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:- Portfolio-Based Sharpe (preferred): Uses portfolio NAV snapshots to compute annualized risk-adjusted returns
- Trade-Based Sharpe (simplified): Uses closed trade P&Ls for quick approximation
- 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
- 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
(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:Performance Metrics Module
Portfolio Snapshot
ThePortfolioSnapshot type aggregates all portfolio state:
Exposure & Risk Metrics
Analytics Calculations Module
The analytics module provides advanced statistics:Portfolio History & Downsampling
Portfolio values are recorded every minute in thePortfolioHistory table:
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):Related Resources
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

