feat: 새로운 안전 규칙 및 최적화 적용을 통한 트레이딩 시스템 개선

변경 사항 (Changes):

구문 오류(Syntax error) 및 토큰 낭비를 방지하기 위해 에이전트 쉘(Agent shell)과 파이썬 코드 스니펫에 다수의 신규 안전 규칙(Safety rules)을 추가함.

스키마 검증 및 적절한 SQL 포맷팅을 보장하기 위해 임시(Ad-hoc) 데이터베이스 쿼리 작성 가이드라인을 도입함.

코드 수정 후 UI 기능이 정상 작동하는지 확인하기 위해, 백테스트 웹 서비스 재시작 및 브라우저 검증에 대한 새로운 규칙을 구현함.

시스템 전반의 무결성(Integrity)을 유지하기 위해 실전 매매(Live trading), 웹 백테스팅, 파라미터 탐색(Parameter searches) 간의 일관성 검사(Consistency checks) 체계를 확립함.

기대 효과 (Impact):

이러한 개선 사항들은 트레이딩 시스템의 견고성(Robustness)과 신뢰성을 향상시키며, 에러 발생을 최소화하고 다양한 시스템 컴포넌트 간의 원활한 상호작용을 보장함.
This commit is contained in:
Your Name
2026-07-17 01:09:09 +09:00
parent a4626e0351
commit fc27e726f9
151 changed files with 20718 additions and 6450 deletions

View File

@@ -64,7 +64,7 @@ class TailCatchStrategy(BaseStrategy):
except Exception as e:
self.logger.debug("tail_engine defaults 조회 실패: %s", e)
self.eod_enabled = get_env_bool("TAIL_EOD_ENABLED", True)
self.eod_hm = get_env_from_db("TAIL_EOD_HM", "15:25")
self.eod_hm = get_env_from_db("TAIL_EOD_HM", "15:20")
def _candidate_filter(self, candidate: Dict) -> bool:
"""tail_on 이 True 인 후보만 대상 (SCALP 과 분리)."""
@@ -174,13 +174,22 @@ class TailCatchStrategy(BaseStrategy):
pass
try:
today_trades = self.db.get_trades_by_date(today)
daily_cnt = len([
code_trades = [
t for t in today_trades
if t.get("code") == code and str(t.get("strategy", "")).startswith("SHORT")
])
]
daily_cnt = len(code_trades)
daily_pnl_krw = sum(
float(t.get("realized_pnl") or 0) for t in code_trades
)
except Exception:
daily_cnt = 0
state = {"last_exit_dt": last_exit_dt, "daily_cnt": daily_cnt}
daily_pnl_krw = 0.0
state = {
"last_exit_dt": last_exit_dt,
"daily_cnt": daily_cnt,
"daily_pnl_krw": daily_pnl_krw,
}
params = dict(self._engine_params or {})
params["_whipsaw_ws"] = self.ws
@@ -381,9 +390,9 @@ class TailCatchStrategy(BaseStrategy):
now = dt.now()
is_eod = is_live_eod_now(
getattr(self, "eod_enabled", True),
getattr(self, "eod_hm", "15:25"),
getattr(self, "eod_hm", "15:20"),
now,
default_hm="15:25",
default_hm="15:20",
)
try:
params = te.get_tail_defaults_from_db(self.db)