Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Is fetch_csv still not allowed in Live Trading?

I am getting an error trying to access VIX data fetched from quandl, but only in live trading.

I recall this being an error last year?

EDIT: hmm it is supposed to work apparently, I wonder what I have done wrong that it fails only in live minute trading.

11 responses

Here's a cut down version with even more problems - I don't seem to be getting any callbacks after the pre_func of the fetch. I am not sure if this algo would have worked last night, but it seems like it ought to work in daily backtests, minutely backtests as well as live trading.

EDIT: the one below doesn't even work in backtests!

Anyone know what I am doing wrong with this?

Hey Simon, it looks like there was just no securities referenced. I'm not positive why that causes handle data to not get called, but tossing symbol('SPY') in there seems to have fixed it.

Your change gets it to work in minutely backtests, but it still fails in live paper trading. Any ideas?

My guess is the timestamps. Log the tail of the dataframe when you paper trade it, if the last timestamp is still yesterday's it will not do anything. You will need to add the last known value with todays date. Give that a shot and let me know if it works.

Hmm, the last data point is Friday. If a fetch_csv brings in data date-stamped Monday, would it be available to a minutely algorithm on Monday morning? That would seem to be a problem - what's the most effective way of shifting data to ensure that anything is shifted by one business day, or better yet, forward filling to whatever is necessary to make walk-forward testing and live trading work properly?

Good question, I ran into this using the fetcher for live trading as well, not exactly the same, but similar. Unfortunately Quandl's data will always be lagged by one day (at least) when using the info to paper/live trade.

One thing you could consider is using the pre_func to append a row for the current day to the dataframe. Use the trading calendar to find the next trading day after quandl's most recent data point, if if they update daily, that should be the trading day you are currently on. Think of it as adding your one step ahead prediction, for example, if you assume a martingale series then you'd append the last reported values into a new row with the current date. The pre_func is the only time you get access to the entire series so you can add columns with other derived calculations as well, e.g. moving avgs.

Maybe context can be added to the pre_func arguments so variables can be stored for use during the trading day, that sounds useful for live trading.

Sorry I don't have time to toss together an example, but I think this idea should work in your case. Let us know what behavior you feel would be most convenient for your situation. Fetcher does not get used much in live trading so your feedback will be a big help for working out these sticky points.

David

Hmm, well when I tried the above algorithm on live trading, it was exactly from my pre_func that the exception was happening, so I was skeptical that I could fix it in my pre_func. I will try this weekend I guess.

Okay, so basically you would like to find an easy way to use quandl data in a live trading algo? I'll see what I can come up with as well.

Yes, but this is really only for index data, and please don't do too much on my account! I was just tempted to try out some of my VIX trading strategies in the contest, but got stuck.

I took a stab at this and the example below has been paper trading for a couple days and it seems to be working. I used the pre_func to add the next trading day to the quandl dataframe.