Get Variant Stats
Variants
Get Variant Stats
Retrieve aggregated performance statistics for each trading variant
POST
Get Variant Stats
Overview
Returns comprehensive performance statistics for all trading variants, aggregated across all models using each variant. This endpoint calculates win rates, P&L metrics, and model counts by analyzing closed orders and active models.Request
Input Schema
Response
Output Schema
Array of variant statistics objects
Example Response
Statistics Calculations
Aggregation Logic
For each variant, the endpoint:- Finds all models using the variant (
SELECT * FROM "Models" WHERE variant = ?) - Retrieves closed orders for those models (
WHERE status = 'CLOSED' AND modelId IN (...)) - Calculates metrics from the order data:
totalTrades: Count of closed orderswinRate:(wins / totalTrades) * 100where wins = orders withrealizedPnl > 0totalPnl: Sum of allrealizedPnlvaluesavgPnl:totalPnl / totalTradesmodelCount: Count of active models
Zero-Value Handling
If no models exist for a variant:- All numeric fields return
0 - The variant is still included in the response for completeness
Performance Considerations
- Uses database indexes on
models.variantandorders.status - Runs parallel queries for all variants using
Promise.all() - SQL array operations (
ANY(modelIds)) for efficient filtering
Usage
Performance Metrics
Database Queries
- Per variant: 2 queries (models lookup + orders aggregation)
- Total queries:
2 × number of variants(currently 8 queries) - Execution: Parallel via
Promise.all() - Average latency: 50-150ms depending on order volume
Indexes Used
Monitoring
The endpoint is wrapped in a Sentry performance span:Understanding the Metrics
Win Rate
Win Rate
Definition: Percentage of trades that closed with positive P&LCalculation:
(winning_trades / total_trades) × 100Interpretation:> 55%: Strong performance50-55%: Moderate performance< 50%: Underperforming
Average P&L
Average P&L
Definition: Mean profit/loss per closed tradeCalculation:
total_pnl / total_tradesInterpretation:> 0: Profitable on average< 0: Losing on average- Magnitude indicates risk-adjusted returns
Model Count
Model Count
Definition: Number of active models currently using the variantNote: This is a snapshot count, not historical. Models can be:
- Actively trading (status = ACTIVE)
- Paused (status = PAUSED)
- Any status except DELETED
Related Endpoints
Get Variants
List all available variants and their configurations
Get Variant History
View historical portfolio performance per variant

