Skip to Content
BlitzPulse docs are live. Looking for Blitz Global? Visit https://blitzglobalcapital.com.
Api ReferencePortfolio API

Portfolio API

Auto-generated from openapi-snapshot.json. Do not edit by hand — changes are overwritten by scripts/docs/generate_api_reference.py.

19 endpoints in this group.

GET /api/portfolio/archive-stats

Archive Stats

Row counts and date range for the snapshot and intraday tables.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/backfill/csv

Backfill From Csv

Deprecated stub — use /api/portfolio/backfill/upload instead.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/backfill/save

Backfill Save

Request body: application/json

Responses

CodeDescription
201Successful Response
422Validation Error

POST /api/portfolio/backfill/upload

Backfill Upload

Upload a CSV of historical position snapshots and upsert into daily_position_snapshots.

Expected CSV columns (flexible header matching): symbol, date, quantity, avg_cost, market_price, market_value Optional: unrealized_pnl, day_change_pct, source

Parameters

NameInTypeRequiredDescription
yearqueryintegeroptional
source_typequerystringoptional
tenant_idqueryoptional

Request body: multipart/form-data

Responses

CodeDescription
201Successful Response
422Validation Error

DELETE /api/portfolio/data

Delete Year Data

Soft-delete a year’s realized_trades + daily_position_snapshots.

Both tables get deleted_at = now() on still-active rows. No row is physically removed (see migration 0115_soft_delete_realized_dps).

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
yearqueryintegerrequired

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/eod

Run Eod Ingestion

Trigger end-of-day broker position fetch + snapshot save.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/eod/run-log

Get Eod Run Log

Return recent EOD snapshot runs grouped by snapshot_date.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
limitqueryintegeroptional

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/eod/trigger

Run Eod Ingestion

Trigger end-of-day broker position fetch + snapshot save.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/fees-summary

Fees Summary

Parameters

NameInTypeRequiredDescription
daysqueryintegeroptional
account_hashqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/pnl

Get Pnl Series

Daily P&L time series — P0-8: limit capped at 100.

G10 (mobile#150): supports keyset cursor pagination for infinite-scroll.

The series is grouped by snapshot_date and ordered ASC (chronological). Pass cursor from the previous page’s next_cursor to fetch the next chunk; the server emits next_cursor only when a full page was returned (len(rows) == limit). Cursor is opaque — a base64url JSON blob whose payload is {"d": "YYYY-MM-DD"} (date-only, since rows are grouped by date and have no row-id).

The page dependency provides limit (1..100) + a generic cursor query param for shape-parity with the blotter endpoint; we decode it locally rather than via decode_cursor because pnl keyset is one-column not two.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
start_datequeryoptional
end_datequeryoptional
limitqueryintegeroptionalPage size (max 100). Legacy — prefer ?page_size=.
page_sizequeryoptionalCanonical page size. Must be one of 25, 50, 100. When supplied, overrides ?limit=.
cursorqueryoptionalOpaque pagination cursor from a previous page’s next_cursor.

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/positions/{symbol}

Get Position By Symbol

Latest daily snapshot row for one symbol.

Returns 404 when the tenant has no snapshot for that symbol so the mobile client can render an empty-state without parsing. Returns 200 with the same shape as /snapshots (singular snapshot key + snapshot_date echo) so PositionDetailScreen reuses the existing dashboard summary-row parser.

Parameters

NameInTypeRequiredDescription
symbolpathstringrequired
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/realized-from-orders

Get Realized From Orders

Return FIFO realized lots derived from filled local orders.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
yearqueryoptional
symbolqueryoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/realized-kpis

Get Realized Kpis

Day/MTD/YTD realized gain/loss for the live Portfolio KPI strip.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
sourcequerystringoptionalbroker

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/realized-trades

Get Realized Trades

Return realized trades from uploads or connected-broker lot projections.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
yearqueryoptional
symbolqueryoptional
sourcequeryoptional
limitqueryoptional
pagequeryintegeroptional1-based page index.
page_sizequeryintegeroptionalPage size — must be one of 25, 50, 100.

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/realized-trades/sync

Sync Realized Trades

Repair Schwab realized-trade rows from already-stored broker data.

Parameters

NameInTypeRequiredDescription
account_idqueryoptional
account_idsqueryoptional
force_rebuild_closed_lotsquerybooleanoptional

Responses

CodeDescription
200Successful Response
422Validation Error

GET /api/portfolio/snapshots

Get Snapshots

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
account_idqueryoptional
account_idsqueryoptional
account_numberqueryoptional
start_datequeryoptional
end_datequeryoptional
as_of_datequeryoptional
latest_onlyquerybooleanoptional
refresh_livequerybooleanoptionalWhen true with latest_only, foreground-refresh connected broker positions before reading.
limitqueryintegeroptional

Responses

CodeDescription
200Successful Response
422Validation Error

POST /api/portfolio/snapshots

Save Snapshots

Request body: application/json

Responses

CodeDescription
201Successful Response
422Validation Error

POST /api/portfolio/snapshots/archive

Archive Snapshots

  1. Move daily_position_snapshots older than keep_snapshot_years to archive table.
  2. Roll up 5-min intraday bars older than keep_intraday_years into market_data_daily (preserving OHLCV + VWAP) before deleting them.
  3. Purge intraday bars beyond the retention window.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
keep_snapshot_yearsqueryintegeroptional
keep_intraday_yearsqueryintegeroptional

Responses

CodeDescription
200Successful Response
422Validation Error

DELETE /api/portfolio/trades

Delete Trades

Soft-delete realized_trades for the given tenant + year.

Sets deleted_at = now() on already-active rows (idempotent — rows that are already soft-deleted are skipped). Returns the number of rows that transitioned to soft-deleted in this call.

Parameters

NameInTypeRequiredDescription
tenant_idqueryoptional
yearqueryintegerrequired

Responses

CodeDescription
200Successful Response
422Validation Error