refactor(stock): Phase 1 리뷰 반영 (public get_krx_tickers·타입·limit명명·테스트)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-31 21:45:19 +09:00
parent 0ef7d414b7
commit 62169ad33f
4 changed files with 76 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import os, tempfile, importlib
import os, tempfile
def _fresh_db(monkeypatch):
tmp = tempfile.mkdtemp()
@@ -20,5 +20,18 @@ def test_holdings_signals_table_and_upsert(monkeypatch):
assert len(rows) == 1 # upsert 멱등
assert rows[0]["action"] == "trim"
assert rows[0]["exit_flags"]["ma50_break"] is True # JSON 역직렬화
hist = db.get_holdings_signal_history("005930", days=30)
hist = db.get_holdings_signal_history("005930", limit=30)
assert len(hist) == 1
def test_get_latest_holdings_date(monkeypatch):
db = _fresh_db(monkeypatch)
# empty table → None
assert db.get_latest_holdings_date() is None
# after an upsert → returns that date
db.upsert_holdings_signal(
date="2026-05-30", ticker="005930", name="삼성전자",
action="hold", tech_score=70.0, exit_flags={}, issues=[],
close=80000, pnl_rate=4.0, reasons="테스트",
)
assert db.get_latest_holdings_date() == "2026-05-30"