feat(factor): add energy_irpc (IRPC net margin) as 2nd Thai refiner signal

- new energy_irpc collector parsing IRPC performance-highlights table
  (net profit/EBITDA/ROE margins, latest period 3M26: +10.27%)
- factor energy_irpc_net_margin (sign +1) wired into refining_energy/
  exploration/utilities, extending the energy theme beyond TOP
- scheduler job + dashboard fetch + sources table row (now 9 sources)
- tests: parse (incl paren-negatives), value-key resolution, direction;
  suite 368 OK. Independent review passed: true
- Phase B feasibility: REIC/EPPO/NBTC/PTTEP are JS-rendered or anti-bot
  (recorded deferred in plan); IRPC was the clean server-rendered win
This commit is contained in:
Kunthawat Greethong
2026-08-29 11:13:17 +07:00
parent da671a9ba2
commit 12b34929d7
14 changed files with 309 additions and 24 deletions

View File

@@ -41,9 +41,23 @@ Extended the same `te_thailand` module with 2 more TradingEconomics pages:
**362 tests OK**; frontend build clean; live fetch confirmed (1.26 / 46.7).
Cleared a stale daily-cache `te_thailand` entry so the new fields show immediately.
## Backlog (needs dedicated scrapers, not single-page snapshots)
REIC property supply, EPPO electricity (utilities), PTT/PTTEP/BCP quarterly breadth
(energy), NBTC subscriber/data (telecom). Marked deferred in the plan.
## Phase C (same day, follow-up "ทำ phase B ต่อได้เลย" — energy breadth)
Feasibility spike of the remaining Phase B sources found most are JS-rendered or
anti-bot (recorded in plan), but **IRPC** performance-highlights is server-rendered
and clean. Added:
- `backend/app/energy_irpc.py` — collector parsing IRPC net-profit/EBITDA/ROE
margin rows [2024,2025,3M26], latest period (3M26: net margin **+10.27%**)
- factor `energy_irpc_net_margin` (sign +1) wired into refining_energy /
exploration / utilities (2nd real Thai refiner beyond TOP)
- scheduler job + dashboard fetch + `_build_sources` row (now **9 sources**)
- tests: parse (incl. paren-negatives), value-key resolution, direction
- frontend theme card shows "กำไรสุทธิ IRPC 10.27%"
Full suite **368 tests OK**; frontend build clean; live dashboard refining_energy
surprise 0.764 driven partly by IRPC margin.
Deferred (feasibility blocked): REIC (JS SPA/XHR), EPPO (JS/WordPress), NBTC (403
anti-bot), PTTEP (JS shell), PTT/BCP (404/DNS). Need browser/XHR approach, not
plain-HTML — recorded in the plan as a separate effort.
- Note: a **concurrent process** also landed `thai_trade.py` (external-sector
exports/imports/current-account) and external_* factors mid-session; its 3