本文整理汇总了Python中zipline.api.attach_pipeline函数的典型用法代码示例。如果您正苦于以下问题:Python attach_pipeline函数的具体用法?Python attach_pipeline怎么用?Python attach_pipeline使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了attach_pipeline函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: initialize
def initialize(context):
attach_pipeline(make_pipeline(), 'my_pipeline')
# Rebalance each day. In daily mode, this is equivalent to putting
# `rebalance` in our handle_data, but in minute mode, it's equivalent to
# running at the start of the day each day.
schedule_function(rebalance, date_rules.every_day())
开发者ID:4ever911,项目名称:zipline,代码行数:7,代码来源:momentum_pipeline.py
示例2: initialize
def initialize(context):
pipe = Pipeline()
attach_pipeline(pipe, 'example')
# Note that we don't call add_factor on these Factors.
# We don't need to store intermediate values if we're not going to use them
sma_short = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=30)
sma_long = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=100)
sma_val = sma_short/sma_long
# Construct the custom factor
mkt_cap = MarketCap()
# Create and apply a filter representing the top 500 equities by MarketCap
# every day.
mkt_cap_top_500 = mkt_cap.top(500)
remove_penny_stocks = sma_short > 1.0
pipe.add(sma_val, 'sma_val')
pipe.add(mkt_cap, 'mkt_cap')
# Use mkt_cap_top_500 as a mask on rank
pipe.add(sma_val.rank(mask=mkt_cap_top_500), 'sma_rank')
# Use multiple screens to narrow the universe
pipe.set_screen(mkt_cap.top(500) & remove_penny_stocks)
开发者ID:mequanta,项目名称:z-runner,代码行数:28,代码来源:creating_custom_factors.py
示例3: initialize
def initialize(context):
# Create, register and name a pipeline in initialize.
pipe = Pipeline()
attach_pipeline(pipe, 'example')
# Construct a simple moving average factor and add it to the pipeline.
sma_short = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=10)
pipe.add(sma_short, 'sma_short')
# Set a screen on the pipelines to filter out securities.
pipe.set_screen(sma_short > 1.0)
开发者ID:mequanta,项目名称:z-runner,代码行数:12,代码来源:using_pipelines.py
示例4: initialize
def initialize(context):
attach_pipeline(make_pipeline(), 'my_pipeline')
# Rebalance each day. In daily mode, this is equivalent to putting
# `rebalance` in our handle_data, but in minute mode, it's equivalent to
# running at the start of the day each day.
schedule_function(rebalance, date_rules.every_day())
# Explicitly set the commission to the "old" value until we can
# rebuild example data.
# github.com/quantopian/zipline/blob/master/tests/resources/
# rebuild_example_data#L105
context.set_commission(commission.PerShare(cost=.0075, min_trade_cost=1.0))
开发者ID:chaoyeung,项目名称:zipline,代码行数:13,代码来源:momentum_pipeline.py
示例5: initialize
def initialize(context):
pipeline = Pipeline()
context.vwaps = []
for length in vwaps:
name = vwap_key(length)
factor = VWAP(window_length=length)
context.vwaps.append(factor)
pipeline.add(factor, name=name)
filter_ = USEquityPricing.close.latest > 300
pipeline.add(filter_, "filter")
if set_screen:
pipeline.set_screen(filter_)
attach_pipeline(pipeline, "test")
开发者ID:RoyHsiao,项目名称:zipline,代码行数:15,代码来源:test_pipeline_algo.py
示例6: initialize
def initialize(context):
pipe = Pipeline()
attach_pipeline(pipe, "example")
sma_short = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=30)
sma_long = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=100)
# Combined factors to create new factors
sma_val = sma_short / sma_long
# Create and apply a screen to remove penny stocks
remove_penny_stocks = sma_short > 1.0
pipe.set_screen(remove_penny_stocks)
pipe.add(sma_short, "sma_short")
pipe.add(sma_long, "sma_long")
pipe.add(sma_val, "sma_val")
# Rank a factor using a mask to ignore the values we're
# filtering out by passing mask=remove_penny_stocks to rank.
pipe.add(sma_val.rank(mask=remove_penny_stocks), "sma_rank")
开发者ID:mequanta,项目名称:z-runner,代码行数:21,代码来源:combining_and_ranking.py
示例7: late_attach
def late_attach(context, data):
attach_pipeline(Pipeline(), "test")
raise AssertionError("Shouldn't make it past attach_pipeline!")
开发者ID:RoyHsiao,项目名称:zipline,代码行数:3,代码来源:test_pipeline_algo.py
示例8: initialize
def initialize(context):
p = Pipeline('test')
p.add(USEquityPricing.close.latest, 'close')
attach_pipeline(p)
开发者ID:icecube11,项目名称:zipline,代码行数:5,代码来源:test_pipeline_algo.py
示例9: initialize
def initialize(context):
pipeline = attach_pipeline(Pipeline(), 'my_pipeline')
test_factor = TestFactor()
pipeline.add(test_factor, 'test_factor')
开发者ID:barrygolden,项目名称:zipline,代码行数:4,代码来源:test_pipeline_algo.py
注:本文中的zipline.api.attach_pipeline函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论