Skip to main content
Glama
fd-paper-trading MCP Server

fd-paper-trading MCP Server

Official

Run Backtest

run_backtest

Start a background backtest of a strategy over a daily-bar date window, then poll the run status until results or an error are available.

Instructions

Start a backtest of a strategy over a daily-bar window.

The backtest runs in the background; poll get_strategy_run(run_id) until status is COMPLETED (stats + equity curve) or FAILED (error message).

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": {
      "strategy_id": "<strategy_id>",
      "start": "<start>",
      "end": "<end>"
    },
    "name": "run_backtest"
  }
}

Input Schema

NameRequiredDescriptionDefault
endYesWindow end date, ISO format
riskNoOptional run-level risk overlay — ``stop_loss_pct`` / ``trailing_stop_pct`` (fractions in (0,1)) and ``cooldown_bars`` (int). Honoured on **both tracks** with the same semantics: the check runs on every trading day (not only on rebalance dates), a trigger closes that symbol at the worse of the stop level and that bar's open (gap-conservative), and the symbol's *effective* target weight is 0 for ``cooldown_bars`` rebalances while the snapshot keeps the strategy's own ``target_weights`` beside ``effective_weights`` so the zero is attributable. Omitted = no overlay at all (the absent/disabled distinction is preserved on purpose: the API stores a snapshot only when the field is sent).
startYesWindow start date, ISO format (e.g. "2025-01-01")
sort_byNoRanking key for ``param_grid``'s matrix (default ``sharpe``). Ignored when ``param_grid`` is absent, exactly as on REST.
benchmarksNoOptional benchmark symbols (e.g. ``["000300.SS"]``). When given, the run attaches each benchmark's curve and the relative metrics (excess return / tracking error / information ratio); unavailable benchmarks are reported as missing, never fabricated.
cost_modelNoOptional cost model — ``enabled`` plus ``commission_rate`` / ``stamp_tax_rate`` / ``slippage_bps`` (A-share defaults). Defaults to disabled, so a call that omits it prices the backtest at zero cost. It applies on both tracks (single-symbol and weight/multi-symbol).
param_gridNoOptional parameter grid — ``{param: [values...]}``. When given, every combination is scanned and the ranked matrix lands in the run's ``scan_results``.
strategy_idYesUUID of the strategy
initial_cashNoStarting cash for the simulated portfolio100000
walk_forwardNoOptional walk-forward split — ``train_window`` / ``test_window`` / ``step`` (all ints, bars). All three or none: the API refuses a partial triple rather than guessing the missing one. When given, the OOS segments are attached to the run's ``walkforward_windows``.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4/5.0
Behavior4/5

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

Adds genuinely useful behavior beyond the annotations: the run is asynchronous and backgrounded, and the agent must poll a named tool until a terminal status, with results (stats, equity curve) or an error message at the end. This complements openWorldHint/readOnlyHint=false rather than contradicting them. Not disclosed: that the call is non-idempotent so retries create duplicate runs, and any cost/latency of launching a scan.

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

Conciseness5/5

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

Two sentences, zero filler, with the action front-loaded and the polling contract second. Every clause earns its place by telling the agent both what happens and what to do next.

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?

Given an output schema exists, the description need not explain return values, and it correctly focuses on the async lifecycle instead. For a 10-parameter, open-world write tool the remaining gap is minor: it omits non-idempotency and that the returned run_id is what feeds the poll call.

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% and the parameter descriptions are unusually rich (risk overlay, cost model, walk-forward, param_grid, benchmarks), so the schema carries the semantic load. The description names no parameters and adds no meaning beyond what the schema already states, which is the baseline expectation when coverage is complete.

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 and resource ('Start a backtest of a strategy') plus the data scope ('daily-bar window'), which is enough to distinguish it from read-only siblings like get_strategy_run or list_strategy_runs. It stops short of contrasting with compare_runs or describing what a 'strategy' must already be, but the core purpose is unambiguous.

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?

Gives explicit follow-up guidance: after calling, poll get_strategy_run(run_id) until COMPLETED or FAILED, naming the sibling to use and the terminal states. It does not say when not to use this tool (e.g. to re-inspect an existing run) or mention that repeated calls spawn new runs, so it is clear context without exclusions.

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