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

@@ -205,6 +205,11 @@ def get_scalping_defaults_from_db(*, env_row: Optional[Dict[str, Any]] = None) -
time_start_hm = int(float(r.get("SCALP_TIME_START") or r.get("TIME_START") or 900))
time_end_hm = int(float(r.get("SCALP_TIME_END") or r.get("TIME_END") or 1530))
max_daily = int(float(r.get("SCALP_MAX_DAILY") or r.get("MAX_DAILY") or 3))
# EOD — 실매 기존 15:25 장마감청산과 동일 (strategy_eod SCALP)
eod_enabled = _to_bool(r.get("SCALP_EOD_ENABLED"), True)
if r.get("SCALP_EOD_ENABLED") in (None, "", "None") and r.get("force_eod_exit") not in (None, "", "None"):
eod_enabled = _to_bool(r.get("force_eod_exit"), True)
eod_hm = str(r.get("SCALP_EOD_HM") or "15:25").strip() or "15:25"
else:
cooldown_min, fee_pct, tax_pct, slot = 10, 0.015, 0.18, 300_000.0
high_chase_thr, max_daily_chg, min_price = 0.96, 20.0, 1000.0
@@ -224,6 +229,7 @@ def get_scalping_defaults_from_db(*, env_row: Optional[Dict[str, Any]] = None) -
require_reversal_candle = True
vol_mult = 0.0
time_start_hm, time_end_hm, max_daily = 900, 1530, 3
eod_enabled, eod_hm = True, "15:25"
except Exception:
cooldown_min, fee_pct, tax_pct, slot = 10, 0.015, 0.18, 300_000.0
@@ -244,6 +250,7 @@ def get_scalping_defaults_from_db(*, env_row: Optional[Dict[str, Any]] = None) -
require_reversal_candle = True
vol_mult = 0.0
time_start_hm, time_end_hm, max_daily = 900, 1530, 3
eod_enabled, eod_hm = True, "15:25"
return {
"cooldown_min": cooldown_min,
@@ -287,6 +294,10 @@ def get_scalping_defaults_from_db(*, env_row: Optional[Dict[str, Any]] = None) -
"max_stocks": max_stocks,
"total_budget_krw": total_budget_krw,
"portfolio_mode": portfolio_mode,
"eod_enabled": eod_enabled,
"eod_hm": eod_hm,
# 레거시 별칭 — 포트폴리오/단건 엔진 force_eod 경로 호환
"force_eod_exit": eod_enabled,
}
@@ -668,11 +679,8 @@ def run_scalping_backtest(
min_margin = float(params.get("min_margin", 0.002))
use_defense_filters = _to_bool(params.get("use_defense_filters", True), True)
use_macd_cross = _to_bool(params.get("use_macd_cross", False), False)
# 백테스트 EOD 강제청산 여부:
# - True : 기존 동작 유지(당일 마지막 봉에서 청산)
# - False: 실매와 유사하게 포지션 오픈 유지(미청산은 결과 미기록)
force_eod_exit = _to_bool(params.get("force_eod_exit"), False)
from kis_trader.engine.strategy_eod import is_strategy_eod_bar
from kis_trader.engine.tick_exit_common import (
backtest_sell_slip_pct,
backtest_tick_poll_ms,
@@ -728,8 +736,8 @@ def run_scalping_backtest(
running_high = max(running_high, hi)
running_low = min(running_low, lo)
is_eod_raw = (i == len(candles) - 1) or (candles[i + 1]["candle_time"][:8] != day)
is_eod = is_eod_raw and force_eod_exit
# 실매 SCALP_EOD_HM(기본 15:25) 과 동일 — force_eod 마지막봉만 의존 금지
is_eod = is_strategy_eod_bar(c["candle_time"], params, "SCALP")
# ── 포지션 보유 중: 청산 체크 ──
if position is not None: