Hi all, 

I was trying to import custom EURUSD price data in CSV format from DropBox into LEAN for backtesting, but I was unable to do so successfully. 

I tried using the NIFTY template that was provided in the QuantConnect tutorial, but when I changed the link to my dropbox link (containing the EURUSD data), the backtest failed. No trades were made and there was zero results. 

Attached is my code and I would appreciate any help. 
The dropbox link containing the EURUSD data (in CSV) is https://www.dropbox.com/s/6q49hksqtz48sy9/EURUSD1440.csv?dl=1

class MACDTrendAlgorithm(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(2008, 1, 1) #Set Start Date self.SetEndDate(2018, 1, 1) #Set End Date self.SetCash(10000) #Set Strategy Cash # Find more symbols here: http://quantconnect.com/data eurusd = self.AddData(EuroDollar, "EURUSD", Resolution.Daily).Symbol self.UniverseSettings.Leverage = 50 # define our daily macd(12,26) with a 9 day signal self.sma_actual = self.SMA(eurusd,2,Resolution.Daily) self.sma = self.SMA(eurusd,100, Resolution.Daily) self.psar = self.PSAR(eurusd, 0.04,0.04,0.4,Resolution.Daily) self.rsi = self.RSI(eurusd,100, MovingAverageType.Simple,Resolution.Daily) self.previous = datetime.min def OnData(self, data): # only once per day if self.previous.date() == self.Time.date(): return if data.ContainsKey("eurusd"): self.today = CorrelationPair(self.Time) self.today.CurrencyPrice = data["eurusd"].Close '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here.''' # define a small tolerance on our checks to avoid bouncing tolerance = 0.0025 buysignal = (self.sma_actual.Current.Value > self.sma.Current.Value and self.rsi.Current.Value>50 and self.sma_actual.Current.Value>self.psar.Current.Value) sellsignal = (self.sma_actual.Current.Value < self.sma.Current.Value and self.rsi.Current.Value<50 and self.sma_actual.Current.Value<self.psar.Current.Value) sellexit = (self.sma_actual.Current.Value > self.sma.Current.Value) buyexit = (self.sma_actual.Current.Value < self.sma.Current.Value) holdings = self.Portfolio["EURUSD"].Quantity # Long Order if holdings <= 0 and buysignal == True: self.SetHoldings("EURUSD",1.0) # Short Order if holdings <= 0 and sellsignal == True: self.SetHoldings("EURUSD",-1.0) # Long Exit if holdings < 0 and sellexit == True: self.Liquidate("EURUSD") #Sell Exit if holdings > 0 and buyexit == True: self.Liquidate("EURUSD") self.previous = self.Time class EuroDollar(PythonData): '''EURUSD Custom Data Class''' def GetSource(self, config, date, isLiveMode): return SubscriptionDataSource("https://www.dropbox.com/s/6q49hksqtz48sy9/EURUSD1440.csv?dl=1", SubscriptionTransportMedium.RemoteFile) def Reader(self, config, line, date, isLiveMode): if not (line.strip() and line[0].isdigit()): return None # New Nifty object currency = EuroDollar() currency.Symbol = config.Symbol try: # Example File Format: # Date, Open High Low Close Volume Turnover # 2011-09-13 7792.9 7799.9 7722.65 7748.7 116534670 6107.78 data = line.split(',') currency.Time = datetime.strptime(data[0], "%Y-%m-%d") currency.Value = data[4] currency["Open"] = float(data[1]) currency["High"] = float(data[2]) currency["Low"] = float(data[3]) currency["Close"] = float(data[4]) except ValueError: # Do nothing return None return currency

 

Author