compute_stats
Compute the engine's performance metrics from a returns series.
Use when the returns came from somewhere
other than run_backtest (an external system, a portfolio) — backtest
results already include these statistics.
Args:
returns: Per-bar log returns as {"dates": [...], "values": [...]}
parallel arrays (ISO-8601 dates).
trading_days_per_year: Required annualization factor — 252 for a
daily equities calendar, 365 for 24/7 crypto. Must match the bar
calendar of the returns series; a wrong value silently
mis-annualizes Sharpe, volatility, and CAGR.
benchmark_returns: Optional benchmark series, same shape — adds
alpha/beta/capture metrics.
trades: Optional trade records (entry_date, exit_date, direction,
return_net, ...) — adds trade-level metrics.
risk_free_rate: Annual risk-free rate as a decimal.
Returns:
{"stats": {...}} — the metric set the API key's plan allows.
See get_catalog('sections') for every metric's id and description.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trades | No | ||
| returns | Yes | ||
| risk_free_rate | No | ||
| benchmark_returns | No | ||
| trading_days_per_year | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||