Skip to main content
Glama

run_backtest

Backtest a strategy spec on daily bars over a date range with explicit costs, returning metrics summary plus equity curve and trade blotter links; cached identical runs return instantly.

Instructions

Run a backtest and return its metrics summary plus links to the equity curve and trade blotter. Identical configurations are cached and return instantly. Worked specs: {'primitive':'buy_and_hold','params':{}}; {'primitive':'sma_cross','params':{'fast':10,'slow':30}}; {'primitive':'threshold','params':{'lookback':15,'entry_pct':1.5,'exit_pct':0.25}}. A spec also carries optional top-level fields beside primitive and params, e.g. {'primitive':'sma_cross','params':{'fast':10,'slow':30},'warmup_bars':60,'rebalance':'weekly','sizing':'fixed_fraction','fraction':0.25}. Unknown fields are rejected rather than ignored. Costs have no default and must be stated: {'fee_bps':5,'slippage_bps':2} is a typical setting, {'fee_bps':0,'slippage_bps':0} is frictionless and has to be asked for. Examples: run_backtest(spec={'primitive':'sma_cross','params':{'fast':20,'slow':50}}, symbol='SYN-04', start='2019-01-01', end='2021-12-31', costs={'fee_bps':5,'slippage_bps':2}); run_backtest(spec={'primitive':'buy_and_hold','params':{},'sizing':'fixed_fraction','fraction':0.25}, symbol='SYN-02', start='2020-01-01', end='2020-12-31', costs={'fee_bps':0,'slippage_bps':0}); run_backtest(spec={'primitive':'threshold','params':{'lookback':15,'entry_pct':1.5,'exit_pct':0.25},'rebalance':'weekly'}, symbol='SYN-09', start='2019-01-01', end='2021-12-31', costs={'fee_bps':1,'slippage_bps':1}). This tool takes NO as_of argument. The cutoff is derived from end, so a run can never be pointed at data later than its own evaluation window. Do not ask for an as_of and do not try to pass one.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endYesLast date of the evaluation window.
specYesA strategy spec object.
costsYesTransaction costs. No defaults; state them explicitly.
startYesFirst date of the evaluation window.
symbolYesSymbol to run against.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.9/5.0
Behavior5/5

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

Since no annotations are provided, the description fully discloses behavioral traits: caching, rejection of unknown fields, no default costs, and the absence of as_of. This is beyond what the schema states and is critical for correct usage.

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 lengthy but highly informative, with key usage notes front-loaded. Every sentence adds value, though the extensive examples could be slightly condensed without loss, but they are justified given the complexity.

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?

Given the tool's complexity (nested spec, cost model, caching), the description covers all necessary aspects: behavior, usage, limitations, and examples. The output schema is present, so return values need no further explanation. This is complete for an agent to call correctly.

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?

While schema coverage is 100% for parameters, the description goes further by explaining the spec structure with examples, the cost model's no-default rule, and illustrating valid parameter combinations. This adds meaning beyond the raw schema definitions.

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 the tool runs a backtest, returns metrics plus links, and how caching works, distinguishing it from siblings like compare_runs or get_run. It uses specific verbs and resources, and the context of backtesting is unique among siblings.

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?

Provides explicit guidance on when to use this tool (run backtests) and what not to do (no as_of argument). It also explains the caching behavior and the requirement to specify costs, leaving no ambiguity about how to invoke it.

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