I fetched the VIX data from yahoo and wanna apply the RSI indicator from ta-lib to that data. However, an error showed up: "Exception: input_arrays parameter missing required data key: close".
import pandas
import math
rsi = ta.RSI(timeperiod = 5)
def rename_col(df):
df = df.rename(columns={'Close': 'close_price', 'Open': 'open_price', 'High': 'high', 'Low': 'low'})
df = df.fillna(method='ffill')
df = df[['close_price', 'open_price', 'high', 'low', 'sid']]
return df
def initialize(context):
fetch_csv('http://ichart.finance.yahoo.com/table.csv?s=%5EVIX&a=1&b=1&c=1902&d=07&e=4&f=2039&g=d&ignore=.csv',
date_column='Date',
date_format='%Y-%m-%d',
symbol='vix',
usecols=['Close', 'High', 'Open', 'Low'],
post_func=rename_col)
context.spy = sid(8554)
pass
def handle_data(context, data):
rsi_data = rsi(data)
log.info(rsi_data)
Can anyone tell me what's wrong with the code? Thx!