feat: Enhance trading system with new e_min_chg_pct parameter and related logic
Changes: - Introduced the `e_min_chg_pct` parameter to define the minimum price change percentage compared to the previous day's close, enhancing the momentum trading strategy. - Updated various functions and classes to incorporate this new parameter, ensuring it is utilized in both backtesting and live trading scenarios. - Improved documentation and comments to clarify the purpose and usage of the new parameter across the codebase. Impact: - This addition allows for more precise control over trading conditions, potentially increasing the effectiveness of the momentum strategy while maintaining system integrity and performance.
This commit is contained in:
@@ -359,6 +359,8 @@ def _mom_fixed_defaults(market: str = "KR") -> Dict[str, Any]:
|
||||
out["mom_rsi_max"] = float(_d["mom_rsi_max"])
|
||||
if _d.get("mom_vol_mult") is not None:
|
||||
out["mom_vol_mult"] = float(_d["mom_vol_mult"])
|
||||
if _d.get("e_min_chg_pct") is not None:
|
||||
out["e_min_chg_pct"] = float(_d["e_min_chg_pct"])
|
||||
if _d.get("max_hold_bars") is not None:
|
||||
out["max_hold_bars"] = int(float(_d["max_hold_bars"]))
|
||||
|
||||
@@ -694,6 +696,11 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"MOMENTUM_GRID_FAST_MOM_VOL_MULT",
|
||||
_fmerge([1.0, 2.0, 5.0], float(live.get("mom_vol_mult") or 2.0)),
|
||||
),
|
||||
# HTS K: 전일종가 대비 최소등락(%) — 실매 0.2 포함
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FAST_E_MIN_CHG_PCT",
|
||||
_fmerge([0.0, 0.2, 0.5, 1.0], float(live.get("e_min_chg_pct") or 0.2)),
|
||||
),
|
||||
"tp_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FAST_TP_PCT",
|
||||
_fmerge([3.0, 5.0, 15.0], float(live.get("tp_pct") or 3.0)),
|
||||
@@ -811,6 +818,10 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"MOMENTUM_GRID_RR_MOM_VOL_MULT",
|
||||
[float(get_env_float("MOMENTUM_VOL_MULT", 1.5))],
|
||||
),
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_RR_E_MIN_CHG_PCT",
|
||||
_fmerge([0.0, 0.2, 0.5, 1.0, 1.5], float(live.get("e_min_chg_pct") or 0.2)),
|
||||
),
|
||||
"sl_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_RR_SL_PCT", [1.2, 1.5, 1.8, 2.0],
|
||||
),
|
||||
@@ -841,6 +852,10 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"MOMENTUM_GRID_COARSE_MOM_VOL_MULT",
|
||||
_fmerge([1.0, 2.0, 3.0, 5.0], float(live.get("mom_vol_mult") or 2.0)),
|
||||
),
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_COARSE_E_MIN_CHG_PCT",
|
||||
_fmerge([0.0, 0.2, 0.5, 1.0], float(live.get("e_min_chg_pct") or 0.2)),
|
||||
),
|
||||
"tp_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_COARSE_TP_PCT",
|
||||
_fmerge([3.0, 5.0, 8.0, 15.0], float(live.get("tp_pct") or 3.0)),
|
||||
@@ -925,6 +940,10 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"MOMENTUM_GRID_FINE_MOM_VOL_MULT",
|
||||
_fmerge([1.0, 2.0, 3.0, 5.0], float(live.get("mom_vol_mult") or 2.0)),
|
||||
),
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FINE_E_MIN_CHG_PCT",
|
||||
_fmerge([0.0, 0.2, 0.5, 1.0], float(live.get("e_min_chg_pct") or 0.2)),
|
||||
),
|
||||
"tp_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FINE_TP_PCT",
|
||||
_fmerge([2.0, 3.0, 5.0, 8.0, 15.0], float(live.get("tp_pct") or 3.0)),
|
||||
@@ -1068,6 +1087,13 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"MOMENTUM_GRID_WIDE_MOM_VOL_MULT",
|
||||
[1.0, 1.05, 1.2, 1.5, 2.0, 3.0, 5.0, 8.0, 10.0, 15.0],
|
||||
),
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_WIDE_E_MIN_CHG_PCT",
|
||||
_fmerge(
|
||||
[0.0, 0.2, 0.3, 0.5, 0.8, 1.0, 1.5, 2.0],
|
||||
float(live.get("e_min_chg_pct") or 0.2),
|
||||
),
|
||||
),
|
||||
"tp_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_WIDE_TP_PCT",
|
||||
[2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 15.0],
|
||||
@@ -1137,6 +1163,10 @@ def _momentum_grids(market: str = "KR") -> Dict[str, Dict[str, List]]:
|
||||
"mom_vol_mult": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FULL_MOM_VOL_MULT", [3.0, 10.0, 20.0],
|
||||
),
|
||||
"e_min_chg_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FULL_E_MIN_CHG_PCT",
|
||||
_fmerge([0.0, 0.2, 0.5, 1.0], float(live.get("e_min_chg_pct") or 0.2)),
|
||||
),
|
||||
"tp_pct": _parse_csv_floats(
|
||||
"MOMENTUM_GRID_FULL_TP_PCT", [3.0, 5.0, 7.0],
|
||||
),
|
||||
@@ -1196,6 +1226,7 @@ MOMENTUM_GRID_AXIS_HINTS_KO: Dict[str, str] = {
|
||||
"mom_rsi_min": "RSI3 하한 — 약세 제외",
|
||||
"mom_rsi_max": "RSI3 상한 — use_rsi_max_filter ON 시만",
|
||||
"mom_vol_mult": "TRIGGER 거래량 펄스: 현재봉 ≥ N봉평균 × 배수",
|
||||
"e_min_chg_pct": "HTS K: 전일 종가 대비 최소 등락(%) — 0=종가초과만, 0.2=HTS기본",
|
||||
"trigger_require_bull_bar": "양봉 필수 (0=OFF, 1=ON) — HTS TRIGGER",
|
||||
"pattern_breakout": "(레거시) N분 고가 돌파 패턴",
|
||||
"pattern_pullback": "(레거시) 눌림 재돌파 패턴",
|
||||
@@ -1275,6 +1306,7 @@ def _get_momentum_field_map() -> Dict[str, Tuple[str, Any]]:
|
||||
"mom_rsi_max": ("MOMENTUM_RSI_MAX", lambda v: str(int(v))),
|
||||
"mom_vol_mult": ("MOMENTUM_VOL_MULT", lambda v: str(float(v))),
|
||||
"mom_vol_win": ("MOMENTUM_VOL_WIN", lambda v: str(int(float(v)))),
|
||||
"e_min_chg_pct": ("MOMENTUM_E_MIN_CHG_PCT", lambda v: str(float(v))),
|
||||
"mom_time_end_hm":("MOMENTUM_TIME_END_HM", lambda v: str(int(float(v)))),
|
||||
"mom_max_from_open_pct": ("MOMENTUM_MAX_FROM_OPEN_PCT", lambda v: str(float(v))),
|
||||
"mom_min_from_open_pct": ("MOMENTUM_MIN_FROM_OPEN_PCT", lambda v: str(float(v))),
|
||||
|
||||
Reference in New Issue
Block a user