backtrader.bokeh.analyzers.plot module

Live plotting analyzer.

Provides real-time plotting functionality based on Bokeh Server.

class backtrader.bokeh.analyzers.plot.LivePlotAnalyzer[source]

Bases: Analyzer

Live plotting analyzer.

Provides real-time plotting functionality based on Bokeh Server, including: - WebSocket real-time data push - Pause/resume functionality - Forward/backward navigation - Data lookback control

Parameters:
  • scheme – Theme instance, defaults to Tradimo

  • style – Chart style, ‘bar’ or ‘candle’

  • lookback – Amount of historical data to retain

  • address – Server address

  • port – Server port

  • title – Title

  • autostart – Whether to auto-start the server

Example

cerebro.addanalyzer(LivePlotAnalyzer,

scheme=Blackly(), lookback=100, port=8999)

params = (('scheme', None), ('style', 'bar'), ('lookback', 100), ('address', 'localhost'), ('port', 8999), ('title', None), ('autostart', True))
__init__(**kwargs)[source]

Initialize live plot analyzer.

Parameters:

**kwargs – Keyword arguments overriding default parameters: - scheme: Theme instance (defaults to Tradimo) - style: Chart style (‘bar’ or ‘candle’) - lookback: Number of bars to retain in display - address: Server address (default: ‘localhost’) - port: Server port (default: 8999) - title: Chart title (default: ‘Live {StrategyName}’) - autostart: Whether to auto-start server (default: True)

start()[source]

Start from backtrader.

Starts the Bokeh Server.

stop()[source]

Stop from backtrader.

next()[source]

Receive new data from backtrader.

Updates all connected clients.

get_analysis()[source]

Return analysis results.

Returns:

Empty dict (this analyzer is for plotting, does not produce analysis data)

Return type:

dict