Skip to main content
Glama

start_stochastic_backtest

Run a Stochastic Methods backtest (OU, Kalman and the like).

    No setting has to be settled before it runs: what the request leaves open (the stock or pair, the
    method, the entry and exit z-scores, the lookback, the history) runs with sensible defaults, which the
    result names in one short line; a change is a new run. `question` titles its report. The call waits for
    the run while it is likely to finish inside it, then answers with the result; the run's card in the chat
    shows the result or, for a longer run, how far it is, and fills in by itself, with the next steps as
    choices. A run started here needs no `show_report_card`.

    A grid, a sweep, "the best setting" or "try these values and apply the best" is ONE call with `sweep`
    (two of the method's settings, each from min to max in up to 10 steps), never many single runs: the
    sweep is one task and one run of the person's allowance, and its answer carries the grid and the best
    cell's backtest as the run of record, so applying the best needs no second call.

    Unlike `start_backtest` (indicator rules), this engine
    fits a stochastic model to the price series and trades from its
    parameters. `primary_method` is `{"id": ..., "params": {...}}` with
    the id ou_zscore (OU mean-reversion z-score), kalman_mr (Kalman
    adaptive OU), kalman_trend (Kalman trend-following) or ou_pairs
    (cointegration-based pairs, with `ticker_b`); everyday names such as
    "ou", "kalman" or "pairs" are read too, and a setting the method does
    not have is refused by name.

    Every account runs it within a daily allowance; a refused call does not count, and get_started and
    every run's answer give today's count.

    A run takes about 30 seconds to 2 minutes. The call returns `{task_id,
    status, kind, dashboard_url}`; `get_stochastic_backtest_progress`
    reports progress and, when the run has finished, carries `result`:
    the verdict and, for a run of a year or longer, a few rounded figures
    (the run's return next to simply holding the stock, Sharpe, worst
    drop, trades). With `oos_pct` above 0 the run tests only the earlier
    part of the history and its result says the held-back part was never
    tested; the same run again with `oos_pct` 0 tests the whole history.

    When the run has finished, its progress answer also carries `report_url`: the run written up as a
    QuanterLab report (the model against simply holding the stock, or for a pair holding both stocks and
    SPY, the model's own checks, the trades), which opens without a login.

    Use `list_stochastic_methods()` to discover valid `primary_method.id`
    values and parameter shapes.

    Args:
        question: Optional. One sentence restating what the run should answer, not the person's
            message: the title of the report the finished run becomes, and kept only as that.
        sweep: Optional. A grid of two of the method's number settings,
            `{"x": {"name": "z_entry", "min": 1.0, "max": 3.0, "steps": 7},
            "y": {"name": "lookback", "min": 20, "max": 140, "steps": 7},
            "objective": "sharpe"}`: each from min to max in 2 to 10 steps,
            the best cell picked by Sharpe (the default) or by "return". It
            runs as one task and counts as one run; its answer carries the
            grid (every cell's Sharpe, the best cell) and the best cell's
            backtest as the run of record.
    

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": {
      "ticker": "<ticker>",
      "primary_method": "<primary_method>"
    },
    "name": "start_stochastic_backtest"
  }
}

Input Schema

NameRequiredDescriptionDefault
sweepNo
tickerYes
oos_pctNo
durationNo2y
leverageNo
questionNo
ticker_bNo
directionNolong
timeframeNo1d
spread_bpsNo
regime_filterNo
risk_budget_kNo
signal_paramsNo
stop_loss_pctNo
primary_methodYes
initial_capitalNo
position_sizingNofull_equity
take_profit_pctNo
max_holding_daysNo
risk_per_trade_pctNo
commission_per_tradeNo
position_sizing_modeNofixed

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.5/5.0
Behavior5/5

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

The description adds substantial behavioral context beyond annotations: defaults are applied automatically, the call may wait for short runs, longer runs report progress via `get_stochastic_backtest_progress`, sweeps count as one allowance run, and finished runs expose `report_url`. It also discloses runtime, daily allowance behavior, and the return shape `{task_id, status, kind, dashboard_url}`.

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 long but front-loads the core purpose and then organizes details into useful blocks: defaults, sweep behavior, method IDs, allowance, runtime/return, and report output. Some sentences are dense and could be tightened, but the length is largely justified by the tool's complexity.

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?

For a complex 22-parameter tool with no output schema, the description covers the essential call behavior, return shape, progress mechanism, report output, and sweep semantics. It is not fully complete because many optional parameters remain semantically opaque, but an agent can invoke the tool correctly for common cases.

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 0%, so the description must carry parameter meaning. It explains the key parameters well—`primary_method`, `sweep`, `question`, `oos_pct`, and `ticker_b`—but many of the 22 parameters such as `duration`, `timeframe`, `direction`, `leverage`, `regime_filter`, and risk/sizing fields are not described beyond the general statement that defaults apply.

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 states a specific verb and resource: run a Stochastic Methods backtest using OU, Kalman, or pairs models. It explicitly distinguishes this from `start_backtest` by noting that this engine fits a stochastic model to the price series rather than using indicator rules.

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?

It gives explicit routing guidance: use `sweep` for grids or best-setting searches instead of many single runs, use `list_stochastic_methods()` to discover valid method IDs, and no `show_report_card` is needed after a run started here. It also explains when to use `oos_pct` above zero versus zero.

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