All routes require a bearer token with the
read:users scope plus the
x-user-id header so the backend can resolve the retail account.Overview
The investments screen displays portfolio performance, holdings breakdown, and interactive charts. It uses 4 endpoints to build the UI.Data sources
Get User Portfolios
Retrieve all portfolios for the user and identify the primary portfolio.
Prices by Tenor
Get historical price data for the portfolio chart organized by tenor.
Portfolio Returns by Tenor
Get portfolio holdings with pre-calculated performance metrics (returns and upBy values) across all time periods.
Investment Products
Get current ticker/pricing data for all investment products.
Use the Portfolio Returns by Tenor endpoint to display pre-calculated returns and performance metrics without client-side calculations.
Prerequisites
- Bearer token with
read:usersscope x-user-idheader to identify the user account
Data Flow and Component Building
Phase 1: Initial Load
- Fetch User Portfolios
- Call
GET /portfoliosto retrieve all portfolios for the user - Extract the primary portfolio ID (typically the first portfolio)
- Call
Phase 2: Main Data Fetching
Fetch these in parallel:-
Prices by Tenor
- Response includes time series data for multiple tenors:
1w,1m,3m,6m,1y,max
- Each tenor contains:
data: Array of{timestamp, value, displayIntraday}pointsvalue: Portfolio value in the investor’s base currencydisplayIntraday: Boolean indicating whether to render intraday granularity
- Response includes time series data for multiple tenors:
-
Portfolio Returns by Tenor (recommended for performance metrics)
- Response includes:
calculatedPrice: Current portfolio valuereturnsValues: Returns ratios by tenor (e.g.,{ "1w": 0.003, "1m": 0.012, ... })upByValues: Absolute gains/losses by tenor (e.g.,{ "1w": 13.50, "1m": 54.20, ... })holdings: Array withsinceBuyReturnsfor each holding
- Use this for displaying returns percentages and upBy values without client-side calculations
- Response includes:
-
Investment Products
- Response: Array of investment products with current ticker data
- Used to enrich holdings with current prices and asset metadata
- Ticker data is automatically included (no query parameters needed)
Phase 3: Building UI Components
Component 1: Portfolio Value Display
Data Sources: Prices by Tenor + Portfolio Returns by Tenor- Extract
calculatedPriceas the current portfolio value - For the selected timeframe, use:
- Returns percentage:
returnsValues[timeframe] * 100(e.g.,0.012 * 100 = 1.2%) - UpBy value:
upByValues[timeframe](absolute gain/loss in currency)
- Returns percentage:
- Update displayed value and returns from Returns by Tenor for that timeframe
- Update chart data from Prices by Tenor for that timeframe
Component 2: Performance Chart
Data Source: Prices by Tenor- Parse the selected timeframe’s time series data
- Transform data points:
- Convert
timestamp(milliseconds) to date objects - Extract
valueas the price point - Format dates for x-axis labels
- Convert
- Render line chart with:
- X-axis: Dates
- Y-axis: Portfolio value
- Handle
displayIntradayflag for intraday vs daily data granularity
- Switch to the corresponding time series from the Prices by Tenor response
- Re-render chart with new data
Component 3: Holdings Breakdown
Data Sources: Portfolio Returns by Tenor + Investment Products-
Process holdings from Returns by Tenor:
- Each holding includes
sinceBuyReturns(cumulative return since purchase) - Use
calculatedPricefrom the response as total portfolio value - Calculate holding value: Match holdings with investment products to get current prices, or use
quantity * asset.currentTicker.price - Calculate allocation percentage:
(holdingValue / calculatedPrice) * 100 - Sort holdings by value (descending) or alphabetically
- Each holding includes
-
Group holdings (optional):
- By Asset Class: Group by
asset.assetClassType(if available in investment products) - By Asset Type: Group by
asset.isStockvsasset.isETF - Ungrouped: Show flat list
- By Asset Class: Group by
-
Display individual asset returns:
- Show
sinceBuyReturnsfor each holding (convert to percentage:sinceBuyReturns * 100) - Display asset details from the
assetobject in each holding (ISIN, name, symbol)
- Show
-
Build components:
- Pie Chart: Aggregate allocations by asset class or type
- Asset List: Display individual holdings with:
- Asset name (from Returns by Tenor or investment products)
- Allocation percentage
- Current value
- Quantity held
- Returns since buy
Component 4: Asset Class Filters
Data Source: Portfolio Returns by Tenor + Investment Products- Extract unique asset classes/types from holdings (using investment products data)
- Create filter buttons/chips for each asset class
- When filter selected:
- Filter holdings by selected asset class
- Update pie chart and asset list
- Recalculate totals
Complete Initialization Flow
Refresh Flow
When user pulls to refresh or returns to screen:- Invalidate cached data (if using caching)
- Re-fetch in parallel:
- Prices by Tenor
- Returns by Tenor
- Investment Products (if needed)
- Update all components with new data
Data Dependencies
- Returns by Tenor: Required for holdings breakdown, performance metrics, and individual asset returns
- Prices by Tenor: Required for chart visualization
- Investment Products: Optional, enhances holdings with current prices and metadata
See also
- API Reference → Portfolios API →
GET /portfolios - API Reference → Portfolios API →
GET /portfolios/{id}/prices-by-tenor - API Reference → Portfolios API →
GET /portfolios/{id}/with-returns-by-tenor - API Reference → Investment Products API →
GET /investment-products