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.
Louis Szeto
Hi Diego
There are multiple option contract positions, rather than just 1. Thus, when multiple 2% are stacked up, it exceeds the margin requirement easily. Also, when the dictionary self.uNos values changes, the original contract stored is not liquidated, so it has an open position in the portfolio without any exit rules applicable which further increases the overall exposure.
We suggest you limit the frequency of running setPuts method or only update self.uNos, when the original contract stored is liquidated (i.e. when the dict value is set to be None).
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.
Diego Munoz
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!