Skip to main content

Description

Retrieves historical portfolio net asset value (NAV) over time, grouped by model. Supports date range filtering and automatic downsampling to optimize chart rendering performance. Essential for displaying portfolio performance charts, calculating drawdowns, and analyzing historical returns.

Input Schema

VariantId
Filter portfolio history by model variant. Valid values: "Apex", "Trendsurfer", "Contrarian", "Sovereign". Omit to fetch history from all variants.
string
ISO 8601 datetime string for the start of the date range (e.g., "2024-01-01T00:00:00.000Z"). Defaults to earliest available data if omitted.
string
ISO 8601 datetime string for the end of the date range (e.g., "2024-12-31T23:59:59.999Z"). Defaults to current time if omitted.
number
Maximum number of data points to return. Used for downsampling when dataset is large. Must be between 100 and 15,000. Defaults to an appropriate value based on the query (aggregate mode needs more points since data spans multiple model-variant combinations).

TypeScript Type

Output Schema

PortfolioSnapshot[]
Array of portfolio value snapshots over time.
DownsampleResolution
required
Time resolution of the returned data after downsampling. Indicates the time bucket size used:
  • "1m" - 1-minute intervals
  • "5m" - 5-minute intervals
  • "15m" - 15-minute intervals
  • "1h" - 1-hour intervals
  • "4h" - 4-hour intervals
The resolution is automatically determined based on the data range and maxPoints parameter.

TypeScript Type

Example Usage

Basic Portfolio Chart

Filter by Date Range

Filter by Variant

Calculate Performance Metrics

Compare Multiple Variants

Implementation Notes

  • Precision: netPortfolio is stored as TEXT in the database to preserve decimal precision. Always use parseFloat() for calculations.
  • Downsampling: Server automatically downsamples based on data range and maxPoints to optimize performance. The resolution field indicates the time bucket size used.
  • Retention Policy: Raw data is retained for 7 days, then aggregated into hourly buckets for 30 days. Older data is aggregated into daily buckets.
  • Aggregate Mode: When querying without a variant, data spans all model-variant combinations, requiring higher maxPoints for sufficient granularity.
  • Error Handling: Throws an error on fetch failure with the original error message.