Skip to main content
Glama

Train and Backtest Strategy Code

train_strategy

Train and backtest strategy code on QuantifyMe's prices; returns a job_id at once.

The code is a QuantifyMe strategy file (feature_engineering and strategy_config), from generate_strategy (model "rule-based" gives fixed rules with no ML) or your own. Stop loss and take profit each go with their unit: risk_unit "pips", "usd" (USD a trade) or "pct" (percent of the entry price); a stop_loss or take_profit without risk_unit is refused. Position size is lot_size lots (1 lot = 100,000 units forex, 1 oz gold or silver, 1 bitcoin), so a pip is worth about USD 10 a lot on EURUSD. Each cost left out (commission, swap_long, swap_short, spread_pips) is the market's own (commission USD 6.00 a lot a round trip on forex). The backtest window defaults to the last 40 days (1min at most 30 days, 5min 90). The free plan keeps 2 saved models: delete_model frees a slot.

Billed from the account's credits after the run (about 8.4 credits a second of compute); refused before it starts when the balance is under the estimate. Then call get_training_result(job_id).

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": {
      "code": "<code>"
    },
    "name": "train_strategy"
  }
}

Input Schema

NameRequiredDescriptionDefault
codeYesThe strategy file: Python with feature_engineering and strategy_config, at most 64,000 characters (generate_strategy's `code`).
symbolNoMarket. Default EURUSD.
capitalNoStarting balance in USD, above 0. Default 10,000.
end_dateNoYYYY-MM-DD (UTC).
lot_sizeNoLots a trade, above 0, at most 100. Default 1.0 (100,000 units forex, 1 oz gold or silver, 1 bitcoin).
directionNoThe trades the run may take: long_only, short_only or both. Default the strategy's own.
risk_unitNoThe unit of stop_loss and take_profit: pips, usd (USD a trade) or pct (percent of the entry price). Required with either.
stop_lossNoStop loss distance in risk_unit, above 0 (pips at most 10,000; usd at most 1,000,000; pct at most 10).
swap_longNoUSD a lot a night held long, -1,000 to 1,000. Default the market's own.
timeframeNoBar size. Default 15min.
commissionNoUSD a lot a round trip, 0 to 1,000. Default the market's own.
model_nameNoOptional name: a letter, then letters, digits, _ or -, at most 40. Default the next Model_N.
start_dateNoYYYY-MM-DD (UTC).
swap_shortNoUSD a lot a night held short, -1,000 to 1,000. Default the market's own.
spread_pipsNoThe spread a trade pays, in pips, 0 to 1,000. Default the market's own.
take_profitNoTake profit distance in risk_unit, above 0 (same limits as stop_loss).
train_splitNoShare of the window used to train, 0.5 to 0.95; the rest is the out-of-sample test. Default 0.7.
validation_dateNoYYYY-MM-DD (UTC).
confidence_thresholdNoClassification models only: the score (0 to 100) a signal needs. Default the code's own.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations only say it is a non-read-only, non-idempotent, open-world write; the description supplies the behavior that matters: the call is asynchronous and returns immediately, credits are billed after the run at about 8.4 credits per compute second, and the job is refused up front when the balance is under the estimate. It also discloses retention limits (2 saved models on free) and window caps (40 days default, 30 for 1min, 90 for 5min).

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 and the async/next-call contract, then grouped logically into code, risk/position sizing, costs, window, plan limits, and billing. Dense but nearly every sentence carries operational information; the billing sentence is slightly run-on and the density makes it harder to scan than a bulleted layout would.

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 19-parameter, credit-consuming, asynchronous tool, the description covers the code format and size, the required risk_unit pairing, default fallbacks, backtest window limits, plan caps, and the follow-up call. An output schema exists, so the return payload need not be explained, and the job_id mention is sufficient.

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?

Schema coverage is 100%, so the baseline is 3; the description earns above that by adding cross-field semantics the schema cannot express — a stop_loss or take_profit without risk_unit is refused, lot_size maps to 100,000 units / 1 oz / 1 bitcoin, so a pip is roughly USD 10 a lot on EURUSD, and omitted costs fall back to the market's own (commission USD 6.00 a lot round trip). Several parameters (train_split, confidence_threshold, validation_date, direction, model_name) are left entirely to the schema, so it is not exhaustive.

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 opening clause names a specific verb pair and resource (train and backtest strategy code on QuantifyMe prices) and immediately states the async contract (returns a job_id at once). It distinguishes itself from generate_strategy (code producer) and get_training_result (result consumer) without ambiguity.

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 routes the agent explicitly: obtain code from generate_strategy with model "rule-based" for no-ML rules, or supply your own; then call get_training_result(job_id). It also names delete_model as the remedy when the free plan's 2-model cap is hit, which is a genuine when-to-use alternative.

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