- SimpleORBNT8.cs: append Avwap, AvwapSlope, and TrendConfirm to STATE_CONTEXT when CustomData contains them - SimpleORBNT8DefaultsTests.cs: add source assertions for AVWAP telemetry formatting, missing-key omission, and no scoring/log-format changes - SPRINT_BOARD.md/decisions.md: record observability-only implementation and direction-blind trend_confirm finding Build: clean | Tests: 561 passing; Core 472 passing | Dual-deployed: no - skipped by prompt
137 lines
7.1 KiB
Markdown
137 lines
7.1 KiB
Markdown
# TASK: GAP-061 — expose raw AVWAP/slope/trend-confirm inputs in STATE_CONTEXT telemetry
|
|
# Staged: 2026-08-25 (trade-frequency investigation, DEC-20260825-04)
|
|
# Sprint: Stage 1 — observability only, zero trading-behaviour risk
|
|
# Owner: Kilocode
|
|
# Deploy: COMMIT ONLY — do NOT run deploy-to-nt8.bat or copy build output to
|
|
# the live NT8 install as part of this task. Verify-build and commit
|
|
# as usual; leave the deploy step for the operator to run manually
|
|
# once ready.
|
|
# ─────────────────────────────────────────────────────────────────
|
|
|
|
## THE DEFECT (why this is worth doing)
|
|
|
|
Investigating "zero trades this week" (`DEC-20260825-04`) found that every
|
|
real, pullback-confirmed breakout this week and on 2026-08-18 (the only two
|
|
days with usable `STATE:` telemetry) capped out at Grade B or C — never A.
|
|
On both days, the common driver was `Trend=0.30` on the best real setups,
|
|
both `Direction=Sell`.
|
|
|
|
Reading `TrendAlignmentFactorCalculator.Calculate()`
|
|
(`src/NT8.Core/Intelligence/FactorCalculators.cs` ~116-186), the Trend
|
|
factor is additive: `+0.4` if price is on the trade's side of AVWAP, `+0.3`
|
|
if AVWAP slope agrees with direction, `+0.3` if `trend_confirm > 0.5`.
|
|
|
|
**Found something sharper than a hypothesis while tracing this — a
|
|
provable, direction-blind asymmetry, not something that needs new
|
|
instrumentation to confirm:** `trend_confirm` is set in
|
|
`SimpleORBStrategy.UpdateConfluenceInputs()`
|
|
(`src/NT8.Strategies/Examples/SimpleORBStrategy.cs:970`) as
|
|
`context.CustomData["trend_confirm"] = avwapSlope > 0.0 ? 1.0 : 0.0;` —
|
|
unconditionally rewarding a **positive** slope, regardless of trade
|
|
direction. For a Sell/short trade, `slopeAligned` (the `+0.3` above)
|
|
requires `avwapSlope < 0.0`. These two conditions are mutually exclusive by
|
|
construction: **a short trade can never earn both the `+0.3` slope-aligned
|
|
bonus and the `+0.3` trend-confirm bonus, even when the trend is cleanly
|
|
and correctly bearish.** The maximum a short trade with a genuinely
|
|
confirmed downtrend can score on this factor is `0.3` (or `0.7` if price
|
|
also happens to be below AVWAP) — never higher. This matches both real
|
|
days' data exactly: `Trend=0.30` on every best short setup.
|
|
|
|
This task is scoped to **observability only** — do not change
|
|
`trend_confirm`'s calculation or the Trend factor's logic here. The
|
|
purpose is to make the `avwap`/`avwap_slope`/`trend_confirm` raw values
|
|
visible in the log directly (same value class as GAP-059's
|
|
`orb_range_ticks` fix), so the price-vs-AVWAP question (the one part of
|
|
this that genuinely isn't provable from source alone — whether an ORB
|
|
breakout's early timing structurally prevents earning the `+0.4`
|
|
price-aligned bonus) can be checked against real numbers instead of
|
|
inferred, and so the `trend_confirm` asymmetry above is independently
|
|
visible in the log evidence too, not just in source. Whether to fix
|
|
`trend_confirm`'s direction-blindness is a separate decision — flag it in
|
|
your writeback but do not implement a fix in this task.
|
|
|
|
## READ-FIRST
|
|
|
|
1. `DEC-20260825-04` in `docs/00-governance/decisions.md` — the full
|
|
investigation this task follows from.
|
|
2. `src/NT8.Core/Intelligence/FactorCalculators.cs` ~116-186 —
|
|
`TrendAlignmentFactorCalculator`, confirm the additive logic described
|
|
above is still accurate.
|
|
3. `src/NT8.Strategies/Examples/SimpleORBStrategy.cs` ~926-975 —
|
|
`UpdateConfluenceInputs()`, where `avwap`/`avwap_slope`/`trend_confirm`
|
|
are computed and written to `context.CustomData` every bar.
|
|
4. `src/NT8.Adapters/Strategies/SimpleORBNT8.cs` ~356-370 —
|
|
`GetStateTelemetryContextFields()` override, where `STATE_CONTEXT`
|
|
fields are currently assembled (`OrbHigh`/`OrbLow`/`OrbWindowStart`/
|
|
`OrbWindowEnd`/`OrbReady`). This is where the new fields belong — same
|
|
pattern, same method.
|
|
5. `src/NT8.Adapters/Strategies/NT8StrategyBase.cs` ~1038-1100
|
|
(`MaybeWriteStateTelemetry`) and ~1130 (the virtual base method) for
|
|
how `GetStateTelemetryContextFields`'s return value flows into the
|
|
`STATE_CONTEXT:` log line — read-only context, no changes needed here.
|
|
|
|
## THE CHANGE
|
|
|
|
In `SimpleORBNT8.GetStateTelemetryContextFields()`, add three fields read
|
|
from `context.CustomData` (same defensive pattern already used elsewhere
|
|
in this codebase for optional `CustomData` keys — null/missing-key safe,
|
|
never throws):
|
|
|
|
- `Avwap` — the raw `avwap` value (`F2`), if present.
|
|
- `AvwapSlope` — the raw `avwap_slope` value (`F4` — this is a small
|
|
number, don't round it away), if present.
|
|
- `TrendConfirm` — the raw `trend_confirm` value (`F1` is fine, it's
|
|
currently always `0.0` or `1.0`), if present.
|
|
|
|
Omit a field entirely (don't print a placeholder) when its key isn't in
|
|
`context.CustomData` yet, consistent with how `OrbHigh`/etc. are only
|
|
added once `OpeningRangeReady`. Do not change `UpdateConfluenceInputs()`,
|
|
`TrendAlignmentFactorCalculator`, or any other scoring logic — this task
|
|
only surfaces existing values that are already being computed every bar,
|
|
it does not compute anything new.
|
|
|
|
## DO NOT
|
|
|
|
- Do not change `trend_confirm`'s calculation, the Trend factor's
|
|
additive logic, or any other confluence-scoring code. That is a
|
|
separate decision (see THE DEFECT) and explicitly out of scope here.
|
|
- Do not change `MinTradeGrade`, `GradeFilter`, or any risk/order-flow
|
|
code.
|
|
- Do not change the `STATE:` or `STATE_DETAIL:` line formats — only
|
|
`STATE_CONTEXT:`.
|
|
|
|
## TESTS (required)
|
|
|
|
1. A test proving `GetStateTelemetryContextFields()` includes `Avwap`/
|
|
`AvwapSlope`/`TrendConfirm` when `context.CustomData` has those keys,
|
|
with correct formatting.
|
|
2. A test proving the method still returns `null` (or omits the new
|
|
fields) when `context.CustomData` lacks them, matching the existing
|
|
`OpeningRangeReady` guard behavior — no exceptions, no placeholder
|
|
values.
|
|
3. Confirm the full existing suite still passes, including whatever
|
|
covers `STATE_CONTEXT` formatting today (`SimpleORBNT8DefaultsTests.cs`/
|
|
`NT8StrategyBaseRejectSummaryTests.cs`-style source-text or execution
|
|
tests, whichever pattern already applies to this method).
|
|
|
|
## VALIDATION (operator)
|
|
|
|
None required for correctness — additive telemetry field only, no
|
|
existing log line format changed, no order-flow/sizing/risk behavior
|
|
touched. Once deployed, the next real short-side breakout will show
|
|
`AvwapSlope` directly in `STATE_CONTEXT`, confirming (or refuting) whether
|
|
it was genuinely negative (bearish, i.e., `trend_confirm`'s asymmetry
|
|
really is capping the score) on the setups this investigation looked at.
|
|
|
|
## GOVERNANCE
|
|
|
|
Track as [GAP-061] in SPRINT_BOARD.md. Update
|
|
`docs/00-governance/decisions.md`'s `DEC-20260825-04` entry to note
|
|
GAP-061 implemented. In your writeback, explicitly restate the
|
|
`trend_confirm` direction-blindness finding from THE DEFECT above (confirm
|
|
or correct it if a closer read changes the picture) so the operator has
|
|
a clean, source-verified basis for deciding whether to fix it as a
|
|
follow-up GAP.
|
|
Reference: this task, `DEC-20260825-04`, `TASK_GAP059_ORB_RANGE_TELEMETRY_PROMPT.md`
|
|
(same observability-only precedent).
|