Hi,

I added weather data as a custom data source (as described here: https://www.quantconnect.com/docs/algorithm-reference/importing-custom-data), but the data is never downloaded. What am I doing wrong?

from Weather import Weather class WeatherSimple(QCAlgorithm): # Taking weather into account using a custom data source (I called it simple because it will not be using the Algorithm Framework) def Initialize(self): # Set Strategy Cash. In live trading, this is ignored and replaced with the actual cash of the account self.SetCash(50 * 1000) # Set start and end date start_date = datetime(year=2017, month=1, day=1) self.SetStartDate(start_date) self.SetEndDate(start_date + timedelta(weeks=12 * 4)) # Set brokerage model self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) # Set benchmark - this is the performance that we want to beat if we aim to "beat the market" self.SetBenchmark("SPY") # Add securities resolution = Resolution.Daily self.tickers = ["AAPL", "IBM", "TSLA", "GOOG"] for ticker in self.tickers: # Request the data symbol = self.AddEquity(ticker, resolution, Market.USA).Symbol # Set data normalization mode self.Securities[ticker].SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted) # SplitAdjusted means that the price is adjusted for splits but dividends are paid directly to my balance # Add WEATHER DATA - as a custom data source self.AddData(Weather, self.tickers[0], resolution) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' # Set Holdings such that each ticker gets the same fraction of our money num_tickers = len(self.tickers) fraction_per_ticker = 1. / num_tickers self.SetHoldings([PortfolioTarget(ticker, fraction_per_ticker) for ticker in self.tickers]) # Get bars for each ticker trade_bars = data.Bars for ticker in self.tickers: # Sometimes, there is no info for some of the symbols if ticker not in trade_bars: continue bar = trade_bars[ticker] # self.Debug(f"{ticker} price at {self.Time}: {bar}") # Check if dividends were paid out during the current time slice for ticker in self.tickers: if data.Dividends.ContainsKey(ticker): ## Log the dividend distribution distribution = data.Dividends[ticker].Distribution self.Debug(f"{ticker} paid a dividend of {distribution}")class Weather(PythonData): ''' Weather based rebalancing''' def GetSource(self, config, date, isLive): source = "https://www.wunderground.com/history/airport/{0}/{1}/1/1/CustomHistory.html?dayend=31&monthend=12&yearend={1}&format=1".format(config.Symbol, date.year); return SubscriptionDataSource(source, SubscriptionTransportMedium.RemoteFile); def Reader(self, config, line, date, isLive): # If first character is not digit, pass if not (line.strip() and line[0].isdigit()): return None data = line.split(',') weather = Weather() weather.Symbol = config.Symbol weather.Time = datetime.strptime(data[0], '%Y-%m-%d') + timedelta(hours=20) # Make sure we only get this data AFTER trading day - don't want forward bias. weather.Value = decimal.Decimal(data[2]) weather["MaxC"] = float(data[1]) weather["MinC"] = float(data[3]) return weather

Thanks!