backtrader.reports.reporter module

Main report generator.

Generates backtest reports in HTML, PDF, and JSON formats.

class backtrader.reports.reporter.ReportGenerator[源代码]

基类:object

Main report generator.

Generates backtest reports in HTML, PDF, and JSON formats.

strategy

Strategy instance

calculator

Performance calculator

charts

Chart generator

Usage example:

report = ReportGenerator(strategy) report.generate_html('report.html') report.generate_pdf('report.pdf') report.generate_json('report.json')

__init__(strategy, template='default')[源代码]

Initialize the report generator.

参数:
  • strategy -- backtrader strategy instance

  • template -- Template name or template string

generate_html(output_path, user=None, memo=None, **kwargs)[源代码]

Generate HTML report.

参数:
  • output_path -- Output file path

  • user -- Username

  • memo -- Notes

  • **kwargs -- Additional template variables

返回:

Output file path

返回类型:

str

generate_pdf(output_path, user=None, memo=None, **kwargs)[源代码]

Generate PDF report.

参数:
  • output_path -- Output file path

  • user -- Username

  • memo -- Notes

  • **kwargs -- Additional template variables

返回:

Output file path

返回类型:

str

generate_json(output_path, indent=2, **kwargs)[源代码]

Generate JSON report.

参数:
  • output_path -- Output file path

  • indent -- JSON indentation

  • **kwargs -- Additional data

返回:

Output file path

返回类型:

str

get_metrics()[源代码]

Get all performance metrics.

返回:

Performance metrics dictionary

返回类型:

dict

print_summary()[源代码]

Print performance summary to console.