(a) R1-R5 (factor-refinement, grounded in methodology-research.md): - R1 (PEAD): EPS-growth weight raised 1.0->1.5 in build_siamchart_score / symbol_breakdown (Bernard-Thomas 1990, Livnat-Mendenhall 2006) - R2 (momentum): 12-1 momentum factor from Yahoo price snapshot (Jegadeesh-Titman 93; lite weight 0.5) - R3 (regime): binary bear gate -> continuous stress = negative-themes fraction, smooth LONG/SHORT shift - R5 (dividend screen): non-dividend / cut-yield names no longer go LONG (screen-off) - R4 (earnings-revision) deferred: no free EPS-forecast source yet (documented) (b) bank-sector NPL collector (BOT reportID 794, financial&insurance sector): - refactored auto_npl to expose shared _parse_sector; new bank_npl.py reuses it - registered bank_npl FACTOR -> auto-appears in sources table (6 rows) + blends into banks theme surprise (real NPL) - +unit tests (test_bank_npl), test_dashboard updated (6 sources) 205 tests pass; verified live API (banks surprise incl. NPL 1.07, 6 sources).
44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
"""Tests for the BOT bank-sector (financial) NPL collector."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import unittest
|
|
|
|
from app.bank_npl import BANK_SECTOR_LABEL, parse_bank_npl_html
|
|
|
|
# Minimal server-rendered table fragment in the style of reportID=794.
|
|
_NPL_HTML = """
|
|
<table>
|
|
<tr><th>ยอดคงค้าง NPL</th><th>% ต่อ NPLs</th><th>% ต่อสินเชื่อรวม</th></tr>
|
|
<tr><td></td><td>Q2/2568</td><td></td></tr>
|
|
<tr><td>1</td><td>การผลิต</td><td>12345.0</td><td>4.10</td><td>0.30</td></tr>
|
|
<tr><td>2</td><td>กิจกรรมทางการเงินและการประกันภัย</td><td>5598.0</td><td>1.07</td><td>0.11</td></tr>
|
|
<tr><td>3</td><td>รถยนต์</td><td>20602.0</td><td>3.95</td><td>1.20</td></tr>
|
|
</table>
|
|
"""
|
|
|
|
|
|
class BankNplTest(unittest.TestCase):
|
|
def test_parses_financial_sector(self):
|
|
snap = parse_bank_npl_html(_NPL_HTML)
|
|
self.assertEqual(snap.npl_amount, 5598.0)
|
|
self.assertEqual(snap.pct_of_npls, 1.07)
|
|
self.assertEqual(snap.pct_of_loans, 0.11)
|
|
self.assertEqual(snap.period, "Q2/2568")
|
|
|
|
def test_label_matched(self):
|
|
self.assertIn("การเงิน", BANK_SECTOR_LABEL)
|
|
self.assertIn("ประกันภัย", BANK_SECTOR_LABEL)
|
|
|
|
def test_fetches_live(self):
|
|
# Live BOT page must still yield a financial-sector NPL (network).
|
|
from app.bank_npl import fetch_bank_npl
|
|
snap = fetch_bank_npl()
|
|
self.assertIsNotNone(snap.pct_of_npls)
|
|
if snap.pct_of_npls is not None:
|
|
self.assertGreater(snap.pct_of_npls, 0.0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|