Skip to main content
Glama

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

TableJSON Schema
NameRequiredDescriptionDefault
tradesNo
returnsYes
risk_free_rateNo
benchmark_returnsNo
trading_days_per_yearYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

TDQS

A4.7/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Without annotations, the description carries the full burden. It discloses that a wrong 'trading_days_per_year' silently mis-annualizes metrics, and that the returned metric set depends on the API key's plan. It doesn't mention mutation or side effects, but the tool appears to be read-only, which is adequately implied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with 'Args' and 'Returns' sections, and each bullet is focused. It is concise for the amount of detail, though splitting into subsections could improve scanability slightly. No superfluous text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has 5 parameters (2 required), nested objects, and an output schema. The description covers all parameters, explains return shape ('{"stats": {...}}'), and references 'get_catalog' for metric details. It is complete for a non-trivial computation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, which it does thoroughly. It defines the 'returns' format with 'dates' and 'values' arrays, explains 'trading_days_per_year' with examples (252 for equities, 365 for crypto), describes 'benchmark_returns' shape, and lists fields for 'trades'. This adds critical meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Compute the engine's performance metrics from a returns series,' specifying the verb, resource, and input. It distinguishes the tool from the sibling 'run_backtest' by noting that backtest results already include these statistics.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly says to use this tool when returns came from somewhere other than run_backtest (external system, portfolio), and not to use it when returns come from run_backtest since those already include statistics. This provides clear when-to-use and when-not-to-use guidance, referencing an alternative.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A4.2/5.0
Disambiguation5/5

Every tool targets a distinct operation or resource: backtesting, comparison, macro data, reference catalogs, etc. Even similar tools like run_backtest and compare_backtests are clearly differentiated by purpose and inputs.

Naming Consistency4/5

Overall consistent verb_noun pattern in snake_case, with a few exceptions like engine_info (noun_noun) and export_backtest (verb_noun but less common verb). The pattern is predictable and aids agent selection.

Tool Count4/5

20 tools is slightly above the ideal range but justified by the breadth of the platform (backtesting, data retrieval, reference, export). Each tool serves a clear purpose without redundancy.

Completeness4/5

Covers the full backtesting lifecycle: strategy validation, data sourcing, backtesting, comparison, export, and reference lookups. Minor gaps exist (e.g., no explicit strategy persistence), but the core workflow is complete.

Resources