Hello Friends, 

I need some help to finish developing a tail risk strategy. 

I have three equities I want to purchase ONLY long puts on. SPY, TQQQ, and TECL, each 40% OTM and a 1 year to exp. 

 

They are stored in the dictionary self.uNos (this stands for underlying N options). My algorithms purchases the options fine but then when the option contracts increase in price, my backtest time slows down plenty and I get this error 

I options also do not get any contracts liquidated when they reach their strike price, which may be linked with the error below. 

Insufficient buying power to complete order (Value:3685.5), Reason: Id: 79217, Initial Margin: 3687.25, Free Margin: 0

 

According to my allocation of weights, I am purchasing ETFs to hold and make up 90% of my portfolio {SPY: .2, BND: .3, BNDX: .4 } and the three types of option contracts I am purchasing should only each take up 2% of total portfolios value, leaving me with a 4% buffer. 

 

Overall, I am open to any poor coding critiques and general help with my error handling.