compute_stats
Compute Sharpe, volatility, CAGR, and other performance metrics from a log returns series; use when returns come from an external source or portfolio.
Instructions
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.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"returns": "<returns>",
"trading_days_per_year": "<trading_days_per_year>"
},
"name": "compute_stats"
}
}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 | |||