backtrader.bokeh.analyzers.recorder module

Data recording analyzer.

Records data during strategy execution for subsequent plotting or analysis.

class backtrader.bokeh.analyzers.recorder.RecorderAnalyzer[源代码]

基类:Analyzer

Data recording analyzer.

Records OHLCV data and indicator data during strategy execution.

参数:
  • indicators -- Whether to record indicator data

  • observers -- Whether to record observer data

示例

cerebro.addanalyzer(RecorderAnalyzer, indicators=True)

# Get data after running result = cerebro.run() recorder = result[0].analyzers.recorderanalyzer data = recorder.get_analysis()

params = (('indicators', True), ('observers', False))
__init__()[源代码]

Initialize recorder analyzer.

Sets up storage for data sources, indicators, and observers based on parameter configuration.

start()[源代码]

Analyzer start.

next()[源代码]

Record data for each bar.

stop()[源代码]

Analyzer stop.

get_analysis()[源代码]

Return recorded data.

返回:

Dictionary containing data, indicators and observers

返回类型:

OrderedDict

get_dataframe(data_name=None)[源代码]

Convert data to pandas DataFrame.

参数:

data_name -- Data source name, None means first data source

返回:

pandas.DataFrame or None