Normalize Strategy Representations
tt_normalize_strategyRecompile a hand-edited strategy body so its three forms agree.
Every AST-backed field is stored as a family: condition_json (the
builder tree) / condition_value (the engine expression) /
condition_display, and the same triple for a leg's strike, expiry, qty,
limit_price and SL_trigger. Where a *_json exists it is the SOURCE OF
TRUTH — this tool parses it (which validates it), canonicalizes it, and
re-emits the paired text + display from it. Text-only fields are passed
through untouched.
WRITES NOTHING. Pure transform, no TT call, no auth. Pass the body from
tt_get_strategy(id) (dict or JSON string); feed the returned strategy
back through tt_update_strategy to persist it.
IT ALSO CHECKS THE KEYWORDS IT COMPILES. A tree naming a keyword
Tradetron does not have (an invented RSIX, a display name used as a
function) fails with STRATEGY_NORMALIZE_FAILED and
details.keyword_errors, instead of returning tt_RSIX(...) for a
later write to refuse. Keyword errors the input body already carried
are not counted, so an older strategy still normalizes.
WHEN TO USE IT. After a PATCH_REP_DISAGREEMENT — the tree and the
expression describe different logic and you want the TREE's meaning to
win everywhere. For a targeted single-field edit you usually do NOT
need this: send the *_json member ALONE to tt_apply_strategy_patch /
tt_update_strategy and the server derives that one family's text for
you, leaving the rest of the body byte-identical. This tool walks the
WHOLE body, so the blast radius depends on how the strategy was last
written: on an ASB-authored body it rewrites roughly half to two-thirds
of the condition members (re-minted kids, whitespace canonicalisation,
missing argument-slot backfill), on a body that already went through
this transform it rewrites 0. Either way changed lists exactly which
members moved — read it, do not assume a number.
WHERE A TREE IS MISSING ENTIRELY, it is REBUILT from the stored
condition_value. A condition can reach TT with the engine text and no
tree (an imported body whose conditions never carried one): it runs
correctly and cannot be edited, because the ASB condition builder seeds
itself from condition_json alone and so opens EMPTY. A rebuilt tree is
adopted only when re-emitting it reproduces the stored expression, so
the repair can never change what the engine evaluates; the count comes
back as condition_trees_rebuilt, and anything unreadable is listed in
condition_trees_unrecoverable and left untouched. Legs are excluded
on purpose — a text-only qty or expiry is TT's own normal shape.
This is NOT a general text-to-tree edit path. Where a tree already EXISTS it stays the source of truth, so editing condition_value and calling this will NOT update condition_json — it will overwrite your edit with the tree's meaning.
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": {
"strategy": "<strategy>"
},
"name": "tt_normalize_strategy"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| strategy | Yes |