I'm new to this community and I'm having trouble using the fetcher to import multiple signals from one single csv file.
My data are located at :
https://dl.dropboxusercontent.com/u/503052837/FinalDataFrame.csv
or:
https://copy.com/0F3y2N9kfaatlyzY
They are the same so you can use either one.
I have several columns signals for each of Dow Jones Stocks
And I seem to getting this error every time i run this.
Can someone please explain for this?
def initialize(context):
fetch_csv("https://copy.com/0F3y2N9kfaatlyzY",date_column ='date', date_format = '%m-%d-%Y')
set_symbol_lookup_date('2015-11-01')
context.stocks = symbols('MMM', 'DIS', 'NKE', 'GE', 'AAPL', 'GS', 'MSFT', 'PFE', 'UTX',
'INTC', 'HD', 'PG', 'JPM', 'V', 'TRV', 'DD', 'CSCO', 'BA', 'AXP',
'CVX', 'IBM', 'MRK', 'MCD', 'UNH', 'WMT', 'XOM', 'CAT', 'VZ', 'KO',
'JNJ')
def handle_data(context, data):
for stock in data:
if ("rate" and "retweet") in data[stock]:
indicator1 = data[stock]["rate"]
indicator2 = data[stock]["retweet"]
try:
current_price = data[stock].price
current_position = context.portfolio.positions[stock].amount
#cash = context.portfolio.cash
if (indicator1 < -1) and (indicator2 > 10) and (current_position == 0):
number_of_shares = int((33000 - current_position*current_price)/current_price)
order(stock, number_of_shares)
log.info("Buying shares")
elif (indicator1 > 5) and (indicator2 > 10) and (current_position != 0):
order_target(stock, 0)
log.info("Selling share")
except:
pass
KeyError: 'symbol'
There was a runtime error on line 2.
Thank you very much!