전략수정 및 버그수정

This commit is contained in:
2026-02-22 23:29:22 +09:00
parent d49c6209cb
commit 7867ced1b6
3 changed files with 25 additions and 14 deletions

View File

@@ -115,13 +115,13 @@ def aggregate_to_5min(candles: List[MinuteCandle]) -> List[MinuteCandle]:
if not candles:
return []
buckets: Dict[int, List[MinuteCandle]] = {}
buckets: Dict[tuple, List[MinuteCandle]] = {}
for c in candles:
if not c.time:
continue
h = int(c.time[:2])
m = int(c.time[2:4])
key = (h * 60 + m) // 5
key = (c.date, (h * 60 + m) // 5) # 날짜 포함 → 다른 날 캔들 혼합 방지
buckets.setdefault(key, []).append(c)
result: List[MinuteCandle] = []
@@ -234,9 +234,11 @@ def check_orb_signal(
if recent_vol < orb.avg_vol_per_min * 1.5:
return None
# 직전 5분봉 양봉 확인
# 직전 5분봉 양봉 확인 (5분봉 2개 이상 없으면 보수적으로 차단)
candles_5m = aggregate_to_5min(candles_1min)
if len(candles_5m) >= 2 and candles_5m[-2].close < candles_5m[-2].open:
if len(candles_5m) < 2:
return None # 데이터 부족 시 진입 차단
if candles_5m[-2].close < candles_5m[-2].open:
return None # 직전 5분봉 음봉 → 스킵
stop_loss = max(orb.low, current_price * (1 - STOP_LOSS_PCT))
@@ -298,7 +300,8 @@ def check_vwap_bounce_signal(
return None
atr = _atr(candles_5min, 14)
stop_loss = (current_price - 1.5 * atr) if atr else current_price * (1 - STOP_LOSS_PCT)
raw_stop = (current_price - 1.5 * atr) if atr else current_price * (1 - STOP_LOSS_PCT)
stop_loss = max(raw_stop, current_price * (1 - STOP_LOSS_PCT * 2), 1.0)
target = (current_price + 2.0 * atr) if atr else vwap * 1.03
return DayTradeSignal(
@@ -355,8 +358,13 @@ def check_rsi_bb_signal(
return None
atr = _atr(candles_5min, 14)
stop_loss = (current_price - 1.5 * atr) if atr else current_price * (1 - STOP_LOSS_PCT)
target = bb_middle # BB 중앙선까지 반등 목표
raw_stop = (current_price - 1.5 * atr) if atr else current_price * (1 - STOP_LOSS_PCT)
stop_loss = max(raw_stop, current_price * (1 - STOP_LOSS_PCT * 2), 1.0)
# 최소 1.5R 보장: bb_middle이 너무 가까우면 R:R 확보를 위해 목표 상향
risk = current_price - stop_loss
target = max(bb_middle, current_price + risk * 1.5)
if target <= current_price: # 방어 로직 (stop_loss ≥ current_price 극단 케이스)
return None
return DayTradeSignal(
stock_code=stock_code,