Hey I'm new to quantopian and trying to build a model around VVIX(volatility of volatility). Im having some trouble figuring out fletcher and would love a quick example/explanation how I should present the quandl data in the code. Currently, Im having a error around line 8.
Thanks,
Henry
Heres the code:
def preview(df):
log.info(df.head())
return df
def initialize(context):
context.investment_size = (context.portfolio.cash / 10.0)
fetch_csv('https://www.quandl.com/api/v1/datasets/CBOE/VVIX.csv', vvix = 'VVIX', pre_func = preview)
context.stocks = symbols('xiv')
def handle_data(context, data):
cash = context.portfolio.cash
try:
for s in data:
if 'VVIX' in data[s]:
vvix = data[s]['VVIX']
current_posistion = context.portfolio.positions[s].amount
current_price = vvix
if (vvix >= 120):
if cash > context.investment_size:
order_value(XIV, context.investment_size)
cash -= context.investment_size
elif (vvix <= 90) and (current_position > 0):
order_target(XIV,0)
except Exception as e:
print(str(e))