/compute/capital-gains

Base URL https://api.babylon.app/v1

POST /compute/capital-gains

Compute realised capital gains for a segment ledger and tax authority. The response contains a summary table and drill-down tables showing the calculations for each security.

JSON request body

  • segmentLedger (required) — identifier of the Babylon segment to analyse.
  • taxAuthority (required) — HMRC or SARS.
  • taxYear (optional) — tax year in YYYY/YY or YYYY/YYYY form, for example 2024/25; defaults to the tax year containing valueDate.
  • valueDate (optional) — calculation date in YYYY-MM-DD format; defaults to the current date.

HMRC calculations exclude SIPP, RA and ISA accounts. SARS calculations exclude SIPP, RA, TFSA and TFIA accounts.

Example request

POST /compute/capital-gains
Content-Type: application/json
{
  "segmentLedger": "MyGBSegment",
  "taxAuthority": "HMRC",
  "taxYear": "2024/25",
  "valueDate": "2025-04-05"
}

Example response — 200

{
  "type": "babylon.table.drilldown",
  "schemaVersion": 1,
  "table": {
    "name": "CapitalGains",
    "description": "",
    "columns": [
      "accountAlias",
      "bourseSymbol",
      "isin",
      "securityType",
      "description",
      "tradeDate",
      "settleDate",
      "costBasis",
      "netProceeds",
      "capitalGain",
      "currency"
    ],
    "columnTypes": {
      "costBasis": "Decimal",
      "netProceeds": "Decimal",
      "capitalGain": "Decimal"
    },
    "rows": [
      {
        "accountAlias": "AJB-GIA",
        "bourseSymbol": "LSE:PNL",
        "isin": "GB00BM8B5H06",
        "securityType": "SHRS",
        "description": "ORD GBP0.125",
        "tradeDate": "2024-07-15",
        "settleDate": "2024-07-17",
        "costBasis": "7500",
        "netProceeds": "9000",
        "capitalGain": "1500",
        "currency": "GBP"
      }
    ]
  },
  "detailKeyColumns": ["BourseSymbol"],
  "details": [
    {
      "key": ["LSE:PNL"],
      "table": {
        "name": "segment-ledger",
        "description": "Where (BourseSymbol filtered. AND TradeDate filtered.)",
        "columns": [
          "accountAlias",
          "type",
          "tradeDate",
          "settleDate",
          "isin",
          "bourseSymbol",
          "securityType",
          "description",
          "maturityDate",
          "quantityAdj",
          "netAmount",
          "currency",
          "runningQuantity",
          "runningCost",
          "avgPrice",
          "capitalGain",
          "costBasis",
          "netProceeds"
        ],
        "columnTypes": {
          "quantityAdj": "Decimal",
          "netAmount": "Decimal",
          "runningQuantity": "Decimal",
          "runningCost": "Decimal",
          "avgPrice": "Decimal",
          "capitalGain": "Decimal",
          "costBasis": "Decimal",
          "netProceeds": "Decimal"
        },
        "rows": [
          {
            "accountAlias": "AJB-GIA",
            "type": "Sell",
            "tradeDate": "2024-07-15",
            "settleDate": "2024-07-17",
            "isin": "GB00BM8B5H06",
            "bourseSymbol": "LSE:PNL",
            "securityType": "SHRS",
            "description": "ORD GBP0.125",
            "quantityAdj": "30",
            "netAmount": "9000",
            "currency": "GBP",
            "runningQuantity": "70",
            "runningCost": "-17500",
            "avgPrice": "250",
            "capitalGain": "1500",
            "costBasis": "7500",
            "netProceeds": "9000"
          }
        ]
      }
    }
  ]
}

This drill-down response is JSON. CSV output is not supported for this endpoint.

GET /compute/capital-gains

GET uses the same operation parameters in the query string.

Query parameters

  • segmentLedger (required)
  • taxAuthority (required)
  • taxYear (optional)
  • valueDate (optional)

Example request

GET /compute/capital-gains?segmentLedger=MyGBSegment&taxAuthority=HMRC&taxYear=2024%2F25&valueDate=2025-04-05

The response has the same drill-down JSON shape as the POST response.

← Back to API