I have setup a backtest using IB model.
My algorithm is designed to use 2x leverage.
In an attempt to give myself more control and prevent a margin call, in the OnMarginCallWarning() method I try to liquidate a long position of my choice, but I get an error in
"SecurityTransactionManager.GetSufficientCapitalForOrder()"
What I don't understand is why doesn't this order go through fine.
I would have expected that when selling a long position, no margin check would be required.
If selling short margin would be required, but selling a long position should always go through.
Am I misunderstanding how margin accounts work? Or is this a corner case that needs to be updated in the lean engine?
Jared Broad
Hi Rob! If you're long and closing a position it should close out but we still do a margin check incase you'll end up short. I think this is probably an issue with your algorithm & working with daily data - please share it to get more assistance. If you cannot share the algorithm itself please create a mock up example and send an email to https://www.quantconnect.com/support.
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.
Rob Sauce
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!