Skip to main content

Overview

Autonome provides comprehensive portfolio analytics that track performance, risk exposure, and trading efficiency. All metrics are calculated using shared utility functions to ensure consistency across the UI, prompts, and API responses.

Core Metrics

Sharpe Ratio

Autonome calculates Sharpe ratio using two methods:
  1. Portfolio-Based Sharpe (preferred): Uses portfolio NAV snapshots to compute annualized risk-adjusted returns
  2. Trade-Based Sharpe (simplified): Uses closed trade P&Ls for quick approximation
Why Portfolio-Based?
  • Accounts for unrealized P&L and exposure changes
  • Captures true portfolio volatility
  • Consistent with industry-standard Sharpe calculation
Trade-based Sharpe (calculateSharpeRatioFromTrades) is used when portfolio history is unavailable or for quick approximations. It divides mean trade P&L by standard deviation of trade P&Ls.

Drawdown Metrics

Interpretation:
  • Max Drawdown: Largest peak-to-trough decline in portfolio value (e.g., 15.2% means portfolio fell 15.2% from its peak)
  • Current Drawdown: Distance from current value to all-time high (0% = at ATH)

Win Rate & Expectancy

Expectancy Formula: (Win% × Avg Win) - (Loss% × Avg Loss)
  • Positive expectancy = profitable system long-term
  • Negative expectancy = system loses money on average per trade

Unrealized P&L

Calculated dynamically using current market prices:
Unrealized P&L falls back to stored value if market price is unavailable. This prevents UI flickering during network issues.

Performance Metrics Module

Portfolio Snapshot

The PortfolioSnapshot type aggregates all portfolio state:
Calculation Logic:

Exposure & Risk Metrics

Risk Calculation:

Analytics Calculations Module

The analytics module provides advanced statistics:

Portfolio History & Downsampling

Portfolio values are recorded every minute in the PortfolioHistory table:
Downsampling for Charts: To optimize chart performance, historical data is downsampled based on time range:
Downsampling is server-side to reduce payload size. Raw data is retained for 7 days, then aggregated into hourly/daily buckets.

Real-Time Updates

Analytics update in real-time via SSE (Server-Sent Events):
Client-Side Invalidation:

Trading API

Portfolio history and metrics API

Database Schema

Portfolio and Orders table structures

Real-Time Events

How SSE keeps the UI synchronized

Analytics API

Performance statistics and analytics endpoints