Skip to content

Instantly share code, notes, and snippets.

@twiecki
Created March 31, 2016 12:18
Show Gist options
  • Save twiecki/f3494d4acf44bca79a31e62b5bd81807 to your computer and use it in GitHub Desktop.
Save twiecki/f3494d4acf44bca79a31e62b5bd81807 to your computer and use it in GitHub Desktop.
def initialize(context):
fetch_csv('URL',
date_format='%d/%m/%y',
universe_func=my_universe)
def my_universe(context, fetcher_data):
my_stocks = set(fetcher_data['sid'])
# log the size of the universe for debugging
context.count = len(my_stocks)
print 'total universe size: {c}'.format(c=context.count)
return my_stocks
def handle_data(context, data):
for stock in data:
order_target_percent(stock, data[stock]['weight'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment