backtrader.filters.bsplitter module

Bar Splitter Filter Module - Daily bar splitting.

This module provides the DaySplitterClose filter for splitting daily bars into two parts for intraday replay simulation.

Classes:

DaySplitterClose: Splits daily bars into OHLX and CCCC ticks.

Example

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

Bases: ParameterizedBase

Splits a daily bar in two parts simulating 2 ticks which will be used to replay the data:

  • First tick: OHLX

    The Close will be replaced by the average of Open, High and Low

    The session opening time is used for this tick

And

  • Second tick: CCCC

    The Close price will be used for the four components of the price

    The session closing time is used for this tick

The volume will be split amongst the 2 ticks using the parameters:

  • closevol (default: 0.5) The value indicates which percentage, in absolute terms from 0.0 to 1.0, has to be assigned to the closing tick. The rest will be assigned to the OHLX tick.

This filter is meant to be used together with cerebro.replaydata

params = (('closevol', 0.5),)
__init__(data, **kwargs)[source]

Initialize the DaySplitterClose filter.

Parameters:
  • data – The data feed to apply the filter to.

  • **kwargs – Additional keyword arguments passed to parent class.

__call__(data)[source]

Process the data feed to split daily bars.

This method is called for each bar in the data feed. It splits the daily bar into two parts - an OHLX tick and a CCCC tick - to simulate intraday trading behavior.

Parameters:

data – The data feed containing the bar to process.

Returns:

False if the initial tick can be further processed from stack.

Return type:

bool

backtrader.filters.bsplitter.DaySplitter_Close

alias of DaySplitterClose