Skip to main content

Endpoint

POST /api/simulation/simulate
Runs a Monte Carlo simulation using the provided financial profile, user inputs, and goal parameters. The simulation generates thousands of possible future scenarios to calculate success probability and outcome distributions.

Request Body

The request body must be a valid SimulationRequest object.
financialProfile
object
required
Complete financial profile containing current financial state.
userInputs
object
required
User-specific information affecting simulation parameters.
goal
object
required
Financial goal parameters for the simulation.
simulationParams
object
Optional parameters to control simulation execution.

Response

Returns detailed simulation results including success probability and outcome distributions.
successProbability
number
Probability (0.0 - 1.0) of achieving the specified goal within the timeline.
medianOutcome
number
Median portfolio value at the goal timeline (50th percentile).
percentiles
object
Portfolio value at various percentiles of the outcome distribution.
mean
number
Mean (average) portfolio value across all simulations.
std
number
Standard deviation of outcomes, indicating variability.
worstCase
number
Minimum portfolio value observed across all simulations.
bestCase
number
Maximum portfolio value observed across all simulations.
assumptions
object
Simulation assumptions used in the Monte Carlo model.

Example Request

curl -X POST "https://api.drift.example/api/simulation/simulate" \
  -H "Content-Type: application/json" \
  -d '{
    "financialProfile": {
      "liquidAssets": 15420.50,
      "creditDebt": 3250.00,
      "loanDebt": 28500.00,
      "monthlyLoanPayments": 425.00,
      "monthlyIncome": 6500.00,
      "monthlyBills": 850.00,
      "monthlySpending": 4120,
      "spendingByCategory": {
        "Grocery": 450.75,
        "Restaurants": 320.50,
        "Gas": 180.00
      },
      "spendingVolatility": 0.18
    },
    "userInputs": {
      "monthlyIncome": 6500,
      "age": 32,
      "riskTolerance": "medium"
    },
    "goal": {
      "targetAmount": 50000,
      "timelineMonths": 36,
      "goalType": "house_downpayment"
    },
    "simulationParams": {
      "nSimulations": 100000
    }
  }'

Example Response

{
  "successProbability": 0.73,
  "medianOutcome": 52340.25,
  "percentiles": {
    "p10": 38200.50,
    "p25": 45100.75,
    "p50": 52340.25,
    "p75": 59800.00,
    "p90": 68500.50
  },
  "mean": 53125.80,
  "std": 12450.30,
  "worstCase": 22100.00,
  "bestCase": 92300.75,
  "assumptions": {
    "annualReturnMean": 0.07,
    "annualReturnStd": 0.15,
    "inflationRate": 0.03,
    "inflationVolatility": 0.01,
    "annualRaiseMean": 0.03,
    "annualRaiseFrequency": "annual",
    "promotionProbabilitySemiAnnual": 0.05,
    "promotionRaiseMean": 0.10,
    "emergencyProbabilityMonthly": 0.02,
    "emergencyAmountRange": "500-3000",
    "incomeVolatility": 0.05,
    "expenseVolatility": 0.18
  }
}

Error Responses

500 Internal Server Error
{
  "error": "Failed to run simulation"
}

Usage Notes

  • Success probability above 0.70 (70%) is generally considered a good likelihood of achieving the goal
  • The simulation accounts for investment returns, inflation, income volatility, expense volatility, and random life events
  • Higher nSimulations values provide more accurate results but increase computation time
  • Risk tolerance affects the investment return assumptions used in the simulation
  • The assumptions object in the response shows the exact parameters used for transparency

Build docs developers (and LLMs) love