backtrader.observers.buysell module¶
BuySell Observer Module - Buy/sell signal visualization.
This module provides the BuySell observer for visualizing buy and sell orders on the chart.
- Classes:
BuySell: Observer that plots buy/sell markers on the chart.
Example
>>> cerebro = bt.Cerebro()
>>> cerebro.addobserver(bt.observers.BuySell)
- class backtrader.observers.buysell.BuySell[source]¶
Bases:
ObserverThis observer keeps track of the individual buy/sell orders (individual executions) and will plot them on the chart along the data around the execution price level
- Params:
barplot(default:False) Plot buy signals below the minimum and sell signals above the maximum.If False, it will plot on the average price of executions during a bar
bardist(default:0.0151.5%) Distance to max/min whenbarplotisTrue
- 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 buy/sell markers based on executed orders.
Calculates average prices for buy and sell orders during the bar.
- frompackages = ()¶
- packages = ()¶