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.

Example

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

Bases: 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)[source]

Initialize the BarReplayerOpen filter.

Parameters:

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

__call__(data)[source]

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.

Parameters:

data – The data feed containing the bar to process.

Returns:

True if the length of the stream was changed,

False if it remained unchanged.

Return type:

bool

last(data)[source]

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

alias of BarReplayerOpen