backtrader.flt module¶
Filter Module - Data filtering for backtrader.
This module provides the base Filter class for data filtering operations. Filters can be applied to data feeds to modify or filter bars during backtesting.
- Classes:
Filter: Base class for data filters.
Example
>>> class MyFilter(bt.Filter):
... def next(self, data):
... # Modify data bar
... pass
- class backtrader.flt.Filter[source]¶
Bases:
ParameterizedBaseBase class for data filters in backtrader.
Filters process data bars and can modify or reject them. Subclasses should override the next() method to implement custom filtering logic.
- _firsttime¶
Tracks if this is the first call.
This class has been refactored from MetaParams to the new ParameterizedBase system for Day 36-38 of the metaprogramming removal project.
- __init__(data_, **kwargs)[source]¶
Initialize the Filter.
- Parameters:
data – The data feed to filter.
**kwargs – Additional keyword arguments for parameters.
- __call__(data)[source]¶
Process a data bar through the filter.
- Parameters:
data – The data feed being filtered.