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.
    

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?

Adds far beyond annotations: the call blocks while the run is likely to finish and otherwise returns a card that self-updates, runtime is ~30s–2min, there is a daily allowance and refused calls don't count, and the returned shape is `{task_id, status, kind, dashboard_url}`. It also explains `oos_pct` semantics (held-back data never tested) and that result detail scales with run length. Consistent with readOnly=false / idempotent=false ('a change is a new run').

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-loaded with purpose, then sweep rules, then method ids, then output workflow — a sensible order. It is long but dense with distinct facts; only minor waste (the allowance point is restated in two places, and raw indentation from a docstring leaks through).

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 a 22-param, no-output-schema tool, the description covers what an agent needs to call it correctly: required fields, the polling successor, the return shape, cost/allowance, and the sweep-vs-single-run decision. The remaining gap is the undocumented tuning parameters, which the description partially excuses by promising defaults surfaced in the result.

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% across 22 parameters, so the description carries the burden. It does well on the high-value ones — `sweep` gets a full shape, step bounds and objective choices; `primary_method` gets id/params structure with all four ids and aliases; `question` and `oos_pct` are explained. But roughly sixteen parameters (duration, leverage, direction, timeframe, spread_bps, regime_filter, risk_budget_k, signal_params, stop_loss_pct, take_profit_pct, max_holding_days, position_sizing*, risk_per_trade_pct, commission_per_trade, initial_capital) are undocumented anywhere, relying only on 'sensible defaults'.

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?

Opens with a specific verb and resource ('Run a Stochastic Methods backtest') and names the concrete model families (OU, Kalman), then explicitly contrasts with the sibling `start_backtest` (indicator rules) by stating this engine fits a stochastic model to the price series. An agent can distinguish it from every other start_* sibling without opening a schema.

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?

Explicit routing: grids/sweeps/'best setting' must be ONE call with `sweep`, 'never many single runs', with the reason (one task, one run of allowance). It also routes to `list_stochastic_methods()` for valid method ids and to `get_stochastic_backtest_progress` for results, and states a run started here needs no `show_report_card`.

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