首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何更新已弃用的python zipline.transforms模块?

如何更新已弃用的python zipline.transforms模块?
EN

Stack Overflow用户
提问于 2017-09-21 22:46:21
回答 1查看 405关注 0票数 17

我使用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的受欢迎程度,我认为有很多人在处理这些问题。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46347001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档