feat: add hourly position status report via Telegram
Run status reporter thread every 60 minutes, sends current price, PnL, drop from peak, and holding time for each position. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -49,3 +49,34 @@ def notify_sell(ticker: str, price: float, pnl_pct: float, reason: str) -> None:
|
||||
|
||||
def notify_error(message: str) -> None:
|
||||
_send(f"⚠️ <b>[오류]</b>\n{message}")
|
||||
|
||||
|
||||
def notify_status(positions: dict) -> None:
|
||||
"""1시간마다 포지션 현황 요약 전송."""
|
||||
from datetime import datetime
|
||||
import pyupbit
|
||||
|
||||
now = datetime.now().strftime("%H:%M")
|
||||
|
||||
if not positions:
|
||||
_send(f"📊 <b>[{now} 현황]</b>\n보유 포지션 없음 — 매수 신호 대기 중")
|
||||
return
|
||||
|
||||
lines = [f"📊 <b>[{now} 현황]</b>"]
|
||||
for ticker, pos in positions.items():
|
||||
current = pyupbit.get_current_price(ticker)
|
||||
if not current:
|
||||
continue
|
||||
pnl = (current - pos["buy_price"]) / pos["buy_price"] * 100
|
||||
peak = pos["peak_price"]
|
||||
drop = (peak - current) / peak * 100
|
||||
elapsed = (datetime.now() - pos["entry_time"]).total_seconds() / 3600
|
||||
emoji = "📈" if pnl >= 0 else "📉"
|
||||
lines.append(
|
||||
f"\n{emoji} <b>{ticker}</b>\n"
|
||||
f" 현재가: {current:,.0f}원\n"
|
||||
f" 수익률: {pnl:+.1f}%\n"
|
||||
f" 최고가 대비: -{drop:.1f}%\n"
|
||||
f" 보유: {elapsed:.1f}h"
|
||||
)
|
||||
_send("\n".join(lines))
|
||||
|
||||
Reference in New Issue
Block a user