Files
set50-system/docs/engineering-log/2026-08-25-multitheme-and-simulation.md
2026-08-25 20:41:24 +07:00

4.2 KiB
Raw Permalink Blame History

2026-08-25 — Multi-theme platform + Capital simulation

Scope

Took the single-theme tourism demo and built a full multi-theme SET50 research platform with capital-allocation simulation, all in Thai UI, on real Thai data.

Milestones (all verified + pushed)

# Commit Milestone Status Last verified
1 f6dd630 Auto Credit (TradingEconomics) + EIA collectors complete live fetch
2 2fa8055,fdfd832 BOT regional consumption (north; NE = 0.0 placeholder disabled) complete live (idx 100.3)
3 674dcfd Scope: national-only Thai factors; cancel DLT province scraping complete docs
4 3f7fccd Thai Energy (TOP) collector replacing EIA US proxy complete live (Q2/2026 net 19,481)
5 affc29a theme registry + scoring engine (60 theme / 40 Siamchart) complete tests
6 63058ec daily cache (fetch-once/day, stale fallback, atomic) complete tests
7 7643764 GET /api/v1/themes combined board (3 themes + frequency) complete live HTTP 200
8 90e63e3 frontend Thai theme panel (3 cards + signals) complete browser
9 2caf814 Localize dashboard to Thai; fix fixture-badge honesty complete browser
10 c3a1461 capital allocation engine + MT5 bridge complete tests + live
11 aae1d13 Fix bucket3 rank by dividend yield (ignore score) complete review passed
12 e24023c Thai Simulation UI; remove legacy Paper ledger section complete browser

Key decisions

  • Factors must be Thailand-specific (auto = Thai car sales, energy = TOP Thai refinery, NOT US EIA/Gulf crack spread).
  • Regional = national ภาพรวมไทย only — no province/region-level scraping.
  • Frequency matters: tourism/auto = monthly, energy = quarterly, Siamchart = annual. Don't mix different-cadence factors as same-timestamp.
  • Simulation buckets (user-confirmed): b1 50% score+dividend · b2 20% score no dividend · b3 30% highest dividend yield (ignore score, exclude b1) · min 100 shares · cash fallback.
  • Paper ledger replaced by simulation (backtest + forward test share one engine; forward may optionally dispatch MT5, live gated).

Verified (evidence)

  • Full backend suite: 185 tests OK
  • Live HTTP: /api/v1/themes 200 (3 Thai themes), /api/v1/simulation 200 (1,000,000 → buckets; b1 AOT/MINT/AWC, b3 CRC after yield fix)
  • Independent reviews: deleg_1682c760 (found bucket3-by-score blocker) → fixed → deleg_43b165e0 passed=true (no security/logic errors)
  • git diff --check clean, static secret scan clean, compileall ok

Risks / remaining work

  • Price universe = 8 symbols (Yahoo snapshot); full SET50 needs extending the price collector.
  • bot_regional only north enabled (NE=955 is a 0.0 BE-2570 placeholder).
  • BOT portal API (portal.api.bot.or.th) requires auth — JSON alternative future.
  • MT5 live dispatch is interface-only (dry-run); needs MT5_SEND_ORDERS=1 + config.
  • M2.9 legacy work (prices.py, research.py, event_study.py, vintages.py, etc.) is still uncommitted/dirty — separate, unrelated to this session, untouched.

Next action

Extend price-history collection to the full SET50 universe so simulation can allocate across all names (currently limited to the 8 symbols that have Yahoo history in backend/data/prices/snapshots/).

Dashboard rebuild (real multi-theme) — user 10-point review

Commits 166a885, 9739849, 489920b, 0f706e2 (pushed).

  • macro_thai.py: BOT Thai Economy (consumption +4.9%, investment +18.1%, inflation 1.95%, unemployment 0.93%, tourists 16.2mn)
  • dashboard.py + /api/v1/dashboard: real 3-theme surprise (tourism 0.57, auto 0.81, energy 1.62σ) + macro + sources table + 49-symbol combined board; NO fixture fallback (user decision)
  • Frontend: removed KPI cards (Theme surprise/Paper/คุณภาพข้อมูล/backtest gate); signal count long/short/neutral; merged table + combined col; sources lineage table; per-theme thesis; macro panel; Thai-only (freq รายเดือน/รายไตรมาส)
  • Verified: full suite 195 OK, live /api/v1/dashboard 200, browser DOM 8 checks pass, Thai-only scan clean