Hi,
I am working on an Iron Condor algorithm. I keep getting insufficient fund errors, and I think that is because the algorithm is not exercising the options that limit losses after I get assigned in the wing regions (feel free to chime in if that's not the reason). So, my question is this: do options automatically get exercised if they can be? If not, is there an assignment event I can use to exercise my option, and what would the syntax of directing that event to a function be?
Louis Szeto
Hi John
The reason for having insufficient margin is because there is a new Condor position added 3 times every day, given you call self.AddToPortfolio() at the end of AdjustOptions. Removing that line will avoid this error. Of course, it is also necessary to have sufficient capital for a large universe.
Nonetheless, we spotted the use of a dynamic universe but the variables are kept static without changing. We suggest using the OnSecuritiesChange method for correctly adjusting the list holding symbols that are favorable. The list self.condor_list is also overwritten in for-loops, we suggest using a dictionary to hold that for multiple symbols trading. We also remove functions that are not in use and improve the speed by using GetOptionContractList rather than AddOption. Please check the attached backtest for details.
The options will be exercised/assigned automatically when they can be. You may track the event by:
Check this related thread on how to implement it.
Best
Louis Szeto
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.
John Boesen
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!