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:
@@ -47,12 +47,20 @@ def resolve_prev_trading_day_open(
|
||||
"""
|
||||
전일(직전 거래일) 시가 — HTS momentum E 조건 ``close > prev_open`` 확인용.
|
||||
|
||||
1분봉에서 전일 첫 봉 open = 일봉 시가.
|
||||
1분봉에서 전일 **장 시작 구간** 첫 봉 open = 일봉 시가.
|
||||
전일 오후 봉만 있으면(웜업 부족) 오후 open을 시가로 오인하므로 None 반환.
|
||||
"""
|
||||
from kis_trader.utils.env import get_env_int
|
||||
|
||||
# 전일 시가로 인정할 최대 HHMM (기본 09:10 — 그 이후만 있으면 장시작 시가 미확정)
|
||||
open_hm_max = max(900, int(get_env_int("MOMENTUM_PREV_DAY_OPEN_HM_MAX", 910)))
|
||||
|
||||
prev_day: Optional[str] = None
|
||||
prev_open: Optional[float] = None
|
||||
earliest_hm: Optional[int] = None
|
||||
for j in range(i - 1, -1, -1):
|
||||
d = str(candles[j].get("candle_time", ""))[:8]
|
||||
ct = str(candles[j].get("candle_time", ""))
|
||||
d = ct[:8]
|
||||
if not d or d >= day:
|
||||
continue
|
||||
if prev_day is None:
|
||||
@@ -62,9 +70,36 @@ def resolve_prev_trading_day_open(
|
||||
op = float(candles[j].get("open", 0) or 0)
|
||||
if op > 0:
|
||||
prev_open = op
|
||||
hm = None
|
||||
if len(ct) >= 12:
|
||||
try:
|
||||
hm = int(ct[8:12])
|
||||
except (TypeError, ValueError):
|
||||
hm = None
|
||||
if hm is not None:
|
||||
if earliest_hm is None or hm < earliest_hm:
|
||||
earliest_hm = hm
|
||||
if prev_open is None or prev_open <= 0:
|
||||
return None
|
||||
# 전일 시가 = 정규장 시작 근처 봉이 시리즈에 있어야 함 (오후만 있으면 미확정)
|
||||
if earliest_hm is None or earliest_hm > open_hm_max:
|
||||
return None
|
||||
return prev_open
|
||||
|
||||
|
||||
def candles_have_prev_session_open(
|
||||
candles: List[Dict],
|
||||
day: str,
|
||||
) -> bool:
|
||||
"""기간일 ``day`` 기준 직전 거래일 **장시작 시가** 봉이 있는지 (E조건 해석 가능)."""
|
||||
if not candles:
|
||||
return False
|
||||
d = str(day or "")[:8]
|
||||
if len(d) < 8:
|
||||
return True
|
||||
return resolve_prev_trading_day_open(candles, len(candles) - 1, d) is not None
|
||||
|
||||
|
||||
def _volume_pulse_ok(
|
||||
candles: List[Dict],
|
||||
i: int,
|
||||
|
||||
Reference in New Issue
Block a user