feat: Add DART strategy and related configurations

ㅇ
Changes:
- Introduced the DART strategy to the trading system, including its configuration and integration into the existing framework.
- Updated the database schema to include DART-specific tables for disclosures and watchlists.
- Enhanced the backtesting and parameter search functionalities to support the DART strategy.
- Implemented new rules for browser verification and API interactions to ensure compliance with the updated DART strategy.

Impact:
- These additions expand the trading capabilities of the system, allowing for more comprehensive analysis and execution of DART-related strategies, while maintaining system integrity and performance.
This commit is contained in:
Your Name
2026-07-21 07:50:24 +09:00
parent 74db49149f
commit 61bec4bd1d
86 changed files with 4811 additions and 297 deletions

View File

@@ -208,6 +208,9 @@ class KISOverseasWebSocket:
if self._running:
return True
if force_cleanup:
# 원래 동작: 재기동 시 메모리 approval 비우고 재발급 (국내 공유 매니저 미사용)
self._approval_key = None
self._approval_key_ts = 0.0
with self._cache_lock:
self._cache.clear()
if not self._get_approval_key():
@@ -237,24 +240,28 @@ class KISOverseasWebSocket:
# 내부: approval_key / 구독 메시지 / 파싱
# ==================================================================
def _get_approval_key(self) -> Optional[str]:
"""국내 WS 와 동일 approval_key 파일 캐시 공유 (6h/24h KIS 정책)."""
"""해외 전용 REST approval 발급 (국내 공유 매니저·정합성 freeze 와 무관)."""
now = time.time()
if self._approval_key and (now - self._approval_key_ts) < self.APPROVAL_KEY_CACHE_SEC:
return self._approval_key
try:
from kis_approval_manager import KISApprovalManager
except ImportError as exc:
logger.error("kis_approval_manager import 실패: %s", exc)
return None
mgr = KISApprovalManager.instance(self.is_mock)
key = mgr.get_approval_key(
self.app_key,
self.app_secret,
self._base_url,
force_refresh=False,
)
if key:
self._approval_key = key
self._approval_key_ts = mgr.issued_ts or time.time()
logger.debug("🔑 해외 WS approval_key 공유 (앞8자: %s…)", key[:8])
return key
url = f"{self._base_url}/oauth2/Approval"
body = {
"grant_type": "client_credentials",
"appkey": self.app_key,
"secretkey": self.app_secret,
}
r = requests.post(url, json=body, timeout=10)
key = r.json().get("approval_key")
if key:
self._approval_key = key
self._approval_key_ts = now
logger.info("✅ 해외 WS approval_key 발급 완료 (앞8자: %s…)", key[:8])
return key
logger.error("❌ 해외 WS approval_key 발급 실패: %s", r.text[:200])
except Exception as e:
logger.error("❌ 해외 WS approval_key 요청 예외: %s", e)
return None
def _build_sub_payload(self, tr_key: str, subscribe: bool) -> str:
return json.dumps({