Analytics API
Auto-generated from
openapi-snapshot.json. Do not edit by hand — changes are overwritten byscripts/docs/generate_api_reference.py.
9 endpoints in this group.
GET /api/analytics/aum
Get Aum
AUM history for the authenticated tenant (#714) with capital breakdown: net_capital = contributed capital from capital_accounts unrealized = sum of unrealized_pnl from latest snapshot realized_ytd = sum of gain_loss from realized_trades YTD total_aum = net_capital + unrealized + realized_ytd
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/cumulative-pnl
Cumulative Pnl
Cumulative P&L series for the authenticated tenant (#714).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional | |
year | query | — | optional | |
period_days | query | — | optional | Optional rolling-window filter in days. |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/date-range
Get Date Range
Min/max realized-trade dates for the authenticated tenant.
Auth (#714): tenant_id is derived from the JWT claim. Admins may pass
tenant_id to read another tenant; non-admins cannot.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/drawdown
Compute Drawdown
Compute cumulative-PnL drawdown series for the authenticated tenant (#714).
#482 fixes:
- Reject malformed
date_soldrows — the legacy MTM tax-filing import contained strings like “Dec 29” + literal “Invalid Date” that polluted the series with phantom -80% drawdowns. The regex guard^YYYY-MM-DDexcludes them at the SQL layer. - Accept
period_daysso the 30d / 60d / 90d window buttons on the Performance Analysis page can actually filter the response; previously the frontend sliced the unbounded series client-side which was both slow and never reached the legacy rows that wedged the chart. - Drop the unsafe
LEFT(date_sold, 4)::integeryear filter in favor of the regex-validateddate_sold::datecomparison.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional | |
year | query | — | optional | |
period_days | query | — | optional | Optional rolling-window filter — only include trades whose date_sold is within the last N days. |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/investor-allocation
Get Investor Allocation
Investor allocation breakdown for the authenticated tenant (#714).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/pnl
Aggregate Pnl
P&L aggregate per period for the authenticated tenant (#714).
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional | |
period | query | string | optional | daily |
year | query | — | optional | |
period_days | query | — | optional | Optional rolling-window filter in days. |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/analytics/xirr
Compute Xirr
Compute XIRR (irregular cash flow IRR) using Newton-Raphson. Returns annualized rate of return. None if no convergence.
Request body: application/json
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
GET /api/analytics/yoy
Yoy Summary
Year-over-year P&L summary for the authenticated tenant (#714). Includes pnl_growth_pct vs prior year and aum_growth_pct.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |
POST /api/market/refresh
Refresh Market Data
Fetch latest prices from yfinance and update daily_position_snapshots.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
symbols | query | string | optional | Comma-separated symbols to refresh |
tenant_id | query | — | optional | |
account_id | query | — | optional | |
account_ids | query | — | optional |
Responses
| Code | Description |
|---|---|
200 | Successful Response |
422 | Validation Error |