import sys, os sys.path.insert(0, '.') from app.db.models import get_conn from datetime import datetime with get_conn() as c: pos = c.execute('SELECT ticker, name, entry_time, entry_price, quantity, stop_price FROM positions').fetchall() print('=== 현재 포지션 ===') if pos: for r in pos: print(f' {r[1]}({r[0]}) {r[4]}주 @ {r[3]:,.0f}원 SL={r[5]:,.0f}원 진입={r[2]}') else: print(' 없음') today = datetime.now().strftime('%Y-%m-%d') with get_conn() as c: trades = c.execute( "SELECT name, exit_reason, pnl FROM trades WHERE date=? AND exit_time IS NOT NULL ORDER BY id", (today,) ).fetchall() print(f'\n=== 오늘 거래 ({len(trades)}건) ===') wins = sum(1 for t in trades if t[2] and t[2] > 0) losses = len(trades) - wins for t in trades: sign = '+' if t[2] and t[2] > 0 else '' print(f' {t[0]:12} [{t[1]:4}] {sign}{t[2]:,.0f}원') print(f' 승:{wins} 패:{losses}')