feat(stock-lab): telegram.py 메시지 빌더 (Top10 + 아이콘 + 페이지 링크)
This commit is contained in:
51
stock-lab/app/test_screener_telegram.py
Normal file
51
stock-lab/app/test_screener_telegram.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import datetime as dt
|
||||
from app.screener.telegram import build_telegram_payload
|
||||
|
||||
|
||||
def test_build_payload_includes_top10_and_link():
|
||||
rows = [
|
||||
{
|
||||
"rank": i, "ticker": f"00{i:04}", "name": f"종목{i}",
|
||||
"total_score": 90 - i,
|
||||
"scores": {"foreign_buy": 80 + i, "volume_surge": 60, "momentum": 70,
|
||||
"high52w": 75, "rs_rating": 85, "ma_alignment": 80, "vcp_lite": 30},
|
||||
"close": 50000, "entry_price": 50250, "stop_price": 48500,
|
||||
"target_price": 53750, "r_pct": 3.5,
|
||||
}
|
||||
for i in range(1, 21)
|
||||
]
|
||||
p = build_telegram_payload(
|
||||
asof=dt.date(2026, 5, 12),
|
||||
mode="auto",
|
||||
survivors_count=612,
|
||||
top_n=20,
|
||||
rows=rows,
|
||||
run_id=42,
|
||||
)
|
||||
assert p["parse_mode"] == "MarkdownV2"
|
||||
text = p["text"]
|
||||
assert "2026" in text and "05" in text and "12" in text
|
||||
assert "종목1" in text
|
||||
assert "종목10" in text
|
||||
assert "종목11" not in text # 본문 1-10만
|
||||
assert "42" in text # run_id 링크
|
||||
|
||||
|
||||
def test_score_threshold_filters_icons():
|
||||
rows = [{
|
||||
"rank": 1, "ticker": "A", "name": "A주",
|
||||
"total_score": 80,
|
||||
"scores": {"foreign_buy": 90, "volume_surge": 50, "momentum": 70,
|
||||
"high52w": 30, "rs_rating": 80, "ma_alignment": 80, "vcp_lite": 60},
|
||||
"close": 50000, "entry_price": 50250, "stop_price": 48500,
|
||||
"target_price": 53750, "r_pct": 3.5,
|
||||
}]
|
||||
p = build_telegram_payload(dt.date(2026, 5, 12), "auto", 100, 1, rows, run_id=1)
|
||||
# foreign_buy(90), momentum(70), rs_rating(80), ma_alignment(80) 만 표시 (≥70)
|
||||
assert "👤외" in p["text"]
|
||||
assert "🚀모" in p["text"]
|
||||
assert "💪RS" in p["text"]
|
||||
assert "📈MA" in p["text"]
|
||||
assert "⚡거" not in p["text"]
|
||||
assert "🆙고" not in p["text"]
|
||||
assert "🌀VCP" not in p["text"]
|
||||
Reference in New Issue
Block a user