bt

bt

Backtest execution and reporting.

q.bt.report(...) turns a LEAN result JSON into a native qrt report without starting LEAN’s standalone Report Creator or replaying its orders.

Classes

Name Description
BacktestReport A normalized LEAN backtest plus its qrt-native report renderings.

BacktestReport

bt.BacktestReport(
    title,
    description,
    source,
    equity,
    returns,
    benchmark,
    statistics,
    runtime_statistics,
    parameters,
    configuration,
    orders,
    trades,
    trade_statistics,
    figure,
    diagnostics=None,
    margin_allocation=None,
    performance_treemap=None,
    trade_excursions=None,
    trade_returns=None,
    _raw=dict(),
)

A normalized LEAN backtest plus its qrt-native report renderings.

Methods

Name Description
display Display the report in an isolated iframe inside a notebook.
save Write the self-contained report HTML and return its path.
to_html Render a standalone HTML document with embedded Plotly.js.
display
bt.BacktestReport.display(width='100%', height=900)

Display the report in an isolated iframe inside a notebook.

save
bt.BacktestReport.save(path)

Write the self-contained report HTML and return its path.

to_html
bt.BacktestReport.to_html()

Render a standalone HTML document with embedded Plotly.js.

Functions

Name Description
report Create a native qrt report from an original LEAN backtest result.
run Run a backtest. Placeholder.

report

bt.report(
    source,
    *,
    asset_returns=None,
    asset_weights=None,
    title=None,
    description='',
    output=None,
)

Create a native qrt report from an original LEAN backtest result.

The adapter reads recorded result charts and tables directly. It never decodes LEAN security identifiers or replays orders, so custom markets are supported without preprocessing.

Parameters

Name Type Description Default
source str | Path | JsonObject LEAN result JSON path, a backtests directory from which the newest completed result is selected, or an already loaded result mapping. required
asset_returns pd.DataFrame | None Optional wide simple-return frame used for the portfolio performance treemap. NaN means the asset is not in the portfolio at that timestamp. None
asset_weights pd.DataFrame | pd.Series | None Optional time-varying or static portfolio weights. When supplied, nonzero absolute weights determine membership and tile area. None
title str | None Report title. Inferred from the project/configuration when omitted. None
description str Optional strategy description. ''
output str | Path | None Optional destination for a self-contained HTML report. None

Returns

Name Type Description
A BacktestReport class:BacktestReport containing normalized data and Plotly figures.

run

bt.run(signal, prices)

Run a backtest. Placeholder.

Back to top