옵투나 8방 후처리를 재탐색으로 변경하기 전전

This commit is contained in:
Your Name
2026-08-23 17:51:29 +09:00
parent 3eaa3b61df
commit ba2f9f0953
58 changed files with 25306 additions and 344 deletions

View File

@@ -202,6 +202,31 @@ def attach_optional_backtest_trades(
return result
def slim_trades_for_optuna_json(
trades: Optional[List[Dict[str, Any]]],
) -> List[Dict[str, Any]]:
"""Optuna 결과 JSON용 체결 요약 — 정합 diff용 최소 필드만 (전체 봉/틱 메타 제외)."""
out: List[Dict[str, Any]] = []
for t in trades or []:
if not isinstance(t, dict):
continue
out.append(
{
"code": t.get("code") or t.get("ticker"),
"buy_time": t.get("buy_time") or t.get("entry_time"),
"sell_time": t.get("sell_time") or t.get("exit_time"),
"pnl": t.get("pnl"),
"sell_reason": (
t.get("sell_reason") or t.get("reason") or t.get("exit_reason")
),
"entry_price": t.get("entry_price") or t.get("buy_price"),
"exit_price": t.get("exit_price") or t.get("sell_price"),
"qty": t.get("qty") or t.get("quantity"),
}
)
return out
def optuna_stable_gate_defaults() -> Tuple[int, float, float, int]:
"""(max_losing_days, min_worst_day_pnl, lambda, min_active_days)."""
return (
@@ -917,6 +942,9 @@ def ensure_optuna_gate_env_defaults(db: Any = None) -> None:
"OPTUNA_OB_COMBO_TRIALS_SINGLE": "150",
"OPTUNA_OB_COMBO_TRIALS_DOUBLE": "200",
"OPTUNA_OB_COMBO_TRIALS_TRIPLE": "250",
"OPTUNA_WHIPSAW_PER_COMBO": "true",
"OPTUNA_WHIPSAW_PER_COMBO_TRIALS": "100",
"OPTUNA_WHIPSAW_PER_COMBO_MIN_TRADES": "3",
"OPTUNA_OB_ENTRY_SPREAD_MIN": "0.1",
"OPTUNA_OB_ENTRY_SPREAD_MAX": "8.0",
"OPTUNA_OB_ENTRY_RATIO_MIN": "0.05",