From 6c3a84b8ec16a34a03faad7ea0fb96b7f3721c64 Mon Sep 17 00:00:00 2001 From: gahusb Date: Wed, 13 May 2026 23:41:01 +0900 Subject: [PATCH] feat(screener): ScreenContext.news_sentiment field + load query --- stock-lab/app/screener/engine.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stock-lab/app/screener/engine.py b/stock-lab/app/screener/engine.py index 0f3b373..d6b9120 100644 --- a/stock-lab/app/screener/engine.py +++ b/stock-lab/app/screener/engine.py @@ -17,6 +17,7 @@ class ScreenContext: flow: pd.DataFrame # cols: ticker,date,foreign_net,institution_net kospi: pd.Series # index=date(str), name="kospi" asof: dt.date + news_sentiment: "pd.DataFrame | None" = None @classmethod def load(cls, conn: sqlite3.Connection, asof: dt.date, @@ -38,6 +39,10 @@ class ScreenContext: "FROM krx_flow WHERE date BETWEEN ? AND ? ORDER BY date", conn, params=(cutoff, asof_iso), ) + news_sentiment = pd.read_sql_query( + "SELECT ticker, score_raw, news_count FROM news_sentiment WHERE date = ?", + conn, params=(asof_iso,), + ) # KOSPI 지수: MVP에서는 005930(삼성전자) 종가를 시장 대용으로 사용. # 후속 슬라이스에서 ^KS11 별도 캐시. @@ -47,7 +52,8 @@ class ScreenContext: kospi = sub.copy() kospi.name = "kospi" - return cls(master=master, prices=prices, flow=flow, kospi=kospi, asof=asof) + return cls(master=master, prices=prices, flow=flow, kospi=kospi, asof=asof, + news_sentiment=news_sentiment) def restrict(self, tickers) -> "ScreenContext": tickers = pd.Index(tickers)