Greetings,
Its my first day on Q, so please excuse my noobishness.
I am trying to calculate EMA from 15d window history, but no luck.
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
# init
set_symbol_lookup_date('2015-01-01')
# get data
context.stocks = symbols('AAPL', 'TSLA', 'FB', 'NFLX')
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
for stock in context.stocks:
last_15 = history(bar_count = 15, frequency='1d', field='close_price')
print last_15[stock]
ema_15 = ta.EMA(timeperiod=15)
print ema_15(last_15[stock])
#print ta.EMA(last_15[stock], timeperiod=15)
This code returns an error:
AttributeError: 'SingleBlockManager' object has no attribute 'itervalues'
There was a runtime error on line 18.
While
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
# init
set_symbol_lookup_date('2015-01-01')
# get data
context.stocks = symbols('AAPL', 'TSLA', 'FB', 'NFLX')
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
for stock in context.stocks:
last_15 = history(bar_count = 15, frequency='1d', field='close_price')
print last_15[stock]
#ema_15 = ta.EMA(timeperiod=15)
#print ema_15(last_15[stock])
print ta.EMA(last_15[stock], timeperiod=15)[-1]
Returns:
TypeError: __init__() got multiple values for keyword argument 'close'
There was a runtime error on line 21.
Does anyone know what I'm missing here?