Skip to main content
Glama

start_backtest

Run a backtest of an indicator rule on one stock or ETF, on daily bars.

    A rule the lab's cards hold runs as a circuit of them on the lab's engine, as the lab's assistant builds it
    for the same words, over the span asked: the optimizer tries the settings around the rule on the two years
    before and picks the best, the forward test runs that pick against simply holding, and the autopsy deals the
    test's days again in new orders. It holds the entry's conditions (all must hold to buy), one exit condition, a
    confirming filter, a target and a holding limit (an indicator, or one of its lines, against a level, another
    of its lines or the price; two moving averages crossing); a short side runs long, a share of the account as
    the whole account, a commission as the lab's costs and a stop as the lab's Stop Loss card, each said in one
    line. Its card draws the circuit, lights each card as the run reaches it, shows the result under it, the
    surface of the settings the optimizer tried with its pick, and the fan of the dealt days; a change to a card's
    settings on the card runs it again. Its answer's kind is primitives_run, and get_primitives_run_progress
    follows it. Tuning window by window on past years is start_walkforward. Two exit conditions in one list run on
    the backtester, as before.

    No setting has to be settled before it runs: what the request leaves open (the stock or fund, the
    history, the entry and exit levels, the costs) 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`.

    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 3 minutes. The call returns
    `{task_id, status, kind, dashboard_url}` at once.
    `get_backtest_progress(task_id)` reports progress; when the run has
    finished, its answer carries `result`: the summary in words and, for
    a run of a year or longer, a few rounded figures (the run's return
    next to simply holding the same stock over the same dates, Sharpe,
    worst drop, trades), and `report_url`, the full report.

    `list_indicators()` lists the indicators, their settings and the
    columns each one computes. An indicator is written
    `{"id": "rsi", "params": {"length": 14}}`.

    Args:
        ticker: Stock or ETF symbol (uppercase).
        entry_indicator / entry_conditions: The entry signal (required).
        exit_indicator / exit_conditions: Optional.
        confirmation_indicator / confirmation_conditions: Optional, a filter that
            must also hold on the day the entry fires. The common use is a trend
            filter: a two-day RSI pullback that buys only while the close is above
            its 100-day average is written as confirmation_indicator
            {"id": "sma", "params": {"length": 100}} and confirmation_conditions
            [{"column": "close", "operator": ">", "value": "SMA_100"}].
        timeframe: '1d' (daily bars, the only timeframe this connector runs).
        duration: The history tested, a span back from today: '60d', '6m',
            '1y', '2y', '3y', '5y', '10y' or 'max'; left out, or as given when the person named no span, the last year, said once with the longer run as the next step
            (on the lab's cards the last three years, said in one line; on the
            backtester the whole history held, up to 30 years).
            There is no start date: 'since 2010' is '10y' or 'max', and the
            figures carry the years the run covered.
        direction: 'long' | 'short' | 'both'.
        position_sizing: 'fixed' | 'percent_equity' (the default, as in
            the QuanterLab UI).
        risk_per_trade: Share of the account each trade uses. 1.0, the
            default, is the whole account, as in the QuanterLab UI; a
            smaller share leaves the rest in cash and scales the result
            down with it. Sizing across several positions (Kelly, GARCH,
            fixed) is handled in QuanterLab's portfolio and paper-trading
            tools.
        stop_loss_pct / take_profit_pct / max_holding_days: Optional exits.
        spread_bps / commission_per_trade: Trading costs (default a 10
            basis point spread and no commission).
        oos_pct: Share of the history held back, 0-100 (default 0). The
            run tests only the earlier part, and its result and report say
            the held-back part was never tested; the same run again with
            `oos_pct` 0 tests the whole history.

    Conditions are lists of `{"column": ..., "operator": ..., "value": ...}`;
    every condition in a list has to hold.
        operator: ">", ">=", "<", "<=", "==", "!=", "crosses_above" or
            "crosses_below".
        column: a column the strategy's indicators compute, as
            `list_indicators()` names it ("RSI_14"; "MACD_12_26_9",
            "MACDh_12_26_9" and "MACDs_12_26_9" for the MACD line,
            histogram and signal line), or a price field ("close").
        value: a number, or another column the strategy computes
            (SMA_50 against SMA_200 needs an sma of each length among
            the strategy's indicators).
    Entry and exit usually mirror each other: RSI below 30 in, above 70
    out; MACD crossing above 0 in, crossing below 0 out. An exit identical
    to its entry closes on the entry bar or never, and the run makes no
    trades. A golden cross is entry_indicator sma 50 and exit_indicator
    sma 200, with entry SMA_50 crosses_above SMA_200 and exit SMA_50
    crosses_below SMA_200; a trend line of N days is sma N in both lanes,
    with close crosses_above SMA_N in and crosses_below out.

    Example, long-only MACD momentum on PLTR, the person asking for three years:

        start_backtest(
            ticker="PLTR",
            entry_indicator={"id": "macd",
                             "params": {"fast": 12, "slow": 26, "signal": 9}},
            entry_conditions=[{"column": "MACD_12_26_9",
                               "operator": "crosses_above",
                               "value": 0}],
            exit_indicator={"id": "macd",
                            "params": {"fast": 12, "slow": 26, "signal": 9}},
            exit_conditions=[{"column": "MACD_12_26_9",
                              "operator": "crosses_below",
                              "value": 0}],
            timeframe="1d", duration="3y", direction="long",
        )

    question: Optional. One sentence restating what the run should answer
        ("does the 2-day RSI pullback beat holding SPY?"), not the person's
        message: the title of the report the finished run becomes, and kept
        only as that.

    `report_url` is the run written up as a QuanterLab report (the answer
    against simply holding the stock and SPY, the charts, the numbers,
    what the test cannot tell), and the run's card shows its link, which
    opens without a login. A run can also be kept in the user's library with
    `save_workflow_result` (the result) and `save_trading_config` (the
    settings), when the user wants to keep it.
    

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>",
      "entry_indicator": "<entry_indicator>",
      "entry_conditions": "<entry_conditions>"
    },
    "name": "start_backtest"
  }
}

Input Schema

NameRequiredDescriptionDefault
tickerYes
oos_pctNo
durationNo3y
questionNo
directionNolong
timeframeNo1d
spread_bpsNo
stop_loss_pctNo
exit_indicatorNo
risk_per_tradeNo
entry_indicatorYes
exit_conditionsNo
position_sizingNopercent_equity
take_profit_pctNo
entry_conditionsYes
max_holding_daysNo
commission_per_tradeNo
confirmation_indicatorNo
confirmation_conditionsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / duration / default
      Previous value: -"2y"New value: +"3y"
  2. First observed

TDQS

A3.9/5.0
Behavior3/5

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

Beyond the annotations, the description adds useful context: a daily allowance, runs taking about 30 seconds to 3 minutes, defaults being filled in, and report_url opening without a login. But it is internally inconsistent about execution: it says the call 'waits for the run while it is likely to finish inside it' and then says 'The call returns {task_id, status, kind, dashboard_url} at once.' It also names both get_primitives_run_progress and get_backtest_progress as the progress follower, which could mislead an agent.

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

Conciseness2/5

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

The description is extremely long and front-loads a dense, flowery paragraph about 'the lab's cards' and 'the autopsy deals the test's days again in new orders' before reaching concrete usage. It does include an Args section and an example, but many sentences are convoluted and redundant. For a 19-parameter tool some length is justified, but this is well beyond what the task requires.

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 the 19-parameter schema with nested condition objects and no output schema, the description is largely complete: it covers required fields, defaults, return shape, progress reporting, and limitations like daily-only bars and no start date. The remaining gaps are the contradictory progress-tool names and the inconsistent duration default, which could confuse an agent at invocation time.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage across 19 parameters, the description does most of the work: it explains entry and exit indicators, conditions structure, operators, columns, confirmation filters, direction, position sizing, costs, and oos_pct. It adds substantial meaning beyond the schema, such as 'every condition in a list has to hold' and the golden-cross example. The main flaw is the duration explanation, which says the default is 'the last year' while the schema default is '3y' and the prose also mentions 'the last three years' and 'the whole history held, up to 30 years.'

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 first sentence states a specific verb and resource: 'Run a backtest of an indicator rule on one stock or ETF, on daily bars.' It distinguishes the tool from start_walkforward by saying 'Tuning window by window on past years is start_walkforward,' so an agent can route between them without opening either schema.

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?

The description names start_walkforward as the alternative for window-by-window tuning and says get_backtest_progress follows a run. It also clarifies that a run started here needs no show_report_card and that saving uses save_workflow_result or save_trading_config. However, it does not explicitly state when not to use this tool versus other backtest-like siblings such as start_stochastic_backtest.

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