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:
@@ -21,18 +21,27 @@ def flatten_remaining_portfolio_trades(
|
||||
"""루프 종료 후 미청산 포지션을 마지막 확정봉 종가로 장부에 남긴다.
|
||||
|
||||
분봉이 중간에 끊겨 EOD/max_hold 판정이 안 돈 종목(실매는 벽시계로 청산) 정합용.
|
||||
``eod_enabled`` 이면 sell_reason=``eod``, 아니면 ``bt_flatten``.
|
||||
마지막 봉 시각이 EOD 시각 **이후**일 때만 ``장마감청산``/``eod`` —
|
||||
그 전이면 ``bt_flatten`` (14:57 봉을 장마감으로 위장하지 않음).
|
||||
"""
|
||||
reason = str(default_reason or "bt_flatten")
|
||||
reason_default = str(default_reason or "bt_flatten")
|
||||
eod_on = False
|
||||
eod_hm = "15:20"
|
||||
eod_reason = "eod"
|
||||
_is_eod_bar = None
|
||||
if params is not None and strategy:
|
||||
try:
|
||||
from kis_trader.engine.strategy_eod import resolve_strategy_eod_params
|
||||
from kis_trader.engine.strategy_eod import (
|
||||
is_backtest_eod_bar,
|
||||
resolve_strategy_eod_params,
|
||||
)
|
||||
|
||||
eod_on, _eod_hm = resolve_strategy_eod_params(params, strategy)
|
||||
if eod_on:
|
||||
reason = "eod"
|
||||
eod_on, eod_hm = resolve_strategy_eod_params(params, strategy)
|
||||
sid = str(strategy or "").strip().upper()
|
||||
eod_reason = "장마감청산" if sid == "SCALP" else "eod"
|
||||
_is_eod_bar = is_backtest_eod_bar
|
||||
except Exception:
|
||||
pass
|
||||
eod_on = False
|
||||
|
||||
n = 0
|
||||
for code in list(portfolio.keys()):
|
||||
@@ -61,6 +70,13 @@ def flatten_remaining_portfolio_trades(
|
||||
if exit_price <= 0 or not sell_time:
|
||||
del portfolio[code]
|
||||
continue
|
||||
reason = reason_default
|
||||
if eod_on and _is_eod_bar is not None:
|
||||
try:
|
||||
if _is_eod_bar(sell_time, True, eod_hm, default_hm=eod_hm):
|
||||
reason = eod_reason
|
||||
except Exception:
|
||||
pass
|
||||
trade: Dict[str, Any] = {
|
||||
"code": code,
|
||||
"buy_time": pos["entry_time"],
|
||||
@@ -180,6 +196,13 @@ STRATEGY_PORTFOLIO_KEYS: Dict[str, Dict[str, Tuple[str, ...]]] = {
|
||||
"per_stock_cap": ("DBBAND_MAX_BUY_AMOUNT",),
|
||||
"min_invest_env": ("DBBAND_MIN_INVEST_RATIO_OF_SLOT", "MIN_INVEST_RATIO_OF_SLOT"),
|
||||
},
|
||||
"DART": {
|
||||
"max_stocks": ("DART_MAX_STOCKS", "MAX_STOCKS"),
|
||||
"total_budget": ("DART_TOTAL_BUDGET_KRW", "SHORT_TOTAL_BUDGET_KRW"),
|
||||
"slot": ("DART_SLOT_MONEY", "SLOT_MONEY_DEFAULT"),
|
||||
"per_stock_cap": ("DART_MAX_BUY_AMOUNT",),
|
||||
"min_invest_env": ("DART_MIN_INVEST_RATIO_OF_SLOT", "MIN_INVEST_RATIO_OF_SLOT"),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user