I wrote a python program using the quantopian zipline package http://www.zipline.io/beginner-tutorial.html. I recently updated the package and have encountered that the zipline.transforms package is deprecated. I was using two functions from the zipline.transforms package, batch_transform()
and MovingAverage
.
I haven't been able to find a good post demonstrating how to fix this, other than saying to replace batch_transform
with the history()
function. However, I am unaware how exactly to replace it. I haven't found a post telling how to fix the MovingAverage deprecation.
Here is my code I am using.
from zipline.algorithm import TradingAlgorithm
from zipline.transforms import batch_transform
from zipline.transforms import MovingAverage
class TradingStrategy(TradingAlgorithm):
def initialize(self, window_length=6):
self.add_transform(
MovingAverage, 'kernel', ['price'], window_length=self.window_length)
@batch_transform
def get_data(data, context):
'''
Collector for some days of historical prices.
'''
daily_prices = data.price[STOCKS + [BENCHMARK]]
return daily_prices
strategy = TradingStrategy()
Could someone provide an example of how to update the code above? I assume there are many people dealing with the issues given how popular quantopian is.