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.

示例

>>> cerebro = bt.Cerebro()
>>> cerebro.addobserver(bt.observers.BuySell)
class backtrader.observers.buysell.BuySell[源代码]

基类:Observer

This 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.015 1.5%) Distance to max/min when barplot is True

plotinfo = <backtrader.metabase.plotinfo_obj object>
plotlines = <backtrader.metabase.plotlines_obj object>
__init__(*args, **kwargs)

Wrapped __init__ that properly handles observer initialization

next()[源代码]

Update buy/sell markers based on executed orders.

Calculates average prices for buy and sell orders during the bar.

frompackages = ()
packages = ()