Hey, so if I backtest my options algo it works perfectly. The buy triggers function correctly and the option chain finds and purchases option contracts exactly as expected. However, when I run the algo live. The option chain doesn't function. What is going on here? The buy trigger is met, the algo tries to run the option chain but then just doesn't purchase anything.
Is it my data feed for the live trading? I'm using quant connect for data. When I backtest it uses it too. I dont get why it purchases the options perfectly on backtesting but doesn't even attempt to make the option purchase on live trading. I'm not missing orders, no orders have been placed. I have options access on Interactive brokers and when I run the same algo with the option filter method it will purchase the options fine. Just would prefer to use the option chain as it helps with another aspect of the algo.
Tomorrow I'll try to run the algo live with quant and interactive brokers as combined data feeds. If I run it with just interactive brokers then my results for my consolidated bars on my RSI values aren't correct.
In initialize I have the following:
#QQQ option initialize
self.equityqqq = self.AddEquity("QQQ", Resolution.Minute)
self.equityqqq.SetDataNormalizationMode(DataNormalizationMode.Raw)
self.symbolqqq = self.equityqqq.Symbol
self.contractqqq = str()
self.contractsAddedqqq = set()
for the option chain I have the following code:
def Buyqqqcall(self, data):
# get option data
if self.contractqqq == str():
self.Log("Obtaining QQQ contract")
self.contractqqq = self.OptionsFilterqqq(data)
return
# if not invested and option data added successfully, buy option
if not self.Portfolio[self.contractqqq].Invested and data.ContainsKey(self.contractqqq):
self.SetHoldings(self.contractqqq, 0.05)
self.qqqoptionlist[0] = 5
def OptionsFilterqqq(self, data):
''' OptionChainProvider gets a list of option contracts for an underlying symbol at requested date.
Then you can manually filter the contract list returned by GetOptionContractList.
The manual filtering will be limited to the information included in the Symbol
(strike, expiration, type, style) and/or prices from a History call '''
contractsqqq = self.OptionChainProvider.GetOptionContractList(self.symbolqqq, data.Time)
self.underlyingPriceqqq = self.Securities[self.symbolqqq].Price
# filter the out-of-money put options from the contract list which expire close to self.DTE num of days from now
qqqotm_calls = [i for i in contractsqqq if i.ID.OptionRight == OptionRight.Call and
i.ID.StrikePrice > self.OTM * self.underlyingPriceqqq and
self.DTE - 4 < (i.ID.Date - data.Time).days < self.DTE + 4]
if len(qqqotm_calls) > 0:
# sort options by closest to self.DTE days from now and desired strike, and pick first
qqqcontract = sorted(sorted(qqqotm_calls, key = lambda x: abs((x.ID.Date - self.Time).days - self.DTE)),
key = lambda x: abs(x.ID.StrikePrice - self.underlyingPriceqqq))[0]
if qqqcontract not in self.contractsAddedqqq:
self.contractsAddedqqq.add(qqqcontract)
# use AddOptionContract() to subscribe the data for specified contract
self.AddOptionContract(qqqcontract, Resolution.Minute)
return qqqcontract
self.Log("qqqcontract {0}".format(qqqcontract))
else:
return str()
Alexandre Catarino
Hi David Eldringhoff ,
QuantConnect live data feed does not provide US Equity Options data. You will need to acquire a subscription from Interactive Brokers, and can use the "combined" provider to get the Equity data from QuantConnect.
For more information, please check out the docs:
Our Platform > Live Trading > Data Feeds
Generally, for issues with live trading, please contact support@quantconnect.com with the live deployment attached.
David Eldringhoff
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!