Get Portfolio History
Overview
The Get Portfolio History API allows you to retrieve historical portfolio data for a specific business within a specified date range. This provides insights into how the portfolio composition and value have changed over time.
Resource Access
- HTTP Method:
GET - Endpoint:
/v1/businesses/{business_id}/portfolio_history - Authentication: Bearer token required
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
business_id | string (UUID) | Yes | Unique identifier for the business |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
start_date | string (date) | Yes | Start date for the history query (YYYY-MM-DD format) |
end_date | string (date) | Yes | End date for the history query (YYYY-MM-DD format) |
Request Headers
| Header | Value | Required | Description |
|---|---|---|---|
Accept | application/json | Yes | Content type for the response |
Authorization | Bearer {access_token} | Yes | Bearer token for authentication |
Response
Success Response (200 OK)
{
"business_id": "urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc",
"start_date": "2022-01-01",
"end_date": "2023-02-01",
"history": [
{
"date": "2022-01-01",
"portfolio": {
"id": "urn:uuid:portfolio-123",
"products": [
{
"product": "managed_money_market",
"percentage": 50,
"value": 50000.00
},
{
"product": "managed_treasuries",
"percentage": 50,
"value": 50000.00
}
],
"total_value": 100000.00
}
},
{
"date": "2022-06-01",
"portfolio": {
"id": "urn:uuid:portfolio-123",
"products": [
{
"product": "managed_money_market",
"percentage": 45,
"value": 47250.00
},
{
"product": "managed_treasuries",
"percentage": 45,
"value": 47250.00
},
{
"product": "managed_income",
"percentage": 10,
"value": 10500.00
}
],
"total_value": 105000.00
}
}
]
}
Response Fields
| Field | Type | Description |
|---|---|---|
business_id | string (UUID) | Business identifier |
start_date | string (date) | Query start date |
end_date | string (date) | Query end date |
history | array | Array of portfolio snapshots |
History Item Fields
| Field | Type | Description |
|---|---|---|
date | string (date) | Date of the portfolio snapshot |
portfolio.id | string (UUID) | Portfolio identifier |
portfolio.products | array | Product allocations for this date |
portfolio.total_value | number | Total portfolio value |
Product Allocation Fields
| Field | Type | Description |
|---|---|---|
product | string | Product type (managed_money_market, managed_treasuries, managed_income) |
percentage | number | Percentage allocation |
value | number | Monetary value of this allocation |
Error Responses
- 400 Bad Request: Invalid date format or date range
- 401 Unauthorized: Invalid or missing authentication token
- 404 Not Found: Business not found or no portfolio history available
Code Examples
cURL
curl -X GET \
'https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio_history?start_date=2022-01-01&end_date=2023-02-01' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN'
Python
import requests
url = "https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio_history"
headers = {
"Accept": "application/json",
"Authorization": "Bearer YOUR_ACCESS_TOKEN"
}
params = {
"start_date": "2022-01-01",
"end_date": "2023-02-01"
}
response = requests.get(url, headers=headers, params=params)
print(response.json())
JavaScript (Node.js)
const axios = require('axios');
const url = 'https://api.example.com/v1/businesses/urn:uuid:9b397b0d-69bc-b09f-9d82-0e02637042fc/portfolio_history';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
};
const params = {
start_date: '2022-01-01',
end_date: '2023-02-01'
};
axios.get(url, { headers, params })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response.data);
});
Usage Notes
- Date parameters must be in YYYY-MM-DD format
- The start_date should be before or equal to the end_date
- History data is returned in chronological order
- If no portfolio history exists for the specified date range, an empty history array will be returned
- The API returns portfolio snapshots at regular intervals within the date range