feat: use 60min volume, add KRW P&L log, relax re-entry after win

- strategy: replace daily volume check with 60-min candle volume
  (daily volume at 5am is tiny -> BTC/ETH never matched; now uses
  last 1h candle vs previous 23h avg × 2)
- trader: log actual KRW net profit and fee on every sell
- trader: skip re-entry +1% block when last trade was a win
  (allow re-entry on new trend signal even below last sell price)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
joungmin
2026-03-01 05:38:37 +09:00
parent d2a5c3ae9e
commit 5df56a933e
2 changed files with 43 additions and 20 deletions

View File

@@ -198,16 +198,20 @@ def buy(ticker: str) -> bool:
return False
# 직전 매도가 +1% 이상일 때만 재진입 (손절 직후 역방향 재매수 방지)
# 단, 직전 거래가 수익(승)이었으면 이 필터 스킵 — 다시 상승 시 재진입 허용
if ticker in _last_sell_prices:
current_check = pyupbit.get_current_price(ticker)
last_sell = _last_sell_prices[ticker]
threshold = last_sell * 1.01
if current_check and current_check < threshold:
logger.info(
f"[재매수 차단] {ticker} 현재={current_check:,.2f} < "
f"직전매도+1%={threshold:,.2f} → 상승 흐름 미확인"
)
return False
hist = _get_history(ticker)
last_was_win = bool(hist[-1]) if hist else False
if not last_was_win:
current_check = pyupbit.get_current_price(ticker)
last_sell = _last_sell_prices[ticker]
threshold = last_sell * 1.01
if current_check and current_check < threshold:
logger.info(
f"[재매수 차단] {ticker} 현재={current_check:,.2f} < "
f"직전매도+1%={threshold:,.2f} → 상승 흐름 미확인"
)
return False
# Walk-forward 필터: 직전 WF_WINDOW건 승률이 낮으면 진입 차단
if WF_MIN_WIN_RATE > 0:
@@ -299,9 +303,13 @@ def sell(ticker: str, reason: str = "") -> bool:
current = pyupbit.get_current_price(ticker)
pnl = (current - pos["buy_price"]) / pos["buy_price"] * 100 if current else 0.0
# 실제 KRW 손익 및 수수료 계산 (업비트 수수료 0.05% 양방향)
sell_value = (current or pos["buy_price"]) * actual_amount
fee = pos["invested_krw"] * 0.0005 + sell_value * 0.0005
krw_profit = sell_value - pos["invested_krw"] - fee
logger.info(
f"[매도] {ticker} @ {current:,.0f}원 | "
f"수익률={pnl:+.1f}% | 사유={reason}"
f"수익률={pnl:+.1f}% | 순익={krw_profit:+,.0f}원 (수수료 {fee:,.0f}원) | 사유={reason}"
)
notify_sell(ticker, current, pnl, reason)
if current: