Beta¶
Calculates the beta of each security in the portfolio relative to a reference index. Beta measures the sensitivity of a security's returns to movements in the benchmark index.
HTTP Request
POST /calculations/beta
HTTP Parameters
| Parameter | Description |
|---|---|
portfolio_id string |
optional The ID of an existing portfolio. When provided, the calculation uses the portfolio's securities, date, base currency, and NLV. The securities parameter is no longer required. |
securities array |
REQUIRED * An array of objects describing the securities in the portfolio. Each object includes a unique id, symbol, quantity, and label. For more details click here. * Not required if portfolio_id is provided. |
date string date |
optional, default is null (today) Portfolio date in the format: YYYYMMDD. |
base_currency string |
optional, default is USD 3-letter ISO 4217 currency code. |
nlv float |
optional, default is null (calculated) Net liquidating value (NAV) of the portfolio. |
index_symbol string |
optional, default is SPY The symbol of the reference index used to compute beta (e.g. SPY, IND:SPX). |
n_days integer |
optional, default is 252 Number of business days of history used when computing beta with daily returns (weekly is False). Accepts 1 to 100000. |
n_weeks integer |
optional, default is 104 Number of weeks of history used when computing beta with weekly returns (weekly is True). Accepts 1 to 100000. |
weekly boolean |
optional, default is False If True, beta is computed using weekly returns; otherwise daily returns are used. |
port_beta boolean |
optional, default is False If True, also computes the portfolio-level beta in addition to per-security betas. |
inverted_beta boolean |
optional, default is False If True, the API divides the covariance by the variance of the security instead of the variance of the index. The result is the beta of the index relative to the security. It is not 1 / beta. |
model string |
optional, default is v1 The calculation engine: v1 or v2. See Calculation model. |
To calculate the beta, run the following:
curl https://api.everysk.com/v2/calculations/beta \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <ACCESS_TOKEN>" \
-d '{
"securities": [
{
"id": "id1",
"symbol": "AAPL",
"quantity": 1.0
}
],
"date": "20250124",
"base_currency": "USD",
"index_symbol": "IND:SPX",
"n_days": 252,
"n_weeks": 200,
"weekly": false,
"port_beta": true
}' \
-X POST
The above call returns the following JSON object:
{
"beta": {
"results": {
"beta": {
"id1": 0.9210
},
"port_beta": 0.9210
}
},
"unmapped_tickers": []
}
On this calculation, unmapped_tickers is at the top level of the response, not inside beta.