feat(suggestion): 'ทำกำไร' = price-trend momentum (3/6/12m) gated on positive theme signal

Owner rule: a stock that should be bought for profit is one whose PRICE is
likely to rise in the next 3-6 months — not one with high EPS growth (BTS had
EPS +137% yet flat/falling price). The old selection ranked buckets 1/2 by
 (60/40 theme+siamchart where siamchart was EPS-growth dominated).

- themes.price_trend_score(): blend of ~3/6/12-month price momentum, z-scored
  across the universe (heavier 3/6m weight per the 3-6 month tenure).
- allocate_capital: buckets 1/2 rank by momentum, gated on theme_signal > 0
  (mean surprise across the symbol's themes). theme_signal=None (backtest path)
  is not gated so PIT backtest still allocates. Bucket 3 unchanged (yield top).
- suggestion endpoint passes real momentum + theme_signal from the live board.
- Verified: bucket 1 now picks CRC/BEM (dividend + rising price); falling-price
  PTT/MINT go to bucket 3 by yield, not bucket 1. Full suite 372 green (3 new
  momentum/theme-gate tests).
This commit is contained in:
Kunthawat Greethong
2026-08-31 10:05:00 +07:00
parent be6a92540c
commit 576d9e31ec
5 changed files with 155 additions and 9 deletions

View File

@@ -109,3 +109,23 @@ Implemented (commit 2026-08-30):
(final_equity 1,117,243.95 on 1M), no 400 from missing factors.
- Tests: test_backtest_readiness updated to earliest-runnable semantics; full
suite 369 green.
## Capital-allocation selection rework (owner rule — 2026-08-31)
Owner clarified what the 3 buckets mean and flagged that the old selection
(rank by `combined` = 60/40 theme+siamchart where siamchart was EPS-growth
dominated) picked names like BTS whose EPS was up 137% but whose PRICE was flat/
falling — NOT the owner's "ทำกำไร" (price likely to rise in 3-6 months).
New definition implemented:
- "ทำกำไร" is now measured by a **price-trend (momentum) score**, not EPS growth.
Added `themes.price_trend_score()` blending ~3/6/12-month momentum (trading
days), z-scored across the universe (heavy weight on 3/6m per the 3-6 month
tenure).
- Buckets 1 & 2 rank by momentum, **gated on `theme_signal > 0`** (mean surprise
of the symbol's themes). theme_signal=None (backtest path) is not gated, so
the PIT backtest still allocates.
- Bucket 3 unchanged: highest dividend yield, ignores score/momentum.
- Suggestion endpoint passes real momentum + theme_signal from the live board.
- Verified: suggestion now picks CRC+BEM (dividend, rising price) in bucket 1;
PTT/MINT (falling price, theme positive) slide to bucket 3 by yield, not
bucket 1. Full suite 372 green (3 new momentum/gate tests).