Skip to main content

Statistics Display Flow

Legend

  • Blue nodes → API/Data operations
  • Green nodes → UI updates
  • Orange nodes → Decision logic
  • Red/Green → Color coding

Statistics Calculated

Trade Counts

  • Total Alerts: All trades (pending + completed)
  • Completed Trades: Trades with status: done, take_profit, stop_loss, session_end
  • Wins: Completed trades with pnl > 0
  • Losses: Completed trades with pnl < 0

Streaks

  • Max Consecutive Wins: Longest win streak
  • Max Consecutive Losses: Longest loss streak

Performance Metrics

  • Win Rate: (wins / completed_trades) * 100
  • Total PnL $: Sum of all PnL in dollars
  • Total PnL %: Sum of all PnL as percentage
  • Avg PnL %: Average PnL per trade
  • Best Trade %: Highest single trade PnL percentage

Data Priority

  1. Live Trades: If user has live trades (is_live = true), show live stats
  2. Simulation Trades: If no live trades, show simulation stats
  3. Admin Users: Can see simulation trades when live trading is disabled

Auto-Refresh

  • Interval: 30 seconds
  • Triggers: loadStats() automatically
  • Note: Prevents rapid blinking by only updating if value changes significantly (>$10 for PnL)

Color Coding

  • Green (Positive): Wins, positive PnL, win streaks
  • Red (Negative): Losses, negative PnL, loss streaks
  • Neutral: Counts and percentages (no color class)