Hello all,

I have a custom data file that looks like:


Basically trying to add Sector data to my data set for underlying stocks.

The following code, however, does not seem to pull in the data.  I get "no Sectors data" in the log file.

Please take a look:

from clr import AddReference

from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Data import SubscriptionDataSource
from QuantConnect.Python import PythonData

class BasicTemplateAlgorithm(QCAlgorithm):

def Initialize(self):

self.SetStartDate(2018,5,25) #Set Start Date
self.SetEndDate(2018,5,29) #Set End Date
self.SetCash(20000) #Set Strategy Cash
self.AddEquity("SPY", Resolution.Second)

# add the custom set of sector data from an outside file
self.AddData(SectorData, "SECTORS", Resolution.Daily)

# we know the file is available, because the below works
#file = self.Download("https://www.dropbox.com/sh/vf8dp7snigw7j9x/AADniLYgjeV0GTamCI3DTCb9a/Sector_Lookup.csv?dl=1")

# get the universe of stocks every morning
self.UniverseSettings.Resolution = Resolution.Daily
self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)

# Universe selection - coarse
def CoarseSelectionFunction(self, coarse):

# price > 5 and volume > 500k
selected = [x for x in coarse if (float(x.Price) >= 5 and x.Volume > 500000) ]

return [ x.Symbol for x in selected ]

# Universe selection - fine
def FineSelectionFunction(self, fine):

self.Debug("starting fine selection")
# check that "fine" stocks are available in downloaded Ticker/Sector combinations

return [ x.Symbol for x in fine ]

# intraday trading
def OnData(self, data):

if data.ContainsKey("SECTORS"):
self.Debug("SECTORS has been added to data")
self.Debug("no SECTORS data")

if not self.Portfolio.Invested:
self.SetHoldings("SPY", 1)

# Custom data download description
class SectorData(PythonData):

def GetSource(self, config, date, isLiveMode):

url = "https://www.dropbox.com/sh/vf8dp7snigw7j9x/AADniLYgjeV0GTamCI3DTCb9a/Sector_Lookup.csv?dl=1"
return SubscriptionDataSource(url, SubscriptionTransportMedium.RemoteFile)

def Reader(self, config, line, date, isLiveMode):

sectors = SectorData()
sectors.Symbol = config.Symbol

data = line.split(',')
sectors["Ticker"] = data[0]
sectors["Sector"] = data[1]

return sectors