Hi,
When I put limit order for crypo coin, it may need to wait sometime to fulfill. During that time, how can I get the accurate money left (which should be my cash minus the money hold for that limit order), so I can send another limit order?
I tried GetBuyingPower, unsettledCash etc, but it seems cannot work. When I put 2nd limit order, it always told me like below:
Order Error: id: 3, Insufficient buying power to complete order (Value:4579.358), Reason: Your portfolio holds 10000 USD, 9327.8493 USD of which are reserved for open orders, but your
Buy order is for 13468.7 LTO. Your order requires a total value of 4579.358 USD, but only a total value of 667.571342 USD is available.
Derek Melchin
Hi Henry111,
When we have standing limit orders for BTC, we can calculate the amount of available USD with
usd_total = self.Portfolio.CashBook["USD"].Amount usd_reserved = sum(x.Quantity * x.LimitPrice for x in [x for x in self.Transactions.GetOpenOrders() if x.Direction == OrderDirection.Buy and x.Type == OrderType.Limit and x.Symbol == self.symbol]) usd_available = usd_total - usd_reserved
See the attached backtest for reference.
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Henry111
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!