Skip to main content

Overview

The analytics.getRunInfo endpoint provides information about the current trading session, including when trading began. This is useful for calculating session duration, determining data availability, and contextualizing performance metrics.

Endpoint

Input Parameters

This endpoint takes no input parameters.

Response Schema

Date | null
The timestamp when trading began, determined by the earliest portfolio snapshot.Returns null if no portfolio snapshots exist (trading has not started).

How Run Start Time is Determined

The run start time is calculated by finding the earliest portfolio snapshot in the database:
Key points:
  • Uses the portfolioSize table, which tracks portfolio values over time
  • Finds the earliest createdAt timestamp
  • Returns null if the table is empty (no trading activity yet)
  • Does not distinguish between live trading and simulator modes

Use Cases

Calculate Session Duration

Determine how long the trading session has been running:

Contextualize Performance Metrics

Provide context for Sharpe ratio and other time-sensitive metrics:

Determine Data Availability

Check if historical data is available for analysis:

Usage Examples

Display Session Uptime

Calculate Session Statistics

Conditional Rendering Based on Data Availability

Session Reliability Warning

Combine with Leaderboard for Context

Implementation Notes

Why Portfolio Snapshots?

The endpoint uses portfolio snapshots rather than other timestamps (like first order or first model creation) because:
  1. Portfolio snapshots are consistent: They’re created regularly by the system
  2. Meaningful start time: Trading effectively begins when portfolio tracking starts
  3. Available for both modes: Works in both live trading and simulator modes
  4. Database reliability: The portfolioSize table is a stable source of truth

Null Handling

The endpoint returns null instead of throwing an error when no data exists. This allows:
  • Graceful handling in UI components
  • Conditional rendering based on data availability
  • Clear distinction between “no data” and “error”

Time Zones

The returned Date object is in UTC. Convert to local time in your UI:

Source Code Reference

Implementation details:
  • Router: src/server/orpc/router/analytics.ts:243-250
  • Query function: src/server/features/analytics/queries.server.ts:666-674
  • Database schema: src/db/schema.ts (portfolioSize table)