Validate Strategy Markdown
tt_validate_markdownValidate a strategy spec (markdown OR JSON) against the locked schema.
Auto-detects format: text starting with '{' is treated as JSON, otherwise as markdown (the Tradetron strategy-markdown grammar).
mode: 'create' (strict, for new strategies; checks int types tightly) 'update' (lenient, for already-existing strategies fetched via get_strategy where some legacy types are looser).
ALWAYS call this BEFORE create_strategy. The validator catches:
SCHEMA_LOCK rule violations (settings wrapper, positions vs legs, etc.)
Forbidden condition keys (condition_action, parent, sort, c_new)
Type mismatches (instrument as string, fee_frequency as 'Month', etc.)
Unknown keywords (typos, hallucinated function names)
Structural issues that TT would silently drop on submit
Returns a structured error list with hints for each issue, so you can fix the spec and retry without making a round-trip to TT.
AUTHORING RULES it enforces — follow them up front so you do not round-trip on errors:
Leg Qty is in LOTS; confirm the resolved lot count per leg in your summary. A count of shares/contracts mis-sizes by orders of magnitude.
A per-leg trailing/repair stop (Leg SL trail / Leg Exit / Traded Instrument) anchors the condition that OPENED the leg — usually cond_type='Entry', 'Repair Once' when a Repair Once opened it — never the condition it sits in (a self-reference never arms).
Index strikes use ATM SPOT (NIFTY/BANKNIFTY); MCX uses ATM (no spot). Weekly expiry = the 'Current Week' token, never a Week Day==N filter.
'N minutes after entry' = Time Difference (T2-T1)(EntryTime( underlying), Time('NSE')) >= Number(N) (never gate on != with it); read entry price/time via the Entry* keywords, not a literal.
Init Var takes 2 args (name, default); Get Runtime takes 1 (name). Cross-sectional ranking (top-N) works only inside a Python block.
Never improvise a keyword's signature: if you are not CERTAIN of its argument count and order, call tt_lookup_keyword and copy the returned example's shape (an OHLC read is Position ( CLOSE ( Symbol ( Instrument Name ( ... ) , '5m', 'All' ) ) , '-1' ) — the candle interval lives in Symbol, never in Position). If the logic cannot be expressed from catalog-verified shapes, say so and offer the nearest construct Tradetron supports; never a nearest guess.
GAPS — the trading decisions the user never made. data.gaps lists
each missing or ambiguous piece (no exit, no stop-loss on sold options,
a stop-loss or target the description promises but the logic lacks,
an unstated expiry or quantity, re-entry after an exit, a keyword that
does not run) as {code, field, question, options: [2-4 x {label,
detail, value}], default, blocking}. When gaps is non-empty, do NOT
guess and do NOT ask open-ended: put each gap to the user as its
question with its options, one question per gap, and mark the
option whose value equals default as the usual choice (default: null = no safe default, let them pick). Settle every blocking: true
gap before you create; a non-blocking gap may take its default when
the user says to go ahead. Build exactly what they pick, then validate
again. When the user did not state a leg's expiry or the quantity,
leave that Expiry cell blank or the Qty column out instead of guessing:
the conventional default is applied and the gap comes back so you can
confirm it. Gaps never change valid, errors or warnings.
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": {
"text": "<text>"
},
"name": "tt_validate_markdown"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | 'create' (strict — every check runs) or 'update' (lenient — checks that only apply to a fresh create are skipped). Default 'create'. | create |
| text | Yes |