I'm trying to select option contracts to trade based on their delta. According to this discussion, option greeks should be fairly similar to what's displayed in major brokerages (TD, IBKR).
In this backtest, I'm logging the strike prices chosen by the algo, which should be close to 0.20 delta. Sometimes it's close, others WAY off. For example, on Nov 15, 2022 the algo chose the 462.00C strike when SPY's price was 396.50.. According to ThinkorSwim, that's actually a 0.01 delta.
I'm using option.PriceModel = OptionPriceModels.BjerksundStensland() but am convinced there must be an inconsistency with the way option delta is being calculated?? This can be the only explanation as to why chosen strikes vary so much. I would love to be proven wrong.
Side note: I also noticed on this same day, the algo chose an expiration cycle with 31 DTE, despite option.SetFilter being set between timedelta(45), timedelta(65).
I am selecting a contract by delta, retrieving it's strike price, so that I can then round to the nearest base 5 strike (more liquidity for trading) which makes the issue a bit more complicated. I'm a novice at Python, but hopefully this was at least implemented correctly.
Please forgive the half-baked code, this is supposed to be an iron condor but I only made it as far as the short call :)
Louis Szeto
Hi Eli
I've run your algorithm in debugger mode and found that there was only 1 contract in the option chain of that 2022-11-15 15:50 slice. Thus it is the correct contract to be selected by your algo's logic.
It is very likely that was because no contract was fit into the (-75, 75, timedelta(45), timedelta(65)) filter, particularly the time constraint. Thus, the only contract subscribed (within the option chain) would be the one that you were currently holding. That also explains the weird expiry issue you're experiencing.
We recommend allowing at least 31-day time interval for the filter, or also including weeklies if you would allow that, to avoid no available contract that fits in your filter.
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.
Eli Laycock
Hi Louis,
Thank you very much for your reply! As a novice learning QC, I'm grateful for your help.
I changed the lower bound in the OptionFilter to timedelta(0) and option delta appears to be correct now. I will be sure to filter by at least the duration of 1 monthly cycle as you suggest. I will also make use of the debugging tool in the future!
PS - any idea when Iron Condors will be officially supported as an OptionsStrategies method?
Much appreciated!
Sincerely,
Eli
Louis Szeto
Hi Eli
Currently Iron Condor has not been supported by OptionStrategies or multi-leg combo orders, but we've been working on that feature. Right now you might use 2 Strangles as a workaround. We'll announce it once it was published.
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.
Eli Laycock
Hi Louis, great to hear the team is working on iron condors and multi-leg combos. I'm sure many in the QC community will be eagerly looking forward to them being implemented 😊
In terms of my initial request for help, I was able to build out the rest of this iron condor logic, however it appears that while delta is now being calculated correctly for the short call, it is not correct for the short put. In the attached backtest, the logs show the short put's delta to be close to -0.20, however when I double-check using ThinkorSwim, the chosen strikes actually correspond to -0.02 delta. Seeing as the QC logs appear to show the correct delta reading, I do not know what could be causing this algo to be selecting a strike so far OTM..
The contracts traded in the backtest Orders tab appear to be priced in accordance to such a small delta, with premiums around $0.30. Do you have any idea why delta seems to be incorrect for puts?
Thank you very much,
Eli
Louis Szeto
Hi Eli
I have investigated this case and believe the value of -0.20 is correct. Normally, put has a higher price and delta value due to supply and demand. While the long-put is having a -0.19 delta, the less OTM short put should be higher in absolute value. Another case might be due to SPY is having a discrete dividend payoff during its life cycle, so the QuantLib package cannot handle that well.
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.
Eli Laycock
Hi Louis,
I appreciate you investigating. I'm convinced it still isn't as accurate given the discrepancy between QuantLib and values shown in ThinkorSwim. That SPY put should definitely have more than $0.30 premium. Very curious how the delta calculation on the call was extremely accurate. Nonetheless, I'll continue testing on different assets and seeing what the results are. In the meantime, a workaround would be to set the strike distance based on the difference between the short call and underlying price.
Grateful for your support in the community!
Sincerely,
Eli
Eli Laycock
Hi again Louis,
Still working on this iron condor implementation. After experimenting with various option pricing models, BinomialCoxRossRubinstein() seems to be accurately calculating delta in most cases.
I now seem to be experiencing a different issue, I'm not sure if it's a bug or not. When I go to open the 4 selected option contract objects, I'm now getting “Runtime Error: Trying to dynamically access a method that does not exist”. The strange thing is, this is happening when trying on both self.Buy() or self.LimitOrder() methods. With self.Buy(), the error says “ensure each parameter matches those required by the ‘float’>) method”. For self.LimitOrder(), the ‘int’>) method. Both are the last required arguments, which I think I've entered correctly to the best of my knowledge. Why would it throw a Runtime Error on a built in helper method?
I'm unable to attach the backtest, presumably because it didn't run due to the error.
Louis Szeto
Hi Eli
It is hard to tell what’s the issue without seeing the code/backtest, but I recommend you to check the Buy and LimitOrder API reference on the arguments they shall receive. BTW combo orders are now available, checkout this example on its usage for Iron Condor.
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.
Eli Laycock
Hi Louis,
Appreciate your reply as always 😊 Fantastic news about the Iron Condor now being available under combo orders!!
Eli Laycock
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!