In OnData, I set a LimitOrder for a limit price of 40. The current Close price is 63.40.
I'm calculating the quantity with this formula: Portfolio.Cash * 0.9 / 40. So, I'm trying to put a limit order that will be worth 90% of my current available cash when it will be executed at the limit price.
But I get this error:
Backtest Handled Error: Order Error: id: 1, Insufficient buying power to complete order (Value:90000), Reason: Id: 1, Initial Margin: 142661.25, Free Margin: 100000
When I divide the number from Initial Margin (142661.25) by the calculated quantity of 2250, I get exactly 63.405, which is the Close price of the finished bar.
Is this a bug? Why would I need margin based on the current price?
Louis Szeto
Hi Daniel
Thank you for reporting. We confirmed that we can reproduce this issue. Please subscribe to this GH issue to track the fixing progress.
Best
Louis
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.
Daniel Hilgarth
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!