I applied this to an algo:
- self.Portfolio.MarginCallModel = MarginCallModel.Null
QUANTCONNECT COMMUNITY
I applied this to an algo:
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.
Gurumeher Sawhney
The line above is the correct way to set the null margin call model. In the algorithm below please see the NullMarginCallModel working as expected -- preventing the liquidation of trades. When the margin call model is set to null the OnMarginCallWarning and OnMarginCall events are never triggered, but when the margin call model is not set, both events and their debug messages are called. If the issue still persists after following the backtest below feel free to share the code here.
Jack Pizza
I don't know what's going on, now testing for 2008 which threw all the margin errors is fine doesn't show them anymore, but when I turn on the the margincall it still doesn't show the margin calls, so something seems off.
Gurumeher Sawhney
After cloning the algorithm I commented out the null assignment of the margin model and added the function def OnMarginCallWarning(self). During the backtest, the function was called numerous times along with margin call orders. This function is called when the margin model is not set to null. Try again and make sure that the project is built before running a backtest.
Jack Pizza
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!