Live Trading: History Error (OANDA-Python)


I'm having troubles trying to deploy my algorithm with my live account in OANDA.

It runs OK when backtesting, but when switching to live mode, it fails to retrieve history.

I get a "Index out of range" message. Seems like the ticker is incorrect (i.e. WTICOUSD)

I tried with the Oanda tickers but still doesn't work.

It only fails when it's in live mode...

Any thoughts on what I'm doing wrong?

I also tried specifying the exchange with self.Securities["WTICOUSD"].Exchange = ForexExchange() but no luck.

class DataConsolidationAlgorithm(QCAlgorithm):

def Initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''

self.SetStartDate(DateTime(2017, 07, 03, 9, 30, 0))
self.SetEndDate(DateTime(2017, 12, 29, 9, 30, 0))

# Set Brokerage model to load OANDA fee structure.
self.SetBrokerageModel(BrokerageName.OandaBrokerage, AccountType.Margin)

# Find more symbols here:
#self.Securities["WTICOUSD"].Exchange = ForexExchange()

# Triggers events on a 15-minute basis
fifteenMinuteConsolidator = QuoteBarConsolidator(timedelta(minutes=15))
fifteenMinuteConsolidator.DataConsolidated += self.FifteenMinuteBarHandler
self.SubscriptionManager.AddConsolidator("WTICOUSD", fifteenMinuteConsolidator)

# Triggers events on an hourly basis
oneHourConsolidator = QuoteBarConsolidator(timedelta(hours=1))
oneHourConsolidator.DataConsolidated += self.OneHourBarHandler
self.SubscriptionManager.AddConsolidator("WTICOUSD", oneHourConsolidator)

# Triggers events on a daily basis
oneDayConsolidator = QuoteBarConsolidator(timedelta(1))
oneDayConsolidator.DataConsolidated += self.OneDayBarHandler
self.SubscriptionManager.AddConsolidator("WTICOUSD", oneDayConsolidator)

historyM = self.History(["WTICOUSD"], timedelta(3.5), Resolution.Minute)
historyH = self.History(["WTICOUSD"], timedelta(15), Resolution.Hour)
historyD = self.History(["WTICOUSD"], timedelta(250), Resolution.Daily)

#Custom class
self.a1 = splitHist(self)
self.closeM, self.highM, self.lowM = self.a1.getWTICOUSD(historyM)
self.closeH, self.highH, self.lowH = self.a1.getWTICOUSD(historyH)
self.closeD, self.highD, self.lowD = self.a1.getWTICOUSD(historyD)

#Converts 1-minte prices into 15-minute bars
self.a1 = Resample15M(self)
self.high15M = self.a1.High(self.highM)
self.low15M = self.a1.Low(self.lowM)
self.close15M = self.a1.Close(self.closeM)
Update Backtest

Update Backtest


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.


This discussion is closed