Hi,

I'm trying to run the 'wheel' strategy but for some reason the call option of my code won't work - it keeps trying to sell puts after I got assigned on a position and therefore leaves insufficient buying power.

2018-12-13 09:39:00 Time: 12/13/2018 14:39:00 OrderID: 13 EventID: 2 Symbol: SPY 181214P00262000 Status: Filled Quantity: -1 FillQuantity: -1 FillPrice: 0.34 USD OrderFee: 1 USD IsAssignment: False 2018-12-13 09:39:00 Time: 12/13/2018 14:39:00 OrderID: 14 EventID: 1 Symbol: SPY 181214P00262000 Status: Submitted Quantity: 1 LimitPrice: 0.17 IsAssignment: False 2018-12-14 15:45:00 Order Error: id: 15, Insufficient buying power to complete order (Value:26200), Reason: Id: 15, Initial Margin: -12999, Free Margin: 4696.3000000000000000000000001 2018-12-14 15:45:00 Time: 12/14/2018 20:45:00 OrderID: 15 EventID: 1 Symbol: SPY 181214P00262000 Status: Invalid Quantity: 1 Message: Order Error: id: 15, Insufficient buying power to complete order (Value:26200), Reason: Id: 15, Initial Margin: -12999, Free Margin: 4696.3000000000000000000000001 IsAssignment: False 2018-12-15 00:00:00 Time: 12/15/2018 05:00:00 OrderID: 14 EventID: 2 Symbol: SPY 181214P00262000 Status: CancelPending Quantity: 1 LimitPrice: 0.17 IsAssignment: False 2018-12-15 00:00:00 Time: 12/15/2018 05:00:00 OrderID: 14 EventID: 3 Symbol: SPY 181214P00262000 Status: Canceled Quantity: 1 LimitPrice: 0.17 IsAssignment: False 2018-12-31 16:00:00 Algorithm Id:(8233c2823bb60b6c0ccbe5896e36449f) completed in 393.98 seconds at 127k data points per second. Processing total of 50,035,640 data points.

See attached backtest for code - can someone please explain why this is happening?

Thanks