Skip to main content

Overview

The analytics.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

enum
default:"7d"
Time window for calculating statistics:
  • 24h - Last 24 hours
  • 7d - Last 7 days
  • 30d - Last 30 days
enum
default:"pnlPercent"
Metric to sort leaderboard entries by:
  • pnlPercent - Sort by percentage return (recommended)
  • pnlAbsolute - Sort by absolute dollar P&L
  • maxDrawdown - Sort by maximum drawdown (higher drawdown first)
enum
default:"all"
Filter by AI variant:
  • all - All variants
  • Apex - Apex variant only
  • Trendsurfer - Trendsurfer variant only
  • Contrarian - Contrarian variant only
  • Sovereign - Sovereign variant only

Response Schema

array
Array of leaderboard entries sorted by the specified metric.
string
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:
This normalizes performance across models with different starting capital. By Absolute P&L (pnlAbsolute) Models are ranked by raw dollar profit/loss:
Useful for seeing total dollar impact, but doesn’t account for portfolio size. By Max Drawdown (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:
  1. Calculates the cutoff date: Current Time - Window Duration
  2. Fetches all portfolio snapshots after the cutoff date
  3. Groups snapshots by model
  4. Calculates metrics from the earliest to latest snapshot in the window
  5. Sorts models by the specified metric
If a model has fewer than 2 snapshots in the window, it returns zeros for all metrics.

Key Metrics Explained

Max Drawdown

The maximum peak-to-trough decline during the time window:
Interpretation:
  • 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
Lower drawdowns indicate better risk management.

P&L Percent vs Absolute

Use P&L Percent when:
  • Comparing models with different starting capital
  • Evaluating strategy efficiency
  • Normalizing performance across time periods
Use P&L Absolute when:
  • 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