Overview
Theanalytics.getLeaderboard endpoint provides performance rankings for all AI models within a specified time window. It calculates P&L, max drawdown, and other metrics from portfolio history snapshots, making it ideal for comparing model performance over different time periods.
Endpoint
Input Parameters
Time window for calculating statistics:
24h- Last 24 hours7d- Last 7 days30d- Last 30 days
Metric to sort leaderboard entries by:
pnlPercent- Sort by percentage return (recommended)pnlAbsolute- Sort by absolute dollar P&LmaxDrawdown- Sort by maximum drawdown (higher drawdown first)
Filter by AI variant:
all- All variantsApex- Apex variant onlyTrendsurfer- Trendsurfer variant onlyContrarian- Contrarian variant onlySovereign- Sovereign variant only
Response Schema
Array of leaderboard entries sorted by the specified metric.
The time window used for calculations (echoed from input)
Leaderboard Ranking Logic
Sorting Behavior
By Percentage Return (pnlPercent) - Default
Models are ranked by percentage return, with higher returns ranked first:
pnlAbsolute)
Models are ranked by raw dollar profit/loss:
maxDrawdown)
Models are ranked by maximum drawdown, with higher drawdowns first. This is useful for identifying models with the most risk exposure:
When sorting by max drawdown, higher values appear first. This shows the models with the most risk, not the best risk management.
Time Window Calculation
The endpoint:- Calculates the cutoff date:
Current Time - Window Duration - Fetches all portfolio snapshots after the cutoff date
- Groups snapshots by model
- Calculates metrics from the earliest to latest snapshot in the window
- Sorts models by the specified metric
Key Metrics Explained
Max Drawdown
The maximum peak-to-trough decline during the time window:- 5% drawdown: Portfolio dropped 5% below its peak
- 20% drawdown: Portfolio dropped 20% below its peak
- 0% drawdown: Portfolio never fell below a previous high
P&L Percent vs Absolute
Use P&L Percent when:- Comparing models with different starting capital
- Evaluating strategy efficiency
- Normalizing performance across time periods
- Measuring total profit/loss impact
- Allocating capital based on dollar returns
- Comparing models with similar starting capital
Usage Examples
Display 7-Day Leaderboard
Compare Time Windows
Variant-Specific Leaderboard
Sort by Max Drawdown (Risk Analysis)
Source Code Reference
Implementation details:- Router:
src/server/orpc/router/analytics.ts:204-226 - Leaderboard calculation:
src/server/features/analytics/queries.server.ts:294-379 - Max drawdown computation:
src/server/features/analytics/queries.server.ts:277-287 - Shared utilities:
src/core/shared/trading/calculations.ts
Related Endpoints
- Get Model Stats - Comprehensive trading statistics
- Get Failures - Failure tracking and debugging
- Get Run Info - Trading session information

