Skip to main content
Glama

Backtest a rule over a parameter grid, validated

backtest_strategy
Read-onlyIdempotent

Test a rule across a parameter grid on your prices, then validate the best result using variants-run count, deflated Sharpe, overfitting probability, track-record length, costs, and buy-and-hold.

Instructions

Backtest a rule on your prices over a whole parameter grid, then validate the best with the count of variants actually run: deflated Sharpe, overfitting probability, minimum track record, vs buy and hold, after costs. A backtest, deflated or not, is not a forecast and not advice.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gridNoValues per parameter, e.g. {"fast":[10,20],"slow":[50,200]}; every valid combination runs (max 200).
datesNoOptional ISO dates, one per value.
familyYessma_cross (fast, slow), momentum (lookback, skip), mean_reversion (window, entry_z), breakout (lookback), buy_and_hold.
pricesNoPrices, oldest first.
cost_bpsNoCost per unit of turnover, bps; default 5.
allow_shortNoShort instead of flat; default false.
prices_fileNoCSV or JSON of prices on this machine; local server only.
prices_columnNoColumn name or 1-based position.
periods_per_yearNo252 daily (default), 365 crypto, 52 weekly, 12 monthly.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitsNo
sourceNo
selectedNo
variantsNo
validationNo
buy_and_holdNo
plain_readingNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.13.0
    • removedInput schema / properties / grid / propertyNames
      Removed value: -{
      -  "type": "string"
      -}
    • changedInput schema / properties / prices_column / anyOf
      Previous value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "maximum": 9007199254740991,
      -    "minimum": -9007199254740991,
      -    "type": "integer"
      -  }
      -]New value: +[
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "integer"
      +  }
      +]
    • removedOutput schema / additionalProperties
      Removed value: -{}
    • removedOutput schema / properties / buy_and_hold / additionalProperties
      Removed value: -{}
    • removedOutput schema / properties / selected / additionalProperties
      Removed value: -{}
    • removedOutput schema / properties / source / additionalProperties
      Removed value: -{}
    • removedOutput schema / properties / validation / additionalProperties
      Removed value: -{}
    • removedOutput schema / properties / variants / additionalProperties
      Removed value: -{}
  2. Addedv0.12.0

TDQS

A3.7/5.0
Behavior4/5

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

Annotations already declare readOnly/idempotent/non-destructive, so the safety profile is covered. The description adds real behavioral context beyond them: validation is conditioned on the count of variants actually run, results are net of costs, and comparison against buy-and-hold, plus an explicit 'not a forecast / not advice' disclaimer. It stops short of describing result structure, but an output schema exists.

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?

Two sentences, front-loaded with the core action and followed by the validation metric list and the disclaimer. Slightly dense in the colon-list clause but no wasted sentences.

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

Completeness4/5

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

With an output schema present, return values need not be explained, and the description covers the pipeline, cost treatment, and the deflated-Sharpe/overfitting/track-record validation angle. What is missing is sibling routing and any note on grid-size limits (that lives in the schema), so it is nearly but not fully complete.

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

Parameters3/5

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

Schema description coverage is 100%, so every parameter is already documented in the schema (grid cap of 200, periods_per_year conventions, family parameter mapping). The description only gestures at the grid and cost concepts and adds no syntax or format detail beyond the schema, so baseline 3 applies.

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

Purpose4/5

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

States a specific verb (backtest) and resource (a rule over a price series via a parameter grid) plus the follow-on validation step, so the agent understands this is a backtest-plus-validation pipeline. It does not, however, name or contrast itself with the many validate_* / audit_backtest siblings, so the agent must infer the boundary.

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

Usage Guidelines3/5

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

Usage is implied by the description – you call this to run a grid backtest and get validation metrics – but there is no explicit when-to-use vs. the sibling validators (validate_deflated_sharpe, validate_overfitting, audit_backtest), nor any stated prerequisites or exclusions.

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