refactor: rename stock-lab → stock (graduation)
- git mv stock-lab/ → stock/ - docker-compose.yml: 서비스 키 + container_name + build.context + frontend.depends_on + agent-office STOCK_LAB_URL → STOCK_URL - agent-office/app: config.py, service_proxy.py, agents/stock.py, tests/ STOCK_LAB_URL → STOCK_URL - nginx/default.conf: proxy_pass http://stock-lab → http://stock (3 lines) - CLAUDE.md / README.md / STATUS.md / scripts/ 문구 갱신 - stock/ 내부 자기 참조 갱신 lab 네이밍 정책 (feedback_lab_naming.md) graduation. API URL / Python import / DB 파일명 변경 없음.
This commit is contained in:
61
stock/app/test_screener_context.py
Normal file
61
stock/app/test_screener_context.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import datetime as dt
|
||||
import sqlite3
|
||||
|
||||
import pandas as pd
|
||||
import pytest
|
||||
|
||||
from app.screener.engine import ScreenContext
|
||||
from app.screener.schema import ensure_screener_schema
|
||||
from app.screener._test_fixtures import make_master, make_prices, make_flow
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def conn(tmp_path):
|
||||
db_path = tmp_path / "ctx.db"
|
||||
c = sqlite3.connect(db_path)
|
||||
ensure_screener_schema(c)
|
||||
yield c
|
||||
c.close()
|
||||
|
||||
|
||||
def _seed(conn, master_df, prices_df, flow_df):
|
||||
now = dt.datetime.utcnow().isoformat()
|
||||
for t, row in master_df.iterrows():
|
||||
conn.execute("""INSERT INTO krx_master (ticker,name,market,market_cap,
|
||||
is_managed,is_preferred,is_spac,listed_date,updated_at)
|
||||
VALUES (?,?,?,?,?,?,?,?,?)""",
|
||||
(t, row["name"], row["market"], row["market_cap"],
|
||||
row["is_managed"], row["is_preferred"], row["is_spac"], None, now))
|
||||
prices_df.to_sql("krx_daily_prices", conn, if_exists="append", index=False)
|
||||
flow_df.to_sql("krx_flow", conn, if_exists="append", index=False)
|
||||
conn.commit()
|
||||
|
||||
|
||||
def test_load_returns_dataframes(conn):
|
||||
asof = dt.date(2026, 5, 12)
|
||||
_seed(conn,
|
||||
make_master(["005930", "035420"]),
|
||||
make_prices(["005930", "035420"], days=30, asof=asof),
|
||||
make_flow(["005930", "035420"], days=30, asof=asof))
|
||||
|
||||
ctx = ScreenContext.load(conn, asof, lookback_days=30)
|
||||
|
||||
assert ctx.asof == asof
|
||||
assert set(ctx.master.index) == {"005930", "035420"}
|
||||
assert ctx.prices.shape[0] == 60 # 2 종목 × 30일
|
||||
assert ctx.flow.shape[0] == 60
|
||||
|
||||
|
||||
def test_restrict_filters_tickers(conn):
|
||||
asof = dt.date(2026, 5, 12)
|
||||
_seed(conn,
|
||||
make_master(["005930", "035420", "091990"]),
|
||||
make_prices(["005930", "035420", "091990"], days=30, asof=asof),
|
||||
make_flow(["005930", "035420", "091990"], days=30, asof=asof))
|
||||
|
||||
ctx = ScreenContext.load(conn, asof, lookback_days=30)
|
||||
scoped = ctx.restrict(pd.Index(["005930"]))
|
||||
|
||||
assert list(scoped.master.index) == ["005930"]
|
||||
assert (scoped.prices["ticker"] == "005930").all()
|
||||
assert (scoped.flow["ticker"] == "005930").all()
|
||||
Reference in New Issue
Block a user