코드 변경

This commit is contained in:
2026-03-10 09:49:03 +09:00
parent a15ecaa314
commit 096e087a9a
8 changed files with 930 additions and 290 deletions

View File

@@ -268,9 +268,10 @@ class BacktestEngine:
rsi_threshold = params.get("MEAN_REVERSION_RSI_THRESHOLD", 30)
stop_loss = params.get("MEAN_REVERSION_STOP_LOSS_PCT", -6.0) / 100
take_profit = params.get("MEAN_REVERSION_TAKE_PROFIT_PCT", 12.0) / 100
rsi_overbought = params.get("RSI_OVERBOUGHT_LEVEL", 70.0)
current_price = df.loc[current_idx, "close"]
# 매수 신호 (과매도 + BB 하단)
if rsi < rsi_threshold and bb_pos < 0.2:
if stock_code not in self.positions:
@@ -279,12 +280,12 @@ class BacktestEngine:
"price": current_price,
"reason": f"RSI={rsi:.1f} BB하단"
}
# 매도 신호 (손절/익절)
if stock_code in self.positions:
pos = self.positions[stock_code]
pnl_pct = (current_price - pos.avg_price) / pos.avg_price
if pnl_pct <= stop_loss:
return {
"action": "SELL",
@@ -297,7 +298,7 @@ class BacktestEngine:
"price": current_price,
"reason": f"익절 {pnl_pct*100:.1f}%"
}
elif rsi > 70 and bb_pos > 0.8:
elif rsi > rsi_overbought and bb_pos > 0.8:
return {
"action": "SELL",
"price": current_price,