Hi,
I have this code to work out the formula of a boll. slope:
import talib as ta
import numpy as np
import pandas as pd
# Setup our variables
def initialize(context):
context.stocks = symbols('AAPL')
def handle_data(context, data):
for sid in data:
daily_prices = history(bar_count=504, frequency='1d', field='price')
weekly_prices = daily_prices.resample('1W')
weekly_close = np.array(weekly_prices[sid].values.tolist())
weekly_bb_upper, weekly_smaLong, weekly_bb_lower = \
ta.BBANDS(weekly_close, timeperiod=30, nbdevup=2, nbdevdn=2, matype=0)
i = -30
for b in weekly_bb_lower[i:]:
print i
ml, c = np.polyfit( range(3), weekly_bb_lower[i:i+3], 1 )
i += 4
print ml, c
but when I run it I get this error:
24 Error Runtime exception: TypeError: expected x and y to have same length
and I don't understand why!
When I run the ml, c instruction in the debug it returns the values as expected.
Anyone have any ideas?
Thanks in advance for your help.