Endpoint
Request Body
The Plaid user ID for the linked account. Used to retrieve the stored access token and fetch account data.
Basic user information that cannot be derived from account data.
Financial goal parameters for the simulation.
Optional parameters to control simulation execution.
Response
Returns simulation results enhanced with Plaid-derived data and metadata about the accounts included.Probability (0.0 - 1.0) of achieving the specified goal.
Median portfolio value at the goal timeline.
Portfolio value percentiles (p10, p25, p50, p75, p90).
Mean portfolio value across all simulations.
Standard deviation of outcomes.
Minimum portfolio value observed.
Maximum portfolio value observed.
Enhanced assumptions object with Plaid-specific metadata.
Example Request
Example Response
How It Works
Data Retrieval Process
- Access Token Lookup: Retrieves stored Plaid access token for the user
- Account Data Fetch: Calls Plaid API to get all account information:
- Depository accounts (checking, savings)
- Credit card accounts
- Loan accounts
- Investment accounts with holdings
- Profile Mapping: Transforms raw Plaid data into
EnhancedFinancialProfile - Parameter Derivation: Calculates sophisticated simulation parameters
Enhanced Parameter Derivation
Investment Returns (simulation.ts:321-342)- Aggregates actual investment allocations across all investment accounts
- Calculates weighted average using historical return assumptions:
- Stocks: 10% annual return, 18% volatility
- Bonds: 4% annual return, 6% volatility
- Cash: 2% annual return, 1% volatility
- Other: 6% annual return, 12% volatility
- Defaults to 7% return / 15% volatility if no investment accounts
- Derived from Plaid income stability score
- Formula:
max(0.02, min(0.15, (1 - stabilityScore) × 0.15)) - Higher stability score = lower income volatility
- Calculated from variance in actual spending patterns
- Based on transaction history analysis
- Filters to cards with non-zero balances
- Captures individual APR and minimum payment for each card
- Enables account-level interest calculations
- Filters to loans with non-zero balances
- Captures interest rate and monthly payment for amortization
- Supports home, auto, and personal loans
Financial Profile Construction
The endpoint automatically calculates:- Total Liquid Assets: Sum of all depository account balances
- Credit Debt: Sum of all credit card balances
- Loan Debt: Sum of all loan principals
- Monthly Income: Derived from income transactions
- Monthly Spending: Calculated from transaction history
- Spending by Category: Aggregated from categorized transactions
Error Responses
Error message describing what went wrong.
Additional error details (included on 500 errors).
Usage Notes
- Requires a valid Plaid link for the specified user (established via Plaid Link flow)
- Real-time data fetch may take 2-5 seconds depending on number of accounts
- Investment allocation analysis requires investment accounts with holdings data
- Income and spending calculations improve with more transaction history
- The
derivedParamsobject provides transparency into how real data influenced the simulation - Future enhancement: Pass
enhancedParams.creditCardsandenhancedParams.loansarrays to Python engine for account-level modeling
Advantages Over Standard Simulation
- Accuracy: Uses real account data instead of user estimates
- Completeness: Automatically includes all linked accounts
- Sophistication: Derives volatility and allocation from actual patterns
- Convenience: Requires minimal user input (age, risk tolerance, goal)
- Transparency: Returns detailed metadata about accounts and derived parameters
- Up-to-date: Fetches current balances and recent transactions