I'm trying to fetch securities from an external CSV, following examples here on forum, but something doesn't seem to work as intended. The code fails with error "AttributeError: 'str' object has no attribute 'start_date'" on the last line. Logs don't contain output from my_universe, however have "WARN Dropped 2838 rows from fetched csv." (which is the number of lines in the CSV).
# Called once at the start of the simulation.
def initialize(context):
fetch_csv('https://docs.google.com/spreadsheets/d/1oMHOIy1qus83dy7g2vHNjbFqQ2Da6AWk63P8Xd7MIGY/export?format=csv', universe_func=(my_universe), decimal=',', quotechar='"')
# Function for returning a set of SIDs from fetcher_data
def my_universe(context, fetcher_data):
print 'Hello, world'
sids = set(fetcher_data['sid'])
symbols = [s.symbol for s in sids]
context.count = len(symbols)
print "total universe size: {c}".format(c=context.count)
return sids
# Called every minute of the simulation.
def handle_data(context, data):
if 'price' in data['R:AKCII']:
record(data['R:AKCII'].price)