Hello
Here is a strategy that rebalancees a portfolio of 5 stocks once per month initially from a large market cap dynamic universe.
The for each stock it buys an OTM put to hedge assuming that the alpha will be worth spending on hedging.
Still need to fix the margin issues to make sure it is possible to buy the necessary stocks and options.
Cheers
Mia Alissi
Here are the substantive bugs and logic flaws in your strategy (ignoring naming, allocation, and imports):
Missing Option Universe Subscription:
There is no call to
AddOption()for each equity, soOptionChainsmay be empty or never populated for those symbols. You must add an Option security for each stock to receive option chains inOnData.Put Selection Not Guaranteed OTM:
The code selects puts by delta alone (targeting -0.40) but does not verify that the contract is out-of-the-money (OTM). This may result in buying at-the-money or even in-the-money puts, which can be more expensive and affect hedge intent.
Equity Fill Not Validated Before Hedging:
Your code attempts to buy puts immediately after submitting the equity
MarketOrder, without checking if the order has been filled. This can cause a mismatch between shares actually owned and puts bought, potentially overhedging or underhedging.Option Hedging May Repeat or Overlap:
OnDatacan be called multiple times before an equity order actually fills (and before the option order fills as well). Because dictionary entries remain until removed, there is a risk of repeating hedges or issuing duplicate orders for the same stock.Unclear Handling for <100 Share Lot Cases:
When the computed
sharesis less than 100, that symbol is skipped, but there is no clear tracking or explanation for the skipped case. It's simply omitted from further logic, so you may lose intended exposure.History Called Repeatedly in Selection:
The algorithm fetches historical data for every symbol in the top market cap universe every monthly rebalance. This repeated calling of
History()can be expensive and may cause timeouts or slowness in live or backtest environments with larger universes.Universe Removal/Liquidation Risks:
When a stock is removed from the universe and
Liquidateis called, both equity and put should be liquidated; but if the daily data isn't present for a symbol or the contract is illiquid/delisted, positions may remain or not exit as intended, and this is not explicitly handled.No Rolling or Timely Exit for Puts:
Puts expire in about 30 days, but there is no logic to roll, exit, or re-hedge if the underlying remains in the
active_symbolsfor another month. The code does not ensure continuous hedging coverage or prevent holding expired or soon-to-expire contracts.Summary: The most critical issue is the lack of option universe subscription (
AddOption()per stock), as this prevents OptionChains from being available at all. In practice, this could break the entire portfolio hedge intent. Further, the sync between stock ownership and option position isn't guaranteed, and handling for edge cases (like failure to fill or option expiry/roll) is incomplete.Sources: US Index Option Universe - QuantConnect.com, Futures Fast Trend Following, with Trend Strength, docs writing algorithms datasets quantconnect us equity option universe, Automating the Wheel Strategy, Adjusted Trend on Futures
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.
AlMoJo
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!