跳转至

fincore.report

Create Strategy Report

fincore.report.create_strategy_report(returns, *, benchmark_rets=None, positions=None, transactions=None, trades=None, title='Strategy Report', output='report.html', rolling_window=63, period='daily', return_result=False)

Generate a strategy report (HTML or PDF) based on the inputs you provide.

参数:

名称 类型 描述 默认
returns Series

Daily return series (required). Must be indexed by a DatetimeIndex.

必需
benchmark_rets Series

Benchmark return series. Enables alpha/beta, tracking error, rolling beta, etc.

None
positions DataFrame

Daily positions DataFrame (columns = asset symbols plus a cash column). Enables positions analysis.

None
transactions DataFrame

Transactions DataFrame (must include amount, price, symbol). Enables transaction analysis.

None
trades DataFrame

Closed trades DataFrame (must include pnlcomm; optional long, barlen, commission). Enables trade statistics (win rate, payoff ratio, etc.).

None
title str

Report title.

'Strategy Report'
output str

Output path. Use .html for HTML and .pdf for PDF.

'report.html'
rolling_window int

Rolling window size (trading days). Default is 63 (about 3 months).

63
period str

Returns period. Default is "daily".

'daily'
return_result bool

Enhanced interface only. When True, compute the report model once and return a :class:ReportArtifacts (owned files, HTML content, and the precomputed model) instead of just the output path. The default path-based return behavior is unchanged.

False

返回:

类型 描述
str

The path to the generated report (return_result=False).

ReportArtifacts

The generated file plus the computed model (return_result=True).

HTML Rendering

fincore.report.render_html.generate_html(returns, benchmark_rets, positions, transactions, trades, title, output, rolling_window, period='daily', *, model=None)

Generate an interactive HTML report (ECharts + sidebar navigation).

参数:

名称 类型 描述 默认
model ReportModel

A precomputed report model. When given, the renderer never computes statistics itself (compute-once, render-many); raw inputs are only used when model is None.

None

PDF Rendering

fincore.report.render_pdf.generate_pdf(returns, benchmark_rets, positions, transactions, trades, title, output, rolling_window, period='daily', *, model=None)

Generate a PDF report by rendering the HTML report via Playwright.

参数:

名称 类型 描述 默认
model ReportModel

A precomputed report model. When given, no statistics are computed here (compute-once, render-many).

None