refactor: enhance Optuna backtesting framework, optimize orderbook filtering, and update database management utilities.

This commit is contained in:
Your Name
2026-08-12 10:19:19 +09:00
parent cb7e5037a0
commit c6bd62a25f
218 changed files with 31613 additions and 759 deletions

View File

@@ -163,6 +163,21 @@ class SafeRequest:
if resp.status_code in self.RETRYABLE_STATUSES:
if resp.status_code == 429:
self._rate_limit_hits += 1
try:
from kis_trader.utils.ops_alert import note_counter, ops_alert
from kis_trader.utils.env import get_env_int
streak = note_counter("rate_limit")
need = max(1, get_env_int("OPS_ALERT_RATE_LIMIT_STREAK", 5))
if streak >= need:
ops_alert(
"rate_limit",
f"HTTP 429 유량 연속 {streak}",
detail=f"{method.upper()} {url}",
level="critical",
)
note_counter("rate_limit", reset=True)
except Exception:
pass
logger.warning(
"HTTP %d on %s %s (%d/%d) → 백오프 후 재시도",
resp.status_code, method.upper(), url, attempt, self.max_retries,
@@ -178,6 +193,21 @@ class SafeRequest:
body = None
if body and self._is_kis_rate_limited(body):
self._rate_limit_hits += 1
try:
from kis_trader.utils.ops_alert import note_counter, ops_alert
from kis_trader.utils.env import get_env_int
streak = note_counter("rate_limit")
need = max(1, get_env_int("OPS_ALERT_RATE_LIMIT_STREAK", 5))
if streak >= need:
ops_alert(
"rate_limit",
f"KIS 유량초과 연속 {streak}",
detail=f"{body.get('msg_cd')} {url}",
level="critical",
)
note_counter("rate_limit", reset=True)
except Exception:
pass
logger.warning(
"KIS rate-limit %s on %s (%d/%d) → 백오프 후 재시도",
body.get("msg_cd"), url, attempt, self.max_retries,