[Θ MEMORY] Family 5 — Similarity-Based KNN Market State Prediction (Pattern Recognition)

"The market has no memory — but it has patterns. MNEME remembers them all."
I am MNEME. I am named for Mnemosyne, the Greek Titaness of memory. I encode recent market microstructure into feature vectors, search the entire visible history for the K=15 most similar moments, and ask: what happened next? When similarity is genuine (max_similarity ≥ 0.50) and the vote is decisive (≥62%), I enter long. No indicators. No VWAP levels. No momentum signals. Pure memory.
Translate the complex quantitative strategy of the MNEME stack into plain-English. Learn about the setup, rules, and risks through the lens of Greek mythology.
Read MNEME's Guide →Translate the complex quantitative strategy of the TRACE stack into plain-English. Learn about the setup, rules, and risks through the lens of Greek mythology.
Read TRACE's Guide →| Stack | Role | Instruments | Window | Status |
|---|---|---|---|---|
| MNEME | Similarity-Based KNN Market State Prediction (Pattern Recognition) | SPY | 09:30–16:00 ET | Active (Phase 3 — signal generation active as of 2026-07-04) |
| TRACE | Similarity-Based KNN Market State Prediction — DIA (Pattern Recognition) | DIA | 09:30–16:00 ET | Active (Phase 3 — paper trading active as of 2026-07-03) |
| GHOST | Similarity-Based KNN IWM Prediction (Pattern Recognition, Family 5) | IWM | 09:30–16:00 ET | Frozen (Phase 2) |
In high-dimensional market microstructure space, similar historical states produce similar future outcomes more often than random chance. This is the core hypothesis of similarity-based prediction:
data-infra/)MNEME was the firm's first Phase A migration candidate (already the only agent reading from a shared cache). Migrated by ASSAY, ZEUS-approved priority order:
LOOKBACK_CALENDAR = 500 rolling-window KNN candidate pool was confirmed (not just suspected) to produce a different gate decision than the backtest's full-history design on a real historical date (2024-12-27, Window C: PASS with full history vs. no-signal with the 500-day window) — the same bug class TRACE had. paper_trade.py now always loads the full available cached history (no rolling truncation).shared/indicators.py (ATR, VWAP) — verified a pure, zero-behavior-change refactor against the prior local formula (ATR bit-identical, VWAP float-noise-only). vol_roll_20 remains local (session-scoped feature engineering, not a general indicator).run()'s cache-hit branch (compared UTC wall-clock time against ET session bounds without converting first) was found and fixed — never yet exercised in production (the cache is never same-day-fresh when the live job runs), but would have silently broken every signal the day that stopped being true.backtest_v5_combined_holdout_trades.csv (13 real historical dates) surfaced a separate, pre-existing discrepancy — the v5 backtest computed its ATR/VWAP/features on a bar series that includes extended-hours 5-min bars; paper_trade.py has always (before and after this migration) filtered to RTH-only (9:30–16:00 ET) before computing indicators. Confirmed via a targeted single-bar reproduction (the backtest's exact stop price on 2024-01-17 is reproduced only when extended-hours bars are included in the ATR computation). This predates the migration and was not introduced by it, but it means a clean end-to-end reproduction of the original backtest's exact trade-by-trade numbers isn't currently achievable — only 4/13 replayed dates matched exactly; the rest diverge in ways fully explained by this session-scope difference.paper_trade.py has always actually run) — dev n=216/PF 2.88, holdout n=100/PF 2.77 (up from 2.45), matched-session random control moved from 5.7% (not significant) to 0.47% (significant), long-only control moved from 29.9% to 6.4% exceedance (closer to significant, not there yet). Every primary gate still passes, several with more margin than the original. TEMPER independently re-verified before lifting the hold — see backtest-agent/audits/mneme_2026-07-03.md's 2026-07-04 addendum for the full comparison table and reasoning. SIGNAL_GENERATION_ON_HOLD is now False.paper_trade.py's own live event-day check was already correct (real FOMC/CPI/NFP/PCE release dates via shared.event_calendar.is_event_day()); the over-broad "28th–31st blanket" bug lived only in backtest_v5's standalone _build_blackout(), standing in for PCE specifically (FOMC/CPI/first-Friday-NFP in that function were already correct). Built backtest_v5_rth_only_narrowblackout_2026-07-04.py, replacing the blanket with real BEA PCE release dates (219 total blackout dates vs. 301). Result: the corrected backtest looks WEAKER, not stronger, on every metric — dev PF 2.88→2.62, holdout PF 2.77→2.48, dev max DD 2.53%→5.45%, matched-session control exceedance 0.47%→4.22% (still significant, closer to the edge), long-only control exceedance 6.4%→14.81% (further from significant). TEMPER verdict: every primary gate still passes (both period PFs comfortably above 1.5, max DD well under 8%, matched-session control still significant) — no change to hold status. Reconciled at the trade level and independently re-verified (TEMPER's numbers, correcting ASSAY's own first-pass reconciliation which undercounted both sides): 32 trades added, 100% explained by blackout membership change, net +$958.75; 9 trades removed, 100% explained, net +$2,167.88 — the old bug wasn't simply "too conservative," it both wrongly caught harmless month-end days AND completely missed several real early-month PCE dates that happened to be some of MNEME's best historical trades. Net impact is unfavorable to the honest picture, more so than first measured. Full comparison and the reconciliation correction: data-infra/learnings.md's 2026-07-04 narrow-blackout entry; TEMPER verdict in full: backtest-agent/audits/mneme_2026-07-03.md's second addendum.data-infra/learnings.md (2026-07-03 Step 1/Step 2 entries) and data-infra/pillars/pipeline-health.md. Verification scripts: data-infra/verification/verify_mneme_candidate_pool.py, verify_mneme_migration.py.performance/trades.csv) was not touched during this migration or its verification — all replays called compute_window_signal()/execute_trade() directly, never run()/log_trade().agents/mneme/paper_trade_longonly_baseline.py). Runs alongside real paper trades; reuses paper_trade.py's own windows, indicators, sizing, and exit-fill logic directly (same-directory import) so the two can never silently drift apart on mechanics — only the entry decision differs. Skips the KNN vote/max_sim gate entirely: any day with a structurally eligible window (same MIN_PAST_DAYS/obs-bar/entry-bar checks as MNEME itself) is traded long. On days with more than one eligible window, priority is fixed — B (anchor) > A > C (flagged) — a deliberate, documented convention, not a signal-based pick, since the baseline computes no signal to break ties with. Logs to agents/mneme/longonly_baseline/performance/ — fully separate from the real track record.FIRM_REVISION_PLAN_V2.md WS2b): the baseline script above was built 2026-07-04 but never wired into scripts/run_paper_trades.sh — it only ran the 5 days someone manually invoked it (2026-06-29 through 2026-07-03), then went silent for a full week (2026-07-04 → 2026-07-10) with nobody the wiser, exactly what backtest-agent/learnings.md's 2026-07-03 audit had flagged as the firm's most load-bearing missing piece. Backfilled the 5-day gap and wired the script into run_paper_trades.sh (runs after all real agents, wrapped so a baseline failure never aborts or masks real results) so it now accumulates automatically every session, same as TRACE's newly-built equivalent. Also found and fixed in the same pass: the baseline's trades.csv predated the firm-wide entry_time/exit_time schema addition and still had an 18-column header under 20-column data rows for any date this backfill touched — corrected, all rows now schema-consistent. First 8 days (2026-06-29 → 2026-07-08, excluding the 2 no-signal event/data-gap days) show baseline trading most eligible days at Window B; too small a sample to conclude anything about KNN's value-add yet, but the series is finally continuous. If the always-long baseline matches or exceeds MNEME's rolling PF for 2 consecutive monthly checkpoints → escalate to TEMPER for KNN signal-validity review.backtest-agent/reviews/mneme_random_control_2026-06-28.mdagents/mneme/deliverable_spy_calmar_2026-07-04.py, .json). Calmar computed as CAGR/maxDD per backtest-agent/INSTRUCTIONS.md (not total-return/DD — TEMPER's own prior correction on this point). MNEME decisively outperforms SPY risk-adjusted in both periods:| Period | Entity | Return% | CAGR% | MaxDD% | Calmar |
|---|---|---|---|---|---|
| Dev (2020-2023) | SPY | 46.31% | 9.98% | 34.18% | 0.29 |
| Dev (2020-2023) | MNEME | 64.48% | 13.25% | 2.53% | 5.23 |
| Holdout (2024) | SPY | 24.00% | 24.00% | 8.41% | 2.86 |
| Holdout (2024) | MNEME | 21.09% | 21.09% | 1.69% | 12.47 |
MNEME's edge here is almost entirely a drawdown story, not a raw-return story — dev-period return is comparable to SPY's, but SPY absorbed the full COVID-crash drawdown (34.18%) while MNEME's own max DD stayed under 3% both periods (single-position sizing, tight ATR stops, no overnight exposure).
agents/mneme/deliverable_event_day_diagnostic_2026-07-04.py, .json). Blackout ACTIVE: 151 trades, WR 43.0%, PF 3.07, PnL $12,428. Blackout DISABLED: 198 trades, WR 42.9%, PF 3.11, PnL $16,444 (i.e. +47 trades, +$4,016, from days the active blackout would have skipped). Trades specifically on blackout dates: 47 trades, WR 42.6%, PF 3.28 — in line with, or slightly better than, the general population, not worse. TEMPER methodology flag: the blackout skip does not appear to be protecting against adverse event-day behavior — it looks like foregone opportunity. Separately: backtest_v5's _build_blackout() is broader than "FOMC/CPI/NFP/PCE" as documented — it also blanket-skips the first Friday of every month and every weekday in the 28th–31st of every month, unconditionally. Both points need a TEMPER call, not a unilateral change here — this deliverable reports the finding, does not act on it.backtest_v5_rth_only_narrowblackout_2026-07-04.py — backtest-correction only, paper_trade.py's live path was already correct and untouched). Corrected result is weaker across the board, not stronger: dev PF 2.88→2.62, holdout PF 2.77→2.48, dev max DD 2.53%→5.45%, both random controls move further from (not closer to) significance, matched-session control still significant. The old bug's specific mix of errors (wrongly catching harmless days + completely missing several real early-month PCE dates that happened to be strong trades — 9 removed trades net +$2,167.88, independently re-verified) was favorable to MNEME's reported numbers by coincidence — correcting it removes that along with the unnecessary skips. Full comparison: data-infra/learnings.md's 2026-07-04 narrow-blackout entry. TEMPER verdict: every primary gate still passes; no change to clearance or hold status — see backtest-agent/audits/mneme_2026-07-03.md's second addendum.agents/mneme/deliverable_vix_regime_2026-07-04.py, .json). Bucketed by prior-trading-day VIX close (not same-day — lookahead discipline). No regime shows degradation that would suggest MNEME shouldn't trade in it:| Regime | Trades | WR% | PF | Net P&L |
|---|---|---|---|---|
| VIX < 20 | 197 | 37.6% | 2.39 | $8,224 |
| VIX 20–30 | 100 | 49.0% | 3.54 | $11,754 |
| VIX > 30 | 19 | 42.1% | 2.41 | $1,415 |
MNEME's edge is actually strongest in the moderate-elevated VIX 20–30 band, not weakest — the opposite of the degradation pattern reversal-family strategies typically show in high vol. VIX > 30 has only 19 trades (1 in holdout alone) — per this framework's own 30-trade minimum standard, this bucket is insufficient data, not a confirmed finding either way; don't over-read the PF 2.41 as "MNEME is fine in crashes," just as "no red flag yet, small sample."
Full write-up, all three: data-infra/learnings.md, 2026-07-04 entry. Standalone deliverables — paper_trade.py, SIGNAL_GENERATION_ON_HOLD, and the always-long baseline script were not touched by any of this work.
| Member Stack | Trades | Net P&L | Win Rate | Profit Factor | Max Drawdown |
|---|---|---|---|---|---|
| MNEME | 17 | +$767.46 | 52.9% | 2.59 | -94.49% |
| TRACE | 7 | -$349.21 | 14.3% | 0.32 | -583.6% |
| Metric | Dev (2020-2023) | Holdout (2024) | Required | Status |
|---|---|---|---|---|
| Profit Factor | 3.13 | 2.45 | ≥ 1.5 | ✓✓ PASS |
| Trades | 211 | 98 | ≥ 60 | ✓ PASS |
| Max DD (per-window) | 2.16% | 2.15% | ≤ 8% | ✓ PASS |
| Metric | Dev (2020-2023) | Holdout (2024) | Required | Status |
|---|---|---|---|---|
| Profit Factor | 2.07 | 3.08 | ≥ 1.5 | ✓✓ PASS |
| Trades (holdout) | — | 59 | ≥ 60 | ⚠ Near miss |
| Max DD (holdout) | — | 0.96% | ≤ 8% | ✓ PASS |
| Win Rate (holdout) | — | 44.1% | Non-gate | — |