feat(tests): 신규 키움 웹소켓 조건검색 및 실시간 조건검색 테스트 추가
변경 사항 ---- - _test_kiwoom_condition_list.py: 키움 웹소켓 조건검색 '목록조회' 기능을 단독으로 테스트하는 스크립트 추가 - _test_kiwoom_condition_realtime.py: 'momentum' 조건식을 실시간으로 등록하고 초기 매칭 종목 리스트 및 실시간 편입/이탈을 수신하는 테스트 스크립트 추가 - _verify_columnar_bitid.py, _verify_shared_e2e_breakout.py, _verify_shared_e2e.py: 공유 메모리 및 dict 간의 데이터 일관성을 검증하는 테스트 추가 영향 ---- - 신규 테스트 스크립트 추가로 키움 웹소켓 API의 기능 검증 및 안정성을 높임 - 기존 기능에 대한 영향 없음 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -15,11 +15,11 @@ import tempfile
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from typing import Any, Optional
|
||||
from typing import Any, Iterable, Optional
|
||||
|
||||
import requests
|
||||
|
||||
from .env import get_env_from_db
|
||||
from .env import get_env_bool, get_env_from_db
|
||||
|
||||
# ── 로깅 ─────────────────────────────────────────────────────────────
|
||||
# 루트 로거 한 번만 설정 (여러 모듈에서 import되어도 중복 핸들러 안 생기게)
|
||||
@@ -117,6 +117,51 @@ def _load_mm_channel_id(channel_alias: str) -> Optional[str]:
|
||||
return None
|
||||
|
||||
|
||||
def msg_mm_multi(
|
||||
text: str,
|
||||
channel_aliases: Iterable[str],
|
||||
*,
|
||||
jitter: bool = True,
|
||||
) -> bool:
|
||||
"""
|
||||
동일 메시지를 여러 MM alias 로 발송 (중복 alias 는 1회만).
|
||||
jitter=True 이면 첫 채널에만 슬립 — 체결 알림은 jitter=False 권장.
|
||||
"""
|
||||
seen: set[str] = set()
|
||||
any_ok = False
|
||||
first = True
|
||||
for raw in channel_aliases:
|
||||
alias = str(raw or "").strip()
|
||||
if not alias or alias in seen:
|
||||
continue
|
||||
seen.add(alias)
|
||||
if msg_mm(text, channel_alias=alias, jitter=jitter and first):
|
||||
any_ok = True
|
||||
first = False
|
||||
return any_ok
|
||||
|
||||
|
||||
def msg_mm_strategy(
|
||||
text: str,
|
||||
strategy_channel_alias: str,
|
||||
*,
|
||||
jitter: bool = False,
|
||||
) -> bool:
|
||||
"""
|
||||
전략 채널 + (옵션) 통합 채널 이중 발송.
|
||||
MM_DUAL_CHANNEL_ENABLED=true 일 때 MATTERMOST_CHANNEL 도 함께 전송 (alias 같으면 1회).
|
||||
"""
|
||||
strat_ch = str(strategy_channel_alias or "").strip() or str(
|
||||
get_env_from_db("MATTERMOST_CHANNEL", "stock")
|
||||
)
|
||||
aliases = [strat_ch]
|
||||
if get_env_bool("MM_DUAL_CHANNEL_ENABLED", False):
|
||||
unified = str(get_env_from_db("MATTERMOST_CHANNEL", "stock") or "stock").strip()
|
||||
if unified and unified != strat_ch:
|
||||
aliases.append(unified)
|
||||
return msg_mm_multi(text, aliases, jitter=jitter)
|
||||
|
||||
|
||||
def msg_mm(text: str, channel_alias: Optional[str] = None, jitter: bool = True) -> bool:
|
||||
"""
|
||||
Mattermost 메시지 전송.
|
||||
|
||||
Reference in New Issue
Block a user