To start out on quantopian I decided to make a few technical indicators and test them, they all work except for one, the MACD. I'm just a physics major and have only had one course in Python so forgive me if I'm overlooking something very obvious.
Normally I do something like this which works fine:
aroondown, aroonup = talib.AROON(high, low, 2)
But with the MACD, in any shape or form resembling this one:
macd, macdsignal, macdhist = talib.MACD(close, 12, 26, 9)
It keeps returning the "AssertionError: real has wrong dimensions" Error...
I've tried the example MACD but as soon as I try to make the function return more than just a single integer value so that I can compute something a little more complex like so:
def handle_data(context, data):
# Load historical data for the stocks
close = history(26, '1d', 'close_price')
macd, macdsignal, macdhist = MACD(close)
# then do some stuff here
def MACD(close, fastperiod=12, slowperiod=26, signalperiod=9):
macd, macdsignal, macdhist = talib.MACD(close, fastperiod=fastperiod, slowperiod=slowperiod, signalperiod=signalperiod)
return (macd, macdsignal, macdhist)
The bloody thing returns the "AssertionError: real has wrong dimensions" error again...
I'm at a loss here, google didn't help me at all, hoping someone might want to tell me what I'm doing wrong.
Thanks.