Bollinger Bands
Rolling mean with standard deviation envelopes
Distributions
Return and PnL histograms with full statistics
Heatmaps
Monthly returns and correlation matrices
Underwater
Per-point drawdown depth for area charts
Trade Scatter
Buy/sell markers with PnL attribution
PlotBundle
One-call extraction of all plot data
Quick Start
One-Call Extraction
from_backtest
Extract all plot data from a BacktestResult in a single call.
| Parameter | Type | Default | Description |
|---|---|---|---|
result | BacktestResult | required | Backtest result object |
n_bins | int | 30 | Bins for histograms |
rolling_window | int | 30 | Window for rolling Sharpe/Sortino |
include_bands | bool | False | Add Bollinger bands to equity |
band_window | int | 20 | Bollinger band window |
band_std | float | 2.0 | Bollinger band std multiplier |
calibration_bins | int | 10 | Bins for calibration plot |
PlotBundle containing all extracted data.
Individual Functions
bollinger_bands
| Parameter | Type | Default | Description |
|---|---|---|---|
series | list[tuple[float, float]] | required | (timestamp, value) pairs |
window | int | 20 | Rolling window size |
num_std | float | 2.0 | Standard deviations for bands |
BandData with timestamps, middle, upper, lower, bandwidth.
underwater_curve
UnderwaterData with per-point drawdown_pct and peak tracking.
histogram
HistogramData with bin_edges, bin_centers, counts, frequencies, plus mean, median, std, skew, kurtosis.
return_distribution
HistogramData.
pnl_distribution
HistogramData of PnL values.
monthly_returns_heatmap
HeatmapData with years as rows and months (Jan-Dec) as columns.
correlation_heatmap
HeatmapData with Pearson correlation coefficients.
rolling_stats
RollingStatData with sharpe and sortino as CurveData.
normalized_equity
NormalizedEquityData with equity normalized to 1.0 and cumulative PnL.
trade_scatter
TradeScatterData with all points, buys, and sells as TradeScatterPoint tuples.
calibration_plot
CalibrationPlotData with bin_centers, actual_freq, perfect_line, ece, and brier_score. Uses Rust calibration_curve() when available, falls back to pure Python.
Output Types
| Type | Fields |
|---|---|
BandData | timestamps, middle, upper, lower, bandwidth |
UnderwaterData | timestamps, drawdown_pct, peak |
HistogramData | bin_edges, bin_centers, counts, frequencies, mean, median, std, skew, kurtosis |
HeatmapData | values, row_labels, col_labels, title |
CurveData | timestamps, values, label |
NormalizedEquityData | timestamps, equity, cumulative_pnl, bands |
TradeScatterPoint | timestamp, price, size, side, market_id, pnl |
TradeScatterData | points, buys, sells |
CalibrationPlotData | bin_centers, actual_freq, counts, perfect_line, ece, brier_score |
RollingStatData | sharpe, sortino |
PlotBundle | equity, underwater, return_hist, pnl_hist, monthly_heatmap, rolling, trades, calibration |