@battlegrid/mcp-server 31.2.5 → 31.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: battlegrid-trade-analysis
3
+ description: Read the player's own trading position — where their money actually is, whether each agent is doing the job it was given, what is open right now and how close it sits to its protections, and whether the automation is actually running. Activate whenever the player asks how they are doing, how an agent is performing, what is open, where their funds are, or why something did or did not happen.
4
+ ---
5
+
6
+ # Trade Analysis
7
+
8
+ You are answering "how am I actually doing?" — for a player whose money is deployed through
9
+ agents they configured and largely cannot watch.
10
+
11
+ ## 1. The money map, with a reconciliation line
12
+
13
+ Start with where the money is, always, even when the question is narrower — a per-agent answer
14
+ means nothing without the whole.
15
+
16
+ - `get_account_state` for the account total.
17
+ - `get_agent_fund_allocation` and `get_agent_budget` for what is committed per agent.
18
+
19
+ Then state a **reconciliation line**: the account total against the sum of its parts. If they
20
+ agree, say they agree. **If they do not, state the gap as a gap** — name the amount and say you
21
+ cannot account for it. Never quietly present a total that does not add up, and never adjust a
22
+ figure to make it add up.
23
+
24
+ ## 2. Per agent: "is it doing its job?"
25
+
26
+ Not "what were its returns" — whether it did *the thing it was told to do*.
27
+
28
+ - `get_intelligence_agent` — restate the agent's mandate in one line, in the player's terms. This
29
+ is the yardstick; without it "up 4%" means nothing.
30
+ - `get_agent_performance` and `list_trade_outcomes` — judge against that mandate.
31
+ - `get_trade_outcome_by_decision` / `get_trade_chart` when a specific trade needs explaining.
32
+ - `get_signal_performance` when the question is whether the agent's signals are working, as
33
+ distinct from whether its trades made money.
34
+
35
+ **Name the blemishes.** A verdict with no flaw in it is not a verdict, it is a summary. The trade
36
+ that went against the mandate, the streak, the position held past its thesis — say it. A player
37
+ reading a clean report about a messy account learns nothing.
38
+
39
+ ## 3. Open positions, with protections and distance to trigger
40
+
41
+ - `get_agent_open_positions` per agent, or `list_user_active_positions` for everything at once.
42
+ - For each open position, report its protections **and how far price sits from each trigger** —
43
+ a stop is a number the player cannot act on; "3.1% from the stop" is one they can.
44
+ - `get_deployment_policy` / `get_radar_deployment` when the protection state comes from standing
45
+ policy rather than the position itself. `list_pending_approvals` and `list_gate_blocks` when
46
+ something looks like it should have fired and did not.
47
+
48
+ ## 4. Automation health — unprompted
49
+
50
+ Call `get_agent_automation_status` and surface anything degraded **even when the player did not
51
+ ask about automation**. A player asking "how's my portfolio?" while an agent has silently stopped
52
+ trading is being answered wrongly if you only answer what they asked.
53
+
54
+ Flag it plainly and **offer to diagnose**. The offer is yours; the diagnosis is
55
+ `strategy-doctor`'s — activate it and let its arc run, rather than reading the gate blocks and
56
+ reason codes from here.
57
+
58
+ ## 5. UNDETERMINED, never "no issue"
59
+
60
+ This is the discipline that matters most on this surface.
61
+
62
+ If a tool call fails, returns nothing, or does not cover the thing being asked about, report that
63
+ item as **UNDETERMINED** and say what you could not check. Never convert an absence of data into a
64
+ clean bill of health. "Automation status: UNDETERMINED — the status read failed" is honest and
65
+ actionable. "No issues found" in the same situation is a false statement about the player's money.
66
+
67
+ The same applies to any figure you could not reconcile, any position whose protections did not
68
+ resolve, and any agent whose mandate you could not read.
69
+
70
+ ## Reporting discipline
71
+
72
+ - Report numbers exactly as the tools return them. Never recompute, re-derive, or round.
73
+ - Lead with the money map, then agents, then positions, then automation. The player scans top-down.
74
+ - Be concise, and put the worst news first. Do not bury a degraded agent under a good return.
@@ -1,254 +0,0 @@
1
- ---
2
- name: battlegrid-strategy-studio
3
- description: Author full-power BattleGrid trading strategies over MCP — multi-section reports, benchmark sections, layered conditions with verdicts and enforcement gates, tiered signal weights, routing gates, ATR trade levels, and post-entry position management. Use whenever building or upgrading a strategy so it uses the whole studio, not a bare template. Companion to the `battlegrid` skill, which owns connection and the compile → review → apply workflow.
4
- ---
5
-
6
- # BattleGrid Strategy Studio — full-power authoring
7
-
8
- A default strategy — a few platform sections, no conditions, untouched weights — wastes the
9
- studio. This skill teaches every axis the strategy aggregate owns and how professional desks
10
- compose them. Workflow, envelopes, and error recovery live in the `battlegrid` skill; this one
11
- is about *what to author*.
12
-
13
- **Ground rule: shapes here are binding, tokens are illustrative.** Every metric code, signal id,
14
- header, and bound in this skill was validated against the live server, but the server's
15
- vocabulary moves with deployments. Before compiling, re-discover (`list_strategy_categories` →
16
- `list_strategy_vocabulary` → `get_metric_construction_hints` → `get_strategy_column_contract`,
17
- `list_strategy_signals` → `get_strategy_signal_definition`) and prefer what discovery returns
18
- over anything printed here.
19
-
20
- ## What a strategy owns (author all of it, deliberately)
21
-
22
- | Axis | Fields | What it does |
23
- |---|---|---|
24
- | Identity | `name` ≤50, `tagline` ≤80, `description` ≤500 | How agents and humans find it |
25
- | Timeframe | `timeframe` (from discovery's enabled list) | Anchor rung; cadence persona and regime rung derive from it |
26
- | Report | `sections[]` — platform + custom columns | The per-coin table the agent LLM actually reads |
27
- | Conditions | `conditions[]` — typed boolean trees | Deterministic verdicts (UP/DOWN/NEITHER) + hard enforcement gates |
28
- | Signal rules | `rules[]` — `{signalId, allocation 0–3, required, params?}` | What scores, how much it counts, what must fire |
29
- | Routing gates | `minAggregateScore` 0–1, `minRequiredCount` 0–20, `minAtrPct` | Whether a scored setup may route to a trade |
30
- | Trade levels | `minStopLossAtrMultiple` < `maxStopLossAtrMultiple`, `minRiskRewardRatio` | Where stops/targets may sit |
31
- | Position management | breakEven / trailing / timeDecay dials | How the stop moves after entry |
32
- | Market Read | `marketReadText` ≤2000 with `{...}` markers | Standing orders rendered with live values |
33
-
34
- A compile also always carries `intentSummary`, `assumptions[]`, and `coinSelection` — call
35
- context, not strategy state (see the `battlegrid` skill).
36
-
37
- ## The full-power checklist
38
-
39
- Before compiling a CREATE, confirm all six; a "no" is a decision, not an omission:
40
-
41
- 1. Report has at least one **custom section** whose columns encode the thesis (not only platform
42
- modules), and every column earns its tokens.
43
- 2. **Conditions** encode the entry logic deterministically — building blocks + verdict carriers —
44
- and at least one `required: true` condition guards spend on obvious disqualifiers.
45
- 3. **Every signal you want scoring is named in `rules`** with a deliberate tier; signals you do
46
- not name keep server defaults (typically Off). Verify in the compiled scorecard, never assume.
47
- 4. **Gates** are set against the weight budget you chose (see scoring math below).
48
- 5. **Trade levels + position management** match the setup's geometry and holding period.
49
- 6. `marketReadText` states the standing orders with markers so the agent sees live values inline.
50
-
51
- ## Report grammar — sections and columns
52
-
53
- A custom column is `metric × transform (± chained transform) × timeframe ref (± params)`.
54
- Headers are **system-generated, never named by you**. Validated affix patterns:
55
-
56
- | Transform | Header shape | Example (validated) |
57
- |---|---|---|
58
- | `value` | `<code>` | `bbWidthPct`, `RVOL`, `rate` |
59
- | `trajectory` (window 4) | `<code>_t3 … _t1`, `<code>_now`, `<code>_trend` (rising/falling/flat) | `RSI14_now`, `RSI14_trend` |
60
- | `distance` (price → level) | `dist_<code>` (signed %) | `dist_SMA50` |
61
- | `spread` (base vs operand) | `<base>_<operand>_spread` | `mark_oracle_spread`, `EMA5_EMA13_spread` |
62
- | `aggregate` (window N) | `<code>_mean<N>` | `rate_mean24` |
63
- | `rank` (ordering hi/lo/far/near) | `<code>_rank_<ordering>` — ordinal, 1 = best; compare with `lte N` for top-N | `bbWidthPct_rank_lo`, `closeChg_rank_far` |
64
- | `efficiency` (window N) | `<code>_er` (0–1; 1 = straight move, ~0 = chop) | `close_ltf_er` |
65
- | `maxShare` (window N) | `<code>_maxShare` (0–1 concentration) | `volBase_ltf_maxShare` |
66
- | `classifyZone` / `classifyState` | `<code>_zone` / `<code>_state` | `RSI14_zone` (overbought/oversold/neutral), `ADX_state` (weak/developing/trending/extreme) |
67
-
68
- Non-anchor rungs add a rung affix: `_ltf` (lower) / `_htf` (regime), e.g. `MAalign_htf`,
69
- `zones_htf_support_dist`. Chains are bounded at two: inner `distance`/`spread` → outer
70
- `trajectory`/`aggregate`/`efficiency`/`maxShare`/`rank` (e.g. EMA5 `spread` EMA13 ×
71
- `trajectory` → `EMA5_EMA13_spread_now` + `_trend`). Read exact headers from
72
- `get_strategy_column_contract` or a `preview_strategy_report`'s `conditionColumns` before
73
- writing conditions against them.
74
-
75
- **Timeframe references — two families.** *Relative* (`{rel: "anchor" | "lower" | "regime"}`)
76
- re-resolve when the strategy timeframe changes; `regime` is the anchor's ladder successor (a 4h
77
- anchor's regime rung is 1d today). *Pinned* (`{abs: "<tf>"}`) is fixed and ignores anchor
78
- retunes; its legal set is discovery's `rankedTimeframes` — a **superset** of the authorable
79
- anchor set (`timeframes`), so `{abs: "1d"}` is valid while `1d` is not an anchor. Pinned
80
- headers suffix the literal: `RSI14_1d`, `dist_SMA200_1d`, `MAalign_1d` (validated). `offset: 1`
81
- on a pinned `value` column reads the **last closed** bar of that timeframe — the deterministic
82
- daily-close read; offset does not change the header, so one section carries one offset per
83
- `metric × timeframe`. This is how higher-timeframe theses (daily-chart strategies included)
84
- are authored on an intraday anchor — see the daily pattern in `references/tradingview-ports.md`.
85
-
86
- **Benchmark sections** (`benchmarkTicker: "BTC"` on a custom section) read the *benchmark's*
87
- values instead of the evaluated coin's — the standard way to gate a whole book on market-leader
88
- regime. `benchmarkTicker` is required-nullable on every custom section: send `null` for an
89
- ordinary section, never omit it.
90
-
91
- A bound section takes **indicator** columns only. Crowd/session metrics (the `CROWD_*` family,
92
- `FLOW_ALIGN`, `SMART_RETAIL`, `CAPTAIN_CONF`, `CONFIDENCE`, `SETTLED_AT`, `PERP_SPOT_*`) and any
93
- `rank` transform are refused there (contract 49), because both are defined relative to the cohort
94
- being evaluated and a benchmark sits outside it — a crowd reading is what this session's players
95
- did, a rank is a position among the coins under evaluation. Neither has a value for BTC-as-yardstick.
96
- Put those columns on an ordinary section and `conditionRef` across.
97
-
98
- Budgets are served by discovery (validated today: 32 sections, 32 custom columns, 8 distinct
99
- timeframes, 16 conditions, 16 clauses, 16k estimated report tokens). `preview_strategy_report`
100
- echoes your usage against each cap.
101
-
102
- ## Conditions — deterministic logic over your own report
103
-
104
- Each condition: `{ conditionKey, name, definition, verdict, required, exit, clock, closes }` —
105
- all eight required, no defaults. The conditions axis saves by whole-set replacement, so an omitted
106
- key would silently un-clock a money gate on the next unrelated edit rather than be refused.
107
-
108
- - **Clauses** compare one column: numeric/rank headers take `lt|lte|gte|gt|between`;
109
- classification/direction/event headers take `is|in` with the column's exact vocabulary
110
- (served per header in `conditionColumns` / the column contract).
111
- - **Groups**: `ALL`, `ANY`, `NOT`, `N_OF` (with `n`), depth ≤ 2 (an inner group holds leaves
112
- only).
113
- - **References** (`{kind:"conditionRef", conditionKey}`) compose named conditions; cycles are
114
- rejected, forward references are legal.
115
- - **Column addressing**: `{sectionKey, header}`. `sectionKey: null` is authoring sugar for a
116
- header unique across the whole report; a duplicated header (e.g. `ADX` in two sections) must
117
- be section-qualified. On a **CREATE you omit `sectionKey` entirely** — the server derives it
118
- from the section itself, so the same submitted section yields the same key on every compile, and
119
- minting a `custom:<uuid>` yourself is refused. On an UPDATE or RESTORE, send back the keys
120
- `get_strategy` returned. To qualify a duplicated header, read the key from a preview's
121
- `conditionColumns` or from the candidates a `CONDITION_COLUMN_AMBIGUOUS` refusal offers.
122
- - **Verdict**: `UP` | `DOWN` | `NEITHER` on deciding conditions, explicit `null` on building
123
- blocks. Declaration order is precedence: the first TRUE condition with a non-null verdict
124
- decides the coin's verdict. Put the more specific carrier first.
125
- - **`required: true`** makes a FALSE reading a hard gate: the compose-trade evaluation is
126
- blocked *before any billing or LLM call*. This is the cheapest risk control in the studio —
127
- use it for liquidity floors, regime vetoes, and "never fight the HTF" rules.
128
- - Evaluation is three-valued: `UNRESOLVED` (missing input) is never collapsed to FALSE, and
129
- outcomes read from a still-forming bar are marked provisional.
130
- - **The evidence clock.** `clock: "LIVE"` reads the forming bar; `clock: "CLOSE"` reads settled
131
- bars, and `closes` (1–5) is how many consecutive closed bars must read TRUE — always `1` under
132
- LIVE, which has exactly one frame. A CLOSE clock is legal **only** over a header resolved from
133
- the coin's own candle series at offset 0; frame-inert operands (perp-payload scalars, published
134
- rolling changes, ranks, zone entities, regime labels, enrichment metrics, session scalars) are
135
- refused with `CONDITION_CLOCK_OPERAND_ILLEGAL`. The remedy is a split, not a re-clock: move that
136
- clause into its own LIVE condition and `conditionRef` it.
137
- - **The exit role.** `exit: true` makes a settled TRUE reading close open positions its verdict
138
- opposes — UP exits SHORTs, DOWN exits LONGs, a `NEITHER` or `null` verdict exits both. Legal only
139
- under `clock: "CLOSE"`, because an exit fired on a forming bar is an intrabar exit. Orthogonal to
140
- `required`: the two act on disjoint lifecycles, pre-entry versus open.
141
-
142
- ## Entry — when, and where, an entry is taken
143
-
144
- `{ trigger, confirmTf, closes, bandAtrMultiple, levelSource, levelOffsetAtrMultiple, validForBars }`
145
- — all seven required on every CREATE, no defaults. Replaced WHOLE on save, so an omitted key
146
- reverts an author's discipline silently rather than being refused.
147
-
148
- | `trigger` | What it does |
149
- |---|---|
150
- | `AT_SIGNAL` | Fire on the qualification flip, at whatever bar is on the tape. The platform's flat wall-clock entry window applies. |
151
- | `ON_CANDLE_CLOSE` | The flip ARMS the pair; entry is taken only after a `confirmTf` close that still reads the conditions true and has not displaced beyond the band. |
152
- | `STOP_THROUGH_LEVEL` | A TRIGGER order rests at the level ± offset; the exchange book is the watcher. |
153
- | `ON_RETEST` | A LIMIT order rests at the broken level. Not filling is a correct outcome, not a failure. |
154
-
155
- - `confirmTf` — exactly two values are legal: the strategy's own timeframe and the rung below it
156
- (one only, at the ladder floor). Not the authorable main-candle set.
157
- - `closes` — 1–5 consecutive confirming closes. Must be `1` under any trigger but `ON_CANDLE_CLOSE`.
158
- - `bandAtrMultiple` — the veto width. The entry is VOIDED when the confirming close moved at or
159
- beyond that many ATR against the armed verdict. Strictly `> 0` (zero voids on any adverse move,
160
- which is a filter, not "off"), and at or below the platform's own entry-deviation gate — read it
161
- from `get_trading_config_catalog`.
162
- - `levelSource` — `SWING_HIGH` | `SWING_LOW` | `BOLLINGER_UPPER` | `BOLLINGER_LOWER`, resolved once
163
- at decision time.
164
- - `levelOffsetAtrMultiple` — 0–2, UNSIGNED. Direction is implied by the trigger and the verdict, so
165
- a signed value would invert the trigger's meaning. Must be `0` under a non-level trigger.
166
- - `validForBars` — 1–24 of the strategy's OWN bars, not minutes: a 1h setup waiting for a retest has
167
- not failed after fifteen minutes.
168
-
169
- The legality matrix runs **one way**: all seven keys are always present, so the question is never
170
- "is it set" but "is it set to something that MEANS anything under this trigger". Leave a dial at its
171
- inert value rather than setting one the platform will ignore.
172
-
173
- ## Signal weights — the scorecard is a weighted average, budget it
174
-
175
- Allocation tiers: `0` Off, `1` Normal, `2` Important, `3` Critical.
176
-
177
- ```
178
- aggregateScore = Σ(score × allocation) / Σ(allocation) over triggered signals
179
- ```
180
-
181
- Consequences worth designing around:
182
-
183
- - Weights are **relative**: one Critical among Normals dominates; all-Critical equals all-Normal.
184
- Build a pyramid — 1–2 Critical (the thesis), 2–4 Important (confirmation), a few Normal
185
- (context) — and turn everything else Off so noise cannot dilute the average.
186
- - `required: true` on a rule does two things: the signal counts toward `minRequiredCount` when
187
- it triggers, and the gate blocks routing when too few required signals fired. A rule with
188
- `required: true` at allocation 0 is **rejected** (contract 34) — raise the allocation or clear
189
- the flag.
190
- - `params` are per-signal and replace canonical defaults only when present and valid — tune
191
- thresholds to the strategy (e.g. an RSI-overbought at 65 for a fade book) after reading
192
- `get_strategy_signal_definition({signalId, timeframe})`. Omitted `params` preserve defaults
193
- byte-for-byte.
194
- - Which signals *can* trigger follows from your report's sections/columns
195
- (`derive_strategy_rule_view` shows in-report membership for a draft). Weighting a signal your
196
- report never feeds is dead weight.
197
-
198
- ## Routing gates
199
-
200
- - `minAggregateScore` (0–1): floor on the weighted average above. Set it from your pyramid: if
201
- routing should need the Critical thesis plus one Important confirmation, compute that mix's
202
- aggregate and gate just under it.
203
- - `minRequiredCount` (0–20): how many `required` signals must be among the triggered set.
204
- - `minAtrPct`: minimum ATR as % of price — a dead-market filter; bounds come from
205
- `get_trading_config_catalog` (validated today: 0.1–10).
206
-
207
- ## Trade levels (ATR geometry)
208
-
209
- `minStopLossAtrMultiple < maxStopLossAtrMultiple` (band where the stop may sit; ceiling capped
210
- at the structural 3×ATR), `minRiskRewardRatio` (catalog bounds today: 0.5–3). Position size is
211
- risk-budget based (`riskPct / stopDistancePct` — see the `battlegrid` skill's contract notes),
212
- so a *wider* stop means a *smaller* position, not more risk. Tight bands suit breakout entries;
213
- wide bands suit mean reversion that needs room.
214
-
215
- ## Position management (how the stop moves)
216
-
217
- Validated live bounds: `breakEvenTriggerR` 0.5–2 · `trailingTriggerR` 0–2 step 0.01 (0 = trail
218
- from entry) · `trailingGivebackPct` 25–55 · `trailingBufferPct` 0.01–1 · `timeDecay` grace
219
- 1–1440 min ≥ interval 1–480 min, tighten 0.1–50%, max 1–100%, stale threshold 0–100% of TP
220
- progress. Each mechanism has its own enabled flag; there is no umbrella switch. Trend books:
221
- arm break-even ~1R, trail late with a generous giveback (40–55). Mean-reversion/scalp books:
222
- break-even early, tight giveback, and **timeDecay on** — a thesis that hasn't paid within its
223
- horizon should be squeezed out.
224
-
225
- ## Coin selection (per compile, not persisted)
226
-
227
- `{mode:"ranked", limit, category?}` (categories today: ALL, CRYPTO, L1, MEMES, DEFI, TRADFI,
228
- STOCKS, INDICES, COMMODITIES) or `{mode:"explicit", tickers[]}`. Choose the cohort the review
229
- should render over — explicit tickers for a focused edit, ranked for a scanning book.
230
-
231
- ## Market Read markers
232
-
233
- `marketReadText` renders with live values wherever a `{...}` marker names a column header
234
- (`{RVOL}`), a condition (`{SQUEEZE_ON}` — renders outcome plus evidence), or a section-qualified
235
- form on collision (`{custom:<uuid>.MAalign}`). The preview returns `marketReadMarkers` with each
236
- marker's resolution status — fix `unknown`/`ambiguous` markers before compiling.
237
-
238
- ## References
239
-
240
- - `references/playbooks.md` — five validated desk-grade playbooks with full payloads: volatility
241
- compression breakout, crowded-positioning fade, relative-strength rotation with a benchmark
242
- gate, HTF trend pullback, perp/spot flow divergence at structure.
243
- - `references/recipes.md` — copy-adaptable column recipes, condition patterns, weight matrices,
244
- and trade-level/position-management presets per trading persona.
245
- - `references/tradingview-ports.md` — the most popular TradingView community scripts (Squeeze
246
- Momentum [LazyBear], Supertrend/UT Bot, Chandelier Exit, MACD + 200 MA, golden cross, RSI-2,
247
- VWAP reversion, Donchian/Turtle, ICT FVG/order blocks) translated process-for-process onto
248
- the studio's vocabulary, with an expressibility triage and honest named substitutions for
249
- what the grammar cannot carry.
250
-
251
- Validate a draft cheaply before compiling: `derive_strategy_rule_view` (report membership +
252
- rule defaults, no write) and `preview_strategy_report` (rendered tables, condition outcomes
253
- with evidence, verdict tally, budget usage, marker resolution). Then compile once, review the
254
- compiled truth, and apply.