backtrader.observers.drawdown module¶
DrawDown Observer Module - Drawdown tracking observer.
This module provides the DrawDown observer for tracking current and maximum drawdown levels during backtesting.
- Classes:
DrawDown: Observer that tracks drawdown and max drawdown levels.
Example
>>> cerebro = bt.Cerebro()
>>> cerebro.addobserver(bt.observers.DrawDown)
- class backtrader.observers.drawdown.DrawDown[source]¶
Bases:
ObserverThis observer keeps track of the current drawdown level (plotted) and the maxdrawdown (not plotted) levels
Params:
fund(default:None)If None, the actual mode of the broker (fundmode - True/False) will be autodetected to decide if the returns are based on the total net asset value or on the fund value. See
set_fundmodein the broker documentationSet it to
TrueorFalsefor a specific behavior
- plotinfo = <backtrader.metabase.plotinfo_obj object>¶
- plotlines = <backtrader.metabase.plotlines_obj object>¶
- __init__(*args, **kwargs)¶
Wrapped __init__ that properly handles observer initialization
- next()[source]¶
Update drawdown values for the current period.
Gets current and maximum drawdown from the analyzer.
- frompackages = ()¶
- packages = ()¶
- class backtrader.observers.drawdown.DrawDownLength[source]¶
Bases:
ObserverThis observer keeps track of the current drawdown length (plotted) and the drawdown max length (not plotted)
Params: None
- plotinfo = <backtrader.metabase.plotinfo_obj object>¶
- plotlines = <backtrader.metabase.plotlines_obj object>¶
- __init__(*args, **kwargs)¶
Wrapped __init__ that properly handles observer initialization
- next()[source]¶
Update drawdown length values.
Gets current and maximum drawdown length from the analyzer.
- frompackages = ()¶
- packages = ()¶
- class backtrader.observers.drawdown.DrawDownOld[source]¶
Bases:
ObserverThis observer keeps track of the current drawdown level (plotted) and the maxdrawdown (not plotted) levels
Params: None
- plotinfo = <backtrader.metabase.plotinfo_obj object>¶
- plotlines = <backtrader.metabase.plotlines_obj object>¶
- __init__(*args, **kwargs)¶
Wrapped __init__ that properly handles observer initialization
- next()[source]¶
Calculate and update drawdown values.
Computes drawdown from peak value and updates maximum.
- frompackages = ()¶
- packages = ()¶