options for code now that load_from_yahoo isn't working and batch_transforms are deprecated

32 views
Skip to first unread message

Brian Hayden

unread,
Jul 5, 2017, 1:32:29 PM7/5/17
to Zipline Python Opensource Backtester
Hello,

I wrote and heavily verified a code for trading purposes way back in zipline 0.7.0. The code relies somewhat heavily on zipline.transforms.batch_transform, and when that was deprecated, I didn't want to mess with the code too much to get it to work with the new api. I don't really have time now. So I froze an anaconda environment to work with zipline 0.7.0.

I was using load_from_yahoo to get my price data, which now seems to be broken (I think I see that zipline is now using google for prices?). So, I need to do something to get my code working again. These are the modules that my code depended on which seem to be significantly changed in some way:

from zipline.transforms import batch_transform: deprecated in recent versions of zipline
from zipline.utils.factory import load_from_yahoo: broken using old versions of zipline
from zipline.transforms import MovingAverage: is there an equivalent in the latest zipline? zipline.transforms no longer exists

Thanks for any advice on how to update my code.

Brian Hayden

unread,
Jul 5, 2017, 1:43:34 PM7/5/17
to Zipline Python Opensource Backtester
For further clarification, it looks like the biggest things that would need to be changed to update for the transform deprecation are:

@batch_transform
def trailing_return(datapanel):
    # this transform calculates trailing returns with the window set in initialize function
    if datapanel['price'] is None: return None
    pricedf = np.log(datapanel['price'])
    return pricedf.ix[-1]-pricedf.ix[0]

@batch_transform
def get_past_prices(datapanel):
    prices = datapanel['price']
    return prices

And then there's also an instance of a TradingAlgorithm class that uses this:
self.add_transform( MovingAverage, 'mavg200', ['price'], window_length=180)

My preferred fix would be to just get the price data in the same format from something other than load_from_yahoo, unless there is a very easy way to update from the transform deprecation. Just not sure the best way to go here. 
Reply all
Reply to author
Forward
0 new messages