코드 변경
This commit is contained in:
@@ -25,7 +25,7 @@ from typing import Optional, Dict, List, Tuple
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
|
||||
from app.core.config import settings
|
||||
from app.services.strategy_config_service import strategy_cfg
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -225,7 +225,7 @@ def check_buy_signal(
|
||||
return None
|
||||
|
||||
if regime == MarketRegime.BULL:
|
||||
rsi_ok = rsi <= settings.MEAN_REVERSION_RSI_THRESHOLD # ← 기본값 30
|
||||
rsi_ok = rsi <= strategy_cfg.get("MEAN_REVERSION_RSI_THRESHOLD", 30.0)
|
||||
|
||||
if rsi_ok:
|
||||
# [2026-03] RSI 반등 확인: rsi_prev 제공 시 RSI 하락 중이면 진입 금지
|
||||
@@ -303,8 +303,10 @@ def check_exit_signal(
|
||||
# ── 1. 손절 (최우선) ──────────────────────────────────────────
|
||||
# [2026-03] ATR 손절 기준: lowest_since_entry → entry_price
|
||||
# 이유: 매수 직후 저점이 낮으면 ATR 손절가가 현재가보다 훨씬 아래 → 손절 사실상 무력화
|
||||
atr_stop = entry_price - 2.5 * atr
|
||||
pct_stop = entry_price * 0.94 # -6%
|
||||
atr_stop_mult = strategy_cfg.get("ATR_STOP_MULTIPLIER", 2.5)
|
||||
stop_loss_pct = strategy_cfg.get("STOP_LOSS_PERCENT", -6.0) # e.g. -6.0
|
||||
atr_stop = entry_price - atr_stop_mult * atr
|
||||
pct_stop = entry_price * (1 + stop_loss_pct / 100)
|
||||
stop_price = max(atr_stop, pct_stop) # 높은 값 = 타이트한 손절
|
||||
|
||||
if close <= stop_price:
|
||||
@@ -392,13 +394,13 @@ def calculate_position_size(
|
||||
|
||||
if rsi is not None:
|
||||
if rsi <= 20:
|
||||
multiplier = settings.MEAN_REVERSION_MULTIPLIER_STRONG
|
||||
multiplier = strategy_cfg.get("MEAN_REVERSION_MULTIPLIER_STRONG", 1.50)
|
||||
elif rsi <= 25:
|
||||
multiplier = settings.MEAN_REVERSION_MULTIPLIER_NORMAL
|
||||
multiplier = strategy_cfg.get("MEAN_REVERSION_MULTIPLIER_NORMAL", 1.25)
|
||||
else:
|
||||
multiplier = settings.MEAN_REVERSION_MULTIPLIER_WEAK
|
||||
multiplier = strategy_cfg.get("MEAN_REVERSION_MULTIPLIER_WEAK", 1.00)
|
||||
else:
|
||||
multiplier = settings.MEAN_REVERSION_MULTIPLIER_WEAK
|
||||
multiplier = strategy_cfg.get("MEAN_REVERSION_MULTIPLIER_WEAK", 1.00)
|
||||
|
||||
if adx is not None and adx < 15:
|
||||
multiplier = min(multiplier + 0.25, 2.0)
|
||||
|
||||
Reference in New Issue
Block a user