backtrader.filters.daysteps module

Day Steps Filter Module - Bar replay simulation.

This module provides the BarReplayerOpen filter for splitting bars to simulate replay behavior.

Classes:

BarReplayerOpen: Splits bars into open and OHLC parts.

示例

>>> data = bt.feeds.GenericCSVData(dataname='data.csv')
>>> data.addfilter(bt.filters.BarReplayerOpen())
>>> cerebro.adddata(data)
class backtrader.filters.daysteps.BarReplayerOpen[源代码]

基类:object

This filters splits a bar in two parts:

  • Open: the opening price of the bar will be used to deliver an initial price bar in which the four components (OHLC) are equal

    The volume/openinterest fields are zero for this initial bar

  • OHLC: the original bar is delivered complete with the original volume/openinterest

The split simulates a replay without the need to use the replay filter.

__init__(data)[源代码]

Initialize the BarReplayerOpen filter.

参数:

data -- The data feed to apply the filter to. The filter sets resampling=1 and replaying=True on the data.

__call__(data)[源代码]

Process the data feed to split bars into open and OHLC parts.

This method is called for each bar in the data feed. It splits the bar into two parts - an initial bar with only the open price (OHLC=Open) and the original OHLC bar. This simulates intraday replay behavior.

参数:

data -- The data feed containing the bar to process.

返回:

True if the length of the stream was changed,

False if it remained unchanged.

返回类型:

bool

last(data)[源代码]

Called when the data is no longer producing bars Can be called multiple times. It has the chance to (for example) produce extra bars

backtrader.filters.daysteps.DayStepsFilter

BarReplayerOpen 的别名