diff --git a/web_dashboard.py b/web_dashboard.py index 2ebe962..163e94a 100644 --- a/web_dashboard.py +++ b/web_dashboard.py @@ -76,6 +76,13 @@ async def get_state(): portfolio_value += data['total'] * price usdt_free = balance.get('USDT', {}).get('free', 0) + + # P&L CALCULATION + initial_capital = 137.79 + pnl_usdt = portfolio_value - initial_capital + pnl_pct = (pnl_usdt / initial_capital * 100) if initial_capital > 0 else 0 + pnl_status = "🟢 PROFIT" if pnl_usdt > 0.01 else ("🔴 LOSS" if pnl_usdt < -0.01 else "⚪ BREAK") + pnl_color = "accent" if pnl_usdt > 0.01 else ("negative" if pnl_usdt < -0.01 else "neutral") # Count active positions = locked coins (NOT trades.json) active_positions = 0 @@ -91,6 +98,10 @@ async def get_state(): 'usdt_free': round(usdt_free, 2), 'active_positions': active_positions, # ← NEW: Real count! 'current_trades': trades.get('current', {}), + 'pnl_usdt': round(pnl_usdt, 2), + 'pnl_pct': round(pnl_pct, 2), + 'pnl_status': pnl_status, + 'pnl_color': pnl_color, 'completed_trades': trades.get('completed', []), 'prices': prices, 'timestamp': datetime.now().isoformat()