Hey, I'm practicing running an algo where I own 100 shares of QQQ and 100 of SPY and sell a naked put on both of them. The QQQ naked put order runs first and is successful and then the SPY naked put order runs the next minute and the order gets rejected. It actually doesn't even submit to IB, it is just listed as invalid due to “Insufficient buying power to complete orders” as you will see in my log below. Issue is that I have PLENTY of margin and buying power. This is a fraction of my account balance and I'm not invested in anything else. The proof of that is the very same minute of the failure I'll log into IB and place the order manually without difficulty. I also asked Interactive Brokers about it and they said they never even saw an order come by for the failed SPY put.
Has anyone run into something like this and can help? Why is quantconnect rejecting this order and what can I do to stop it?
This is my log, not code:
QQQ runs and works fine:
2023-02-03 14:35:00 : Obtaining QQQ naked put contract
2023-02-03 14:35:00 : QQQ Put contract QQQ 230203P00303000
2023-02-03 14:35:00 : QQQ Put contract strike price: 303.0
2023-02-03 14:35:02 : New Order Event: Time: 02/03/2023 14:35:02 OrderID: 3 EventID: 1 Symbol: QQQ 230203P00303000 Status: Submitted Quantity: -1 Message: Interactive Brokers Order Event IsAssignment: False
2023-02-03 14:35:02 : New Order Event: Time: 02/03/2023 14:35:02 OrderID: 3 EventID: 2 Symbol: QQQ 230203P00303000 Status: Filled Quantity: -1 FillQuantity: -1 FillPrice: 0.77 USD OrderFee: 1.053253 USD Message: Interactive Brokers Order Fill Event IsAssignment: False
2023-02-03 14:35:02 : Time: 02/03/2023 14:35:02 OrderID: 3 EventID: 1 Symbol: QQQ 230203P00303000 Status: Submitted Quantity: -1 Message: Interactive Brokers Order Event IsAssignment: False
2023-02-03 14:35:02 : Time: 02/03/2023 14:35:02 OrderID: 3 EventID: 2 Symbol: QQQ 230203P00303000 Status: Filled Quantity: -1 FillQuantity: -1 FillPrice: 0.77 USD OrderFee: 1.053253 USD Message: Interactive Brokers Order Fill Event IsAssignment: False
SPY fails here:
2023-02-03 14:35:02 : Obtaining SPY naked put contract
2023-02-03 14:35:02 : SPY Put contract SPY 230203P00409000
2023-02-03 14:35:02 : SPY Put contract strike price: 409.0
2023-02-03 14:35:03 : New Order Event: Time: 02/03/2023 14:35:02 OrderID: 4 EventID: 1 Symbol: SPY 230203P00409000 Status: Invalid Quantity: -1 Message: Order Error: ids: [4], Insufficient buying power to complete orders (Value:[-547.5]), Reason: Id: 4, Initial Margin: -548.5, Free Margin: 0. IsAssignment: False
2023-02-03 14:35:03 : Order Error: ids: [4], Insufficient buying power to complete orders (Value:[-547.5]), Reason: Id: 4, Initial Margin: -548.5, Free Margin: 0.
Louis Szeto
Hi David Eldringhoff
Naked option would required opening margin of the underlying values it represents (e.g. short 1 naked put option contract at $3 for SPY at $400 would need $400*100=$40000 opening margin). LEAN will calculate before submitting the order to the exchange, blocking the order from submission. If multi-leg strategy is used, we recommend using OptionStrategies helper class or Combo Order, to reduce the margin requirement.
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.
Critical.Error
Hi Louis,
That formula is used for cash secured equity puts. According to the OCC, Writers of uncovered puts or calls must deposit / maintain 100% of the option proceeds* plus 20% of the aggregate contract value (current equity price x $100) minus the amount by which the option is out-of-the-money, (see:
David Eldringhoff
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!