Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Fetch program not working for paper trading - help please!

This is my code

def rename_col0(df0):
df0 = df0.rename(columns={'Close': 'price'})
df0 = df0.fillna(method='ffill')
df0 = df0[['price', 'Adjusted Close','sid']]
# Do not shift as this will be used live
return df0.shift(0)

fetch_csv('https://www.quandl.com/api/v3/datasets/YAHOO/INDEX_VIX.csv',  
    date_column='Date',  
    date_format='%Y-%m-%d',  
    symbol='v',  
    post_func=rename_col0)

log.info("Vix %.2f" %data.current('v','Adjusted Close'))

This is giving the error

2016-05-03 08:31 my_rebalance:95 INFO Vix nan

It works fine in backtesting (where I shift by 1 to avoid look ahead bias)

Help! Please!!

5 responses

Dude, I posted exact code to fetch VIX that works in backtesting as well as live trading.

Thanks Simon, I don't know what to do now. :-(

I have attached the whole code. Can you please do me a huge favor and deploy it for paper trading and see what happens? I would really appreciate that very much!

Understand that the backtest is not right as it is not shifting the fetch by a day and hence has lookahead bias. I just wanted to share the whole code. Thanks much again!

Here's what the algorithm returns when the fetch is shifted by a day

Sorry, I can't fix your algo for you, though someone else surely can. The gist is that you need to shift the data AND populate a new row at the end of the data with the most recent value, for it to work correctly in backtest and live.

I am not talking about fixing the algo, I am asking why I am getting that NAN error. It's not that it is getting erroneous prices. It's getting no prices if I run it live. However, when you ran it it fetched values.

Thanks a bunch anyway for trying out the first snippet of code and letting me know that it is working for you.