我使用quantopian zipline包http://www.zipline.io/beginner-tutorial.html编写了一个python程序。我最近更新了这个包,发现zipline.transforms包被弃用了。我使用的是zipline.transforms包中的两个函数:batch_transform()
和MovingAverage
。
除了说用history()
函数替换batch_transform
之外,我还找不到一个好的帖子来演示如何修复这个问题。然而,我不知道如何准确地替换它。我还没有找到一篇关于如何修复MovingAverage弃用的文章。
这是我正在使用的代码。
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()
有人能提供一个如何更新上面的代码的例子吗?考虑到quantopian的受欢迎程度,我认为有很多人在处理这些问题。
https://stackoverflow.com/questions/46347001
复制相似问题