Dear QuantConnect team,
I have been experimenting with SPX options and I'm currently facing a number of issues.
To simplify debugging i have attached a streamlined version of the backtesting script.
Here is what I noticed:
1) I'm using the setFilter to subset the option chains within a given DTE. If I'm looking at zero DTE, no chains/contracts are returned.
# One week in January 2021. SPX trades Monday, Wednesday, Friday.
self.SetStartDate(2021, 1, 11)
self.SetEndDate(2021, 1, 15)
# Using Days to Expiration
self.dte = 0
With the above parameters I would expect the chain to be available three times (Mon, Wed, Fri) during the backtesting period, however no chains are returned by the filter method.
Log:
2021-01-11 09:55:00 : Entering method openPosition
2021-01-11 09:55:00 : -> No chains!
2021-01-12 09:55:00 : Entering method openPosition
2021-01-12 09:55:00 : -> No chains!
2021-01-13 09:55:00 : Entering method openPosition
2021-01-13 09:55:00 : -> No chains!
2021-01-14 09:55:00 : Entering method openPosition
2021-01-14 09:55:00 : -> No chains!
2021-01-15 09:55:00 : Entering method openPosition
2021-01-15 09:55:00 : -> No chains!
Setting self.dte = 1 also produces no results.
2) Setting self.dte >= 3, I can see a chain being returned, however when submitting a MarketOrder to sell I get a warning that the order was filled at a stale price based on the previous day price
# Using Days to Expiration
self.dte = 5
Log:
2021-01-11 09:55:00 : Entering method openPosition
2021-01-11 09:55:00 : -> No chains!
2021-01-12 09:55:00 : Entering method openPosition
2021-01-12 09:55:00 : -> Found 346 contracts in the option chain!
2021-01-12 09:55:00 : Time: 01/12/2021 14:55:00 OrderID: 1 EventID: 1 Symbol: SPX 210115P05400000 Status: Submitted Quantity: -1 IsAssignment: False
2021-01-12 09:55:00 : Time: 01/12/2021 14:55:00 OrderID: 1 EventID: 2 Symbol: SPX 210115P05400000 Status: Filled Quantity: -1 FillQuantity: -1 FillPrice: 1598.5 USD OrderFee: 1 USD Message: Warning: fill at stale price (01/11/2021 15:20:00 America/Chicago) IsAssignment: False
2021-01-13 09:55:00 : Entering method openPosition
2021-01-13 09:55:00 : -> Found 345 contracts in the option chain!
2021-01-14 09:55:00 : Entering method openPosition
2021-01-14 09:55:00 : -> Found 334 contracts in the option chain!
2021-01-15 09:55:00 : Entering method openPosition
2021-01-15 09:55:00 : -> Found 1 contracts in the option chain!
I must be missing something, can you please advise?
Louis Szeto
Hi Rocco
If the CurrentSlice that the algorithm fetched at the scheduled event (the minute slice) is without any trade/quote on the required option symbol, it'll receive no option chain data. And if there the quote is coming from a fill-forward data, it'll be filled by its last price as a stale price by the security initializer setting.
To avoid the problem of the current slice without data, we recommend using GetOptionContractList together with AddOptionContract. Please check the attached backtest.
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.
Spacetime
How do I access the expiry date of the option for which I am holding?I have a function written to liquidate the options before the expiry date, but I need to figure out how to access the expiry date of the option.
Varad Kabade
Hi Spacetime,
We can use the Expiry(datetime) attribute of the option contract object to get the options contract's expiry date. Refer to the following link for more information on the OptionContract class.
Best,
Varad Kabade
Rocco Claudio Cannizzaro
Thank you Louis,
Really appreciated your help!
It seems that GetOptionContractList returns only options with monthly expirations, is there a way to include Weekly options?
Best Regards,
Rocco
Varad Kabade
Hi Rocco,
To filter out weekly contracts, we can use
Best,
Varad Kabade
Rocco Claudio Cannizzaro
Hi Varad,
Thank you for your comment, I'm actually trying to include weekly options.
Without doing any filtering, I see that the contracts being returned are only the monthly ones. See the log from the attached backtest running from Jan 11th (Monday) to Jan 20th (Friday) 2021. With SPX weekly options expiring 3 times a week, I'm expecting to see expirations for Jan 11 (Weekly), 13 (Weekly), 15 (Monthly), 18 (Weekly), 20 (Weekly), 22(Weekly), …
However I only see the monthly expirations:
Not sure if it is something to do with the code, or perhaps SPX weekly data is not available on QuantConnect?
Louis Szeto
Hi Rocco
We're sorry that only monthlies are available for IndexOption right now. We'll include weekly option contracts in the future.
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.
Rocco Claudio Cannizzaro
Hi Louis,
Following up on the 0-DTE options using the Monthly SPX data, it turns out that all the fills have a stale price, If I print the price and time of the last known price for an option, it shows that the price is the one from the day before:
Log:
It seems that the SPX Index Option 0-DTE quote data is basically unavailable, which would explain why the setFilter method would return no chains at all for 0-DTE (my very first post).
This makes me wonder:
Best Regards, Rocco
.ekz.
Bump on this…
Varad Kabade
Hi Rocco Claudio Cannizzaro,
Best,
Varad Kabade
Yayaya
But the backtest codes above indeed show there are “No CHAINS” for SPX 0 DTE, despite there may be data (or not). 0 DTEs SPX seem not available.
Any updates on this?
Louis Szeto
Hi Yayaya
You should change line 55 in InitialFilter method as
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.
Sergf Berg
Hi Lous,
I tried your code:
And the for the most days the output is:
Louis Szeto
Hi Sergf
We cannot reproduce your problem. Can you attach a backtest that causing that?
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.
Sergf Berg
Hi Louis,
I am trying 2022-06 dates and see only “No chains”. Backtest attached
Louis Szeto
Hi Sergf
The monthly option expiration date was 17 June 2022 for June 2022, so it was normal to have no chain since your filtering was 0-DTE. Just shift the end date of the algorithm.
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.
Sergf Berg
Louis,
Ok, I see you answered about a year ago:
“We're sorry that only monthlies are available for IndexOption right now. We'll include weekly option contracts in the future.”
Do you have plans to include weekly options at this time?
Alexandre Catarino
Hi Sergf Berg ,
QuantConnect has launched a WeFunder campaign to give the community more control over the priorities to implement new features such as supporting new brokerages or a new security type such as weekly index options.
Best regards,
Alex
Joe F
I'd like to piggy back on this issue, specifically for SPX 0 DTE options. I've noticed a couple issues in the data:
(a) when using GetOptionContractList with self.Time as the filter, no options are returned that expire on the same day. You must specify the day before, in which case options are returned for the day of expiry eg Fri May 20, 2022 which is a monthly expiry:
self.OptionChainProvider.GetOptionContractList(self.spx, self.Time.date()+timedelta(days=-1))
(b) In doing so though it appears that no price updates occur for any contracts on that day of expiry. In the backtest attached, the prices for 4 legs of an IC are dumped at 9:30 and 3:00pm with no movement whatsoever, given that the fill forward has used the last known price to set it up, but no further price moves occur during the day of expiry. This appears to be a flaw, since clearly such options remain trading on the day of expiry. If you adjust the dte parameter in Find0DTEOptions to be 1, (ie expires tomorrow) then price movements do indeed occur, so the issue seems limited to no price data on the day of expiry.
This, combined with the lack of weeklies on indexes, appears to be a major limit in backtesting an index 0DTE strategy…
Joe F
Just a followup on my last post, I've realised SPX doesn't trade on its expiry date, ceases trading the day before. This would resolve (b) above.
Rocco Claudio Cannizzaro
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!