Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
how to get data from multiple columns in a csv without use of batch_transform?

As mentioned in the title, is there a way of using only fetch_csv() and history() to get data from multiple columns in a csv file without use of batch_transform?
Since in the help doc, it states "Note: This function [batch_transform] is deprecated in favor of history and will stop working at some point in the future. Please start using history instead."

I have attached my current method (use of batch_transform), which seems to be what many shared algorithms are using.
Specifically, within handle data(), get_past_prices() calls batch_transform() to gather data from multiple columns in the csv, and merges the data with security prices obtained using history().

2 responses

Hi Ted,
Currently there is no way to use history to access fetcher data unfortunately. The problems with batch_transform are two fold; one, it requires a warm-up period which you have already seen, and 2, it's being phased out so compatibility with future code changes is unknown.

What you can do is use a context variable to keep a dataframe of the index data as it comes through, then you can join it with sid data from history. You won't solve the problem of needing a warm up period, but you won't have to worry about your code breaking due to us moving further away from batch_transform.

A hacky way to get the initial lookback history is to encode the first days csv value as a string that contains a long list of previous values, then do some splits on the string to recover the original data. It's hacky but I don't see why it wouldn't work.

This post is another hacky way to get historical derived data, but it wont get you the trailing timeseries you are looking for. Sorry there isn't really an elegant solution to this yet, let me know if you have any questions.

Thanks for the in-depth explanation, David!