API Documentation
API Reference

Investment Comparison

Compare investment scenarios with compound interest calculations

POST /investment-comparison

Compare investment scenarios with compound interest calculations.

Request Body

{
  principal: number;              // Required - Initial investment amount
  years: number;                  // Required - Investment period (1-50 years)
  scenarios: Array<{
    name: string;                 // Required - Scenario name
    rate: number;                 // Required - Annual interest rate (%)
  }>;
}

Constraints

  • Maximum 50 years
  • Maximum 10 scenarios per request
  • Arrays cannot be empty

Response

{
  input: {
    principal: number;
    years: number;
  };
  results: Array<{
    name: string;
    rate: number;
    finalValue: number;           // A = P(1 + r)^t
    totalGrowth: number;          // Final value - principal
    growthPercentage: number;     // (Growth / Principal) * 100
  }>;
}

Example

curl -X POST https://simplycpf.com/api/cpf/investment-comparison \
  -H "Content-Type: application/json" \
  -d '{
    "principal": 100000,
    "years": 20,
    "scenarios": [
      { "name": "CPF OA", "rate": 2.5 },
      { "name": "CPF SA", "rate": 4.0 },
      { "name": "Stock Market", "rate": 7.0 }
    ]
  }'
{
  "input": {
    "principal": 100000,
    "years": 20
  },
  "results": [
    {
      "name": "CPF OA",
      "rate": 2.5,
      "finalValue": 163861.64,
      "totalGrowth": 63861.64,
      "growthPercentage": 63.86
    },
    {
      "name": "CPF SA",
      "rate": 4.0,
      "finalValue": 219112.31,
      "totalGrowth": 119112.31,
      "growthPercentage": 119.11
    },
    {
      "name": "Stock Market",
      "rate": 7.0,
      "finalValue": 386968.45,
      "totalGrowth": 286968.45,
      "growthPercentage": 286.97
    }
  ]
}

Errors

StatusError
400Validation errors, exceeds limits

Use Cases

  • Compare CPF vs external investment returns
  • Model different interest rate scenarios
  • Calculate long-term retirement projections

On this page