ClickAPIs
Docs · Return attribution

Docs / Endpoints

Return attribution

POST/v1/attributionunits: 2 + 1 per symboldaily

Portfolio total return split into additive contributions by holding, by sector and by month (best and worst contributor), buy-and-hold or rebalanced.

Add "async": true to run it as a job, and "webhook_url" to be called when it finishes (Jobs & async). Calls estimated above 1,000 units run as jobs automatically.

Parameters

FieldTypeDefaultDescription
symbolsrequiredarray of string—1 to 100 holdings.
weightsarray of number—One starting weight per symbol (negative = short), normalised by gross exposure. Default: equal weight.
start_datedate—First date (YYYY-MM-DD). Default: one year before end_date.
end_datedate—Last date to include (YYYY-MM-DD). Default: the latest bar.
rebalance"none" | "monthly" | "quarterly""none"none = buy and hold (weights drift); monthly / quarterly = reset to the target weights at the first close of each period.
benchmarkstring"SPY"Benchmark for active return, or null.

Example request

Which holdings made this portfolio's return? Read the walkthrough →

Request POST /v1/attribution
{
  "symbols": [
    "AAPL",
    "MSFT",
    "NVDA",
    "JPM",
    "XOM"
  ],
  "weights": [
    0.3,
    0.25,
    0.2,
    0.15,
    0.1
  ]
}
The same call with curl, Python and JavaScript
curl https://clickapis.com/v1/attribution \
  -H "Authorization: Bearer $CLICKAPIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"symbols":["AAPL","MSFT","NVDA","JPM","XOM"],"weights":[0.3,0.25,0.2,0.15,0.1]}'
import os, requests

r = requests.post(
    "https://clickapis.com/v1/attribution",
    headers={"Authorization": f"Bearer {os.environ['CLICKAPIS_KEY']}"},
    json={
      "symbols": [
        "AAPL",
        "MSFT",
        "NVDA",
        "JPM",
        "XOM"
      ],
      "weights": [
        0.3,
        0.25,
        0.2,
        0.15,
        0.1
      ]
    },
    timeout=60,
)
print(r.json()["data"])
const r = await fetch("https://clickapis.com/v1/attribution", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.CLICKAPIS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "symbols": [
      "AAPL",
      "MSFT",
      "NVDA",
      "JPM",
      "XOM"
    ],
    "weights": [
      0.3,
      0.25,
      0.2,
      0.15,
      0.1
    ]
  }),
});
console.log((await r.json()).data);

Example response

Response 200 OK
{
  "ok": true,
  "data": {
    "start": "2025-11-12",
    "end": "2026-11-12",
    "trading_days": 251,
    "rebalance": "none",
    "total_return": 0.12915,
    "annualized_return": 0.129696,
    "holdings": [
      {
        "symbol": "AAPL",
        "weight_start": 0.3,
        "weight_end": 0.346124,
        "return": 0.302754,
        "contribution": 0.090826,
        "share_of_total": 0.703262,
        "sector": "Technology"
      },
      {
        "symbol": "XOM",
        "weight_start": 0.1,
        "weight_end": 0.130787,
        "return": 0.476784,
        "contribution": 0.047678,
        "share_of_total": 0.369172,
        "sector": "Energy"
      },
      {
        "symbol": "JPM",
        "weight_start": 0.15,
        "weight_end": 0.144798,
        "return": 0.089992,
        "contribution": 0.013499,
        "share_of_total": 0.104521,
        "sector": "Financial Services"
      },
      {
        "symbol": "MSFT",
        "weight_start": 0.25,
        "weight_end": 0.227926,
        "return": 0.02945,
        "contribution": 0.007363,
        "share_of_total": 0.057008,
        "sector": "Technology"
      },
      {
        "symbol": "NVDA",
        "weight_start": 0.2,
        "weight_end": 0.150364,
        "return": -0.151081,
        "contribution": -0.030216,
        "share_of_total": -0.233963,
        "sector": "Technology"
      }
    ],
    "sectors": [
      {
        "sector": "Technology",
        "holdings": 3,
        "weight_start": 0.75,
        "contribution": 0.067972
      },
      {
        "sector": "Energy",
        "holdings": 1,
        "weight_start": 0.1,
        "contribution": 0.047678
      },
      {
        "sector": "Financial Services",
        "holdings": 1,
        "weight_start": 0.15,
        "contribution": 0.013499
      }
    ],
    "monthly": [
      {
        "month": "2025-11",
        "return": -0.02478,
        "best": {
          "symbol": "AAPL",
          "contribution": 0.005896
        },
        "worst": {
          "symbol": "NVDA",
          "contribution": -0.017337
        }
      },
      {
        "month": "2025-12",
        "return": 0.006244,
        "best": {
          "symbol": "NVDA",
          "contribution": 0.010066
        },
        "worst": {
          "symbol": "AAPL",
          "contribution": -0.007862
        }
      },
      {
        "month": "2026-01",
        "return": -0.024408,
        "best": {
          "symbol": "XOM",
          "contribution": 0.018332
        },
        "worst": {
          "symbol": "MSFT",
          "contribution": -0.026634
        }
      },
      {
        "month": "2026-02",
        "return": -0.02006,
        "best": {
          "symbol": "XOM",
          "contribution": 0.010801
        },
        "worst": {
          "symbol": "MSFT",
          "contribution": -0.01876
        }
      },
      {
        "month": "2026-03",
        "return": -0.014388,
        "best": {
          "symbol": "XOM",
          "contribution": 0.01573
        },
        "worst": {
          "symbol": "AAPL",
          "contribution": -0.012159
        }
      },
      {
        "month": "2026-04",
        "return": 0.065186,
        "best": {
          "symbol": "NVDA",
          "contribution": 0.028092
        },
        "worst": {
          "symbol": "XOM",
          "contribution": -0.014255
        }
      },
      {
        "month": "2026-05",
        "return": 0.06576,
        "best": {
          "symbol": "AAPL",
          "contribution": 0.0457
        },
        "worst": {
          "symbol": "XOM",
          "contribution": -0.007049
        }
      },
      {
        "month": "2026-06",
        "return": -0.065038,
        "best": {
          "symbol": "JPM",
          "contribution": 0.012614
        },
        "worst": {
          "symbol": "MSFT",
          "contribution": -0.036207
        }
      },
      {
        "month": "2026-07",
        "return": 0.09763,
        "best": {
          "symbol": "MSFT",
          "contribution": 0.045991
        },
        "worst": {
          "symbol": "NVDA",
          "contribution": 0.000696
        }
      },
      {
        "month": "2026-08",
        "return": 0.054604,
        "best": {
          "symbol": "MSFT",
          "contribution": 0.019886
        },
        "worst": {
          "symbol": "JPM",
          "contribution": 0.001865
        }
      },
      {
        "month": "2026-09",
        "return": 0.016094,
        "best": {
          "symbol": "AAPL",
          "contribution": 0.015656
        },
        "worst": {
          "symbol": "JPM",
          "contribution": -0.010525
        }
      },
      {
        "month": "2026-10",
        "return": 0.015373,
        "best": {
          "symbol": "XOM",
          "contribution": 0.018489
        },
        "worst": {
          "symbol": "NVDA",
          "contribution": -0.021274
        }
      },
      {
        "month": "2026-11",
        "return": -0.036641,
        "best": {
          "symbol": "AAPL",
          "contribution": 0.010014
        },
        "worst": {
          "symbol": "NVDA",
          "contribution": -0.035753
        }
      }
    ],
    "check_sum_of_contributions": 0.12915,
    "benchmark": {
      "symbol": "SPY",
      "return": 0.115923,
      "active_return": 0.013227
    }
  },
  "meta": {
    "op": "attribution",
    "units": 7,
    "cost_usd": 0.0,
    "billing": "internal",
    "free_call": false,
    "free_calls_left": 0,
    "balance_usd": 5.0,
    "ms": 6,
    "interval": "1day",
    "data_as_of": "2026-11-12",
    "partial_last_bar": false
  }
}

Every response has the same envelope: ok, data and meta (op, units, cost_usd, ms, interval, billing, balance_usd, data_as_of, partial_last_bar). Numbers are decimals (0.05 = 5%), dates ISO, and a value that cannot be computed is null.