29 lines
1007 B
Python
29 lines
1007 B
Python
import datetime as dt
|
|
import pandas as pd
|
|
|
|
from app.screener.engine import ScreenContext
|
|
from app.screener.nodes.volume_surge import VolumeSurge
|
|
from app.screener._test_fixtures import make_master, make_prices, make_flow
|
|
|
|
|
|
def _ctx(master, prices, flow):
|
|
return ScreenContext(master=master, prices=prices, flow=flow,
|
|
kospi=pd.Series(dtype=float, name="kospi"),
|
|
asof=dt.date(2026, 5, 12))
|
|
|
|
|
|
def test_recent_volume_surge_gets_higher_score():
|
|
asof = dt.date(2026, 5, 12)
|
|
master = make_master(["A", "B"])
|
|
prices = make_prices(["A", "B"], days=30, asof=asof)
|
|
# A는 최근 3일 거래량 10배로
|
|
mask = (prices["ticker"] == "A") & (prices["date"] >= (asof - dt.timedelta(days=3)).isoformat())
|
|
prices.loc[mask, "volume"] *= 10
|
|
flow = make_flow(["A", "B"], days=30, asof=asof)
|
|
|
|
out = VolumeSurge().compute(
|
|
_ctx(master, prices, flow),
|
|
{"baseline_days": 20, "eval_days": 3},
|
|
)
|
|
assert out["A"] > out["B"]
|