Calculate Portfolio Health Score
const url = 'https://indepai.app/api/v1/portfolio-health';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"assets":[{"type":"stock","value":100000,"symbol":"VWCE.DE","name":"Vanguard FTSE All-World UCITS ETF","quantity":50,"purchasePrice":110.5,"currency":"EUR","expenseRatio":0.22,"region":"Global"}],"userAge":35,"targetAllocation":{"stocks":1,"etf":1,"bonds":1,"cash":1,"crypto":1,"real_estate":1,"other":1},"email":"hello@example.com","saveResult":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://indepai.app/api/v1/portfolio-health \ --header 'Content-Type: application/json' \ --data '{ "assets": [ { "type": "stock", "value": 100000, "symbol": "VWCE.DE", "name": "Vanguard FTSE All-World UCITS ETF", "quantity": 50, "purchasePrice": 110.5, "currency": "EUR", "expenseRatio": 0.22, "region": "Global" } ], "userAge": 35, "targetAllocation": { "stocks": 1, "etf": 1, "bonds": 1, "cash": 1, "crypto": 1, "real_estate": 1, "other": 1 }, "email": "hello@example.com", "saveResult": true }'Calculate a health score for a portfolio based on diversification, cost efficiency, risk alignment, and rebalancing needs.
Request Body
Section titled “Request Body”object
Array of portfolio assets
object
Type of asset
Example
etfCurrent value in base currency
Example
100000Ticker symbol (optional)
Example
VWCE.DEAsset name (optional)
Example
Vanguard FTSE All-World UCITS ETFNumber of units held
Example
50Purchase price per unit
Example
110.5Currency code (ISO 4217)
Example
EURAnnual expense ratio for ETFs/funds (%)
Example
0.22Geographic region of the asset
Example
GlobalUser age for risk assessment (default: 35)
Example
35Target asset allocation for rebalancing analysis
object
Optional email to associate with the result
Whether to save result for analytics (default: true)
Responses
Section titled “Responses”Health score calculation successful
object
Indicates successful calculation
object
Overall health score (0-1000)
Portfolio health badge level based on total score
object
Diversification score (0-250)
Cost efficiency score (0-250)
Age-appropriate risk score (0-250)
Rebalancing needs score (0-250)
Actionable improvement suggestions
Breakdown of assets by type (percentage)
object
Total portfolio value
object
Example
{ "success": true, "data": { "totalScore": 790, "level": "Beginner", "components": { "diversification": 180, "costEfficiency": 220, "riskAlignment": 200, "rebalancing": 190 }, "recommendations": [ "Consider adding international diversification", "Your expense ratios are excellent" ], "assetBreakdown": { "etf": 74, "stock": 18, "cash": 8 }, "totalValue": 135000 }}Validation error
object
Always false for error responses
Error type
Machine-readable error code
Detailed validation errors
object
Path to the invalid field
Error message
Example
{ "success": false, "error": "Validation error", "code": "VALIDATION_ERROR", "details": [ { "path": "currentAge", "message": "Must be between 18 and 100" } ]}Rate limit exceeded
object
Always false for error responses
Error type
Machine-readable error code
Detailed validation errors
object
Path to the invalid field
Error message
Example
{ "success": false, "error": "Validation error", "code": "VALIDATION_ERROR", "details": [ { "path": "currentAge", "message": "Must be between 18 and 100" } ]}