Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Using Fetcher to buy stocks on a CSV list

I used the algorithm from this post to try to mimic since I'm new to python and struggling a little. All I want to do is have quantopian pull the stock tickers from my csv and then allocate an equal percentage of the paper capital to each ticker on the list. I have the date pointing to the Earnings Date column in the CSV because I wasn't sure if the function required a date column. Any help is greatly appreciated. Sorry about the poor formatting, I couldn't figure out how to attach the algorithm since it wouldn't backtest without throwing errors. Here is my code below:
import datetime
import pandas as pd
import numpy as np

def preview(df):
log.info(' \n %s ' % df.head())
return df

Function for returning a set of SIDs from fetcher_data

def my_universe(context, fetcher_data):
ticker = fetcher_data('Ticker')
sids = set(ticker['sid'])
symbols = [s.symbol for s in sids]
context.count = len(symbols)
print "total universe size: {c}".format(c=context.count)

# Compute target equal-weight for each stock in the SP500 Financials universe  
context.target_weight = 1.0/context.count  
return sids

def initialize(context):
fetch_csv(
"https://drive.google.com/file/d/0B00RVitCnJJuTm9BeTVYdGYzZm8/view?usp=sharing",
pre_func=preview,
date_column='Earnings Date',
universe_func=(my_universe))

context.target_weight = 0.01  

def handle_data(context,data):

# Loop over every stock in the Financials sector and make sure we have an equal-weight  
# exposure using the order_target_percent() method.  
for stock in data:  
    # Guard for missing stock data  
    if 'price' in data[stock]:  
        order_target_percent(stock,context.target_weight)  
    else:  
        log.warn("No price for {s}".format(s=stock))