python 用捆绑运行ZIPLINE PIPELINE

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 用捆绑运行ZIPLINE PIPELINE相关的知识,希望对你有一定的参考价值。

high = USEquityPricing.high.latest
low = USEquityPricing.low.latest
open_price = USEquityPricing.open.latest
close = USEquityPricing.close.latest
volume = USEquityPricing.volume.latest

if __name__ == '__main__':

    my_pipeline = Pipeline(
        columns={
            'high': high,
            'low': low,
            'open_price': open_price,
            'close': close,
            'volume': volume,
            
        }
    )
    
    bundle_data = load('etf_bundle', os.environ, None)
    pipeline_loader = USEquityPricingLoader(bundle_data.equity_daily_bar_reader, bundle_data.adjustment_reader)

    def choose_loader(column):
        if column in USEquityPricing.columns:
            return pipeline_loader
        raise ValueError("No PipelineLoader registered for column %s." % column)

    cal = bundle_data.equity_daily_bar_reader.trading_calendar.all_sessions
    cal2 = cal[(cal >= "2014-01-03") & (cal <= '2015-03-01')]

    spe = SimplePipelineEngine(get_loader=choose_loader,
                               calendar=cal2,
                               asset_finder=bundle_data.asset_finder)

    results = spe.run_pipeline(my_pipeline,
                               pd.to_datetime("2014-01-03", utc=True),
                               pd.to_datetime('2015-02-27', utc=True)
                              )

    print (results.head(10))

以上是关于python 用捆绑运行ZIPLINE PIPELINE的主要内容,如果未能解决你的问题,请参考以下文章

python 捆绑中的ZIPLINE ETF符号和SIDS

python 运行ZIPLINE PIPELINE(包括模拟输入)

Zipline Beginner Tutorial

python ZIPLINE RUN SIMPLE PIPELINE

python ZIPLINE RUN PIPELINE

python ZIPLINE简单策略与管道因素