Balance & Metrics Display Flow
Legend
- Blue nodes → API/Data operations
- Green nodes → UI updates
- Yellow nodes → Warning states
Balance Graph
Data Source
- Trades: Completed trades from
alerts + alert_results
- Calculation: Equity curve built from starting balance + cumulative PnL
- Timeframes: Day, Week, Month, All
Chart Rendering
- Library: Chart.js (Canvas)
- Type: Line chart
- X-Axis: Timestamp
- Y-Axis: Account Equity
TopstepX Metrics
Data Source
- API Endpoint:
/api/topstepx/account-metrics
- TopstepX Calls:
getAccountBalance() - Current balance
searchTrades() - Recent trades for PnL
searchAccounts() - Account phase and details
Metrics Displayed
- Current Balance: Real-time account balance
- Realized PnL Today: P&L from closed trades today
- Unrealized PnL: P&L from open positions
- Daily P&L: Total daily profit/loss
- Account Phase: Challenge, Verification, Funded
Auto-Refresh
- Interval: 5 seconds (frequent updates)
- Purpose: Real-time balance tracking
Risk State Display
Data Source
- API Endpoint:
/api/topstepx/risk-state
- Function:
getTopstepXRiskState() with forceRefresh: true
- Equity Now: Current account equity
- Realized PnL Today: Today's realized P&L (session boundary: 5pm ET)
- Trailing High Equity: Highest equity reached
- Open Trades: List of open positions
- Fetched At: Timestamp of last fetch
- Is Stale: Whether state is older than max age
Warning Badges
- Stale State: Shown if
fetchedAt age > 10 seconds
- Verification Mismatch: Shown if state verification fails
- Assumed Floor: Shown if funded + MLL zero +
floorSource = 'assumed'
Auto-Refresh
- Interval: 30 seconds
- Purpose: Keep risk state current for trading decisions