Option combo margin calculation

I'm backtesting a strategy using a bull put spread and I'm finding that the margin calculations are incorrect and my orders are rejected as invalid.

The margin requirement is usually calculated as the max loss, which should be (high strike - low strike) * 100. Details here:

However it looks like LEAN doesn't support calculating the margin for a spread and treats it as if I'm trying to sell a naked put then buy a completely unrelated option. See attached backtest.

Am I doing something incorrectly here or does LEAN not support option spread margin calculation?

If the latter, is there somewhere to report it? And is it possible to turn off the margin checks to work around it? I know I can just set an obscenely high starting cash but that breaks profit calculations.

Update Backtest

Update Backtest


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.


This discussion is closed