Hi,
I'm trying to use leverage on futures but I keep getting the following error:
Backtest Handled Error: Order Error: id: 16619, Insufficient buying power to complete order (Value:4910490), Reason: Id: 16619, Initial Margin: 510973.38, Free Margin: 100000
Can someone help me out?
Louis Szeto
Hi Cheng
The leverage of Future was fixed at 1, and it cannot be set by using the leverage argument. (source) You may use a custom Buying Power Model to override that. Make sure to use SetSecurityInitializer implementation since you'll need to apply that for underlying contracts as well:
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.
Li Cheng
Hi Louis,
Thanks so much for the information!
It's helped me to set leverage for the futures in my algorithm!
For people who are interested in how I updated the code, check out the attached backtest😊
Li Cheng
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!