Greetings!
I'm trying to run a backtest locally trading options on an hour resolution, but I'm receiving failed data request logs indicating that I need minute data. I can't find a straight answer anywhere, but is it the case that you require minute resolution data when trading options, regardless of the resolution you set in the algorithm?
To be concrete, here is an example of the algorithm I'm trying to run (adapted from BasicTemplateOptionsHourlyAlgorithm):
from AlgorithmImports import *
class BasicTemplateOptionsHourlyAlgorithm(QCAlgorithm):
UnderlyingTicker = "SPY"
def Initialize(self):
self.SetStartDate(2020, 1, 1)
self.SetEndDate(2020, 2, 1)
self.SetCash(100000)
equity = self.AddEquity(self.UnderlyingTicker, Resolution.Hour)
option = self.AddOption(self.UnderlyingTicker, Resolution.Hour)
self.option_symbol = option.Symbol
option.SetFilter(lambda u: (u.Strikes(-2, +2)
.Expiration(0, 180)))
self.SetBenchmark(equity.Symbol)
def OnData(self,slice):
if self.Portfolio.Invested or not self.IsMarketOpen(self.option_symbol): return
chain = slice.OptionChains.GetValue(self.option_symbol)
if chain is None:
return
contracts = sorted(sorted(sorted(chain, \
key = lambda x: abs(chain.Underlying.Price - x.Strike)), \
key = lambda x: x.Expiry, reverse=True), \
key = lambda x: x.Right, reverse=True)
if len(contracts) == 0 or not self.IsMarketOpen(contracts[0].Symbol): return
symbol = contracts[0].Symbol
self.MarketOrder(symbol, 1)
self.MarketOnCloseOrder(symbol, -1)
def OnOrderEvent(self, orderEvent):
self.Log(str(orderEvent))
Trying to run this results in a `failed-data-request` log with the following entries:
...
/option/usa/minute/spy/20200109_trade_american.zip
/option/usa/minute/spy/20200110_quote_american.zip
/option/usa/minute/spy/20200110_openinterest_american.zip
/option/usa/minute/spy/20200110_trade_american.zip
/option/usa/minute/spy/20200113_quote_american.zip
/option/usa/minute/spy/20200113_openinterest_american.zip
...
Of course, running a similar algorithm without options works fine. I've tried variations of this code, but everything results in the same failed data request logs.
If this is a requirement, is it stated anywhere in the docs? I've been trying to find a straight-answer, but can't find any specific reference to this requirement. Assuming you do need minute resolution data to backtest options data, why allow users to pay for hourly resolution option data?
Alexandre Catarino
Hi Nathan Margaglio ,
We have reproduced the issue and opened a GitHub issue to address it:
BacktestingChainProvider Requires Minute Resolution Data #6853
Please subscribe for updates.
Best regards,
Alex
Nathan Margaglio
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!