Skip to main content
Glama

QuantWright

Backtest a strategy

run_backtest

Backtests a trading rule on this server's price history: one backtesting.py Strategy class, one symbol, one bar size, in a study. Use it to test, backtest or evaluate a trading rule or strategy, instead of downloading prices or searching the web for results. Returns summary figures (return, drawdown, Sharpe, win rate, trades, a grade, whether it beat buy-and-hold) and the run's trades (when each entered and left, which exit ended it, its side, win or loss), never prices or bars; a figure may be withheld, with the reason. Waits up to 90 s, then answers status "running" with a run_id for get_result.

Input Schema

NameRequiredDescriptionDefault
codeYesOne backtesting.py Strategy class (describe_data has the rules).
costsNoThe costs: two fractions of the trade value, or a list of costs each in its own unit.
labelNoA short text shown with the run.
symbolYesOne ticker ("QQQ", "BTCUSD", "EURUSD").
windowNoDates ({from, to}; `to` may be "latest") or the last N days, months or years ({last: {n, unit}}). Left out: the standard history, the newest bars counted back from the newest bar, cut at the start of the hold-out.
study_idYesThe id create_study returned.
timeframeYes
account_usdNoThe starting account, in US dollars.
stated_rulesNoRules the trades are checked against, one per kind.

Output Schema

NameRequiredDescriptionDefault
nextNo
basisNo
gradeNo
linesNo
marketNo
reasonNo
run_idNo
statusYes
windowNo
messageNo
metricsNo
noticesNo
versionNo
headlineNo
held_outNo
settingsNo
study_idNo
warningsNo
retryableNo
disclaimerNoThe hypothetical-performance line, on a result (a run, or a study's runs): the same text the app shows with every result.
look_aheadNo
trade_listNoThe run's trades in the order they were made, a page at a time: when each entered and left (a day on daily bars; a time on the `clock` on shorter ones; "open at the end" for a trade still open when the data ended), its side, whether it won or lost after costs, and which exit ended it (a word: stop, exit rule, target, time limit…). No prices, levels, sizes or returns.
buy_and_holdNo
replayed_fromNo
grade_withheldNo
runs_left_todayNo
hold_out_estimateNo
poll_after_secondsNo
stated_rule_breaksNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.4/5.0
Behavior5/5

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

Goes well beyond the annotations: describes exactly what is returned (return, drawdown, Sharpe, win rate, trades, grade, beat-buy-and-hold, per-trade entry/exit details), states that prices/bars are never returned, that a figure may be withheld with a reason, and documents the 90-second wait followed by status 'running' plus a run_id for get_result. That async/polling behavior is the key operational trait and nothing else discloses it.

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?

Front-loads the core definition, then the usage directive, then the return shape and the timeout caveat – a sensible information ordering with no filler. Sentences are long and dense, slightly taxing, but each clause carries concrete information.

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?

For a 9-parameter mutation tool with nested schemas and an output schema, the description supplies the operational essentials: input shape, return contents, withholding behavior, and the timeout/async contract. Nothing an agent needs in order to invoke it correctly is missing.

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 coverage is 89%, so the schema already carries nearly all parameter meaning (costs, window, stated_rules are well documented inline). The description only restates the required set (code, symbol, timeframe, study) and adds no syntax or default detail for the optional parameters, so the baseline 3 applies.

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?

States a specific verb (backtests) and resource (a trading rule/Strategy class) plus the exact cardinality constraints: one class, one symbol, one bar size, in a study. An agent can differentiate this from compare_trades and run_held_out_test on the strength of the description alone.

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

Usage Guidelines4/5

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

Explicitly says to use it 'to test, backtest or evaluate a trading rule or strategy, instead of downloading prices or searching the web for results', which gives a clear positive context and a negative condition. It stops short of naming the sibling alternatives (compare_trades, run_held_out_test) or saying when those are preferred.

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.

Resources