Docs / Endpoints
Stress test
POST/v1/stressunits: 3 + 1 per symboldaily
Portfolio return, max drawdown and worst day through historical crises (2008, 2011, 2015, 2018, 2020, 2022, 2023) and your own windows, contributions per holding, plus beta-scaled benchmark shocks.
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
| Field | Type | Default | Description |
|---|---|---|---|
symbolsrequired | array of string | — | 1 to 100 holdings. |
weights | array of number | — | One weight per symbol (negative = short), normalised by gross exposure. Default: equal weight. |
portfolio_value | number | — | Portfolio value, to also express losses in money. |
benchmark | string | "SPY" | Benchmark for window returns and the beta shocks, or null. |
custom_windows | array of object | [] | Extra windows [{name, start_date, end_date}]. Each item: {name, start_date, end_date}. |
include_historical | boolean | true | Run the built-in historical windows (GFC 2008-09, euro 2011, Aug 2015, Q4 2018, COVID 2020, 2022 rate shock, Mar 2023 banks). |
shocks | array of number | [-0.1, -0.2, -0.3] | Hypothetical benchmark moves (-0.2 = -20%) applied through each holding's 1-year beta. |
Example request
How would a 60/40 portfolio have done in past crises? Read the walkthrough →
Request
POST /v1/stress{ "symbols": [ "SPY", "TLT" ], "weights": [ 0.6, 0.4 ], "portfolio_value": 1000000 }
The same call with curl, Python and JavaScript
curl https://clickapis.com/v1/stress \
-H "Authorization: Bearer $CLICKAPIS_KEY" \
-H "Content-Type: application/json" \
-d '{"symbols":["SPY","TLT"],"weights":[0.6,0.4],"portfolio_value":1000000}'import os, requests
r = requests.post(
"https://clickapis.com/v1/stress",
headers={"Authorization": f"Bearer {os.environ['CLICKAPIS_KEY']}"},
json={
"symbols": [
"SPY",
"TLT"
],
"weights": [
0.6,
0.4
],
"portfolio_value": 1000000
},
timeout=60,
)
print(r.json()["data"])const r = await fetch("https://clickapis.com/v1/stress", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.CLICKAPIS_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"symbols": [
"SPY",
"TLT"
],
"weights": [
0.6,
0.4
],
"portfolio_value": 1000000
}),
});
console.log((await r.json()).data);Example response
Response 200 OK
{ "ok": true, "data": { "holdings": [ { "symbol": "SPY", "weight": 0.6, "history_from": "1993-01-29" }, { "symbol": "TLT", "weight": 0.4, "history_from": "2002-07-30" } ], "portfolio_value": 1000000.0, "scenarios": [ { "id": "gfc_2008", "name": "Global financial crisis", "start_date": "2008-09-01", "end_date": "2009-03-09", "kind": "historical", "available": true, "from_close": "2008-08-29", "to_close": "2009-03-09", "trading_days": 130, "return": -0.226226, "max_drawdown": -0.227624, "worst_day": { "date": "2008-10-15", "return": -0.048318 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.463731, "contribution": -0.278238 }, { "symbol": "TLT", "weight": 0.4, "return": 0.130032, "contribution": 0.052013 } ], "missing": [], "pnl": -226225.73, "max_drawdown_value": -227623.86, "benchmark_return": -0.463731 }, { "id": "euro_debt_2011", "name": "Euro debt crisis / US downgrade", "start_date": "2011-07-22", "end_date": "2011-10-03", "kind": "historical", "available": true, "from_close": "2011-07-21", "to_close": "2011-10-03", "trading_days": 51, "return": 0.017064, "max_drawdown": -0.057988, "worst_day": { "date": "2011-08-08", "return": -0.021948 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.178412, "contribution": -0.107047 }, { "symbol": "TLT", "weight": 0.4, "return": 0.310278, "contribution": 0.124111 } ], "missing": [], "pnl": 17063.62, "max_drawdown_value": -57987.53, "benchmark_return": -0.178412 }, { "id": "china_deval_2015", "name": "August 2015 China devaluation", "start_date": "2015-08-17", "end_date": "2015-08-25", "kind": "historical", "available": true, "from_close": "2015-08-14", "to_close": "2015-08-25", "trading_days": 7, "return": -0.062272, "max_drawdown": -0.067112, "worst_day": { "date": "2015-08-24", "return": -0.024641 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.105785, "contribution": -0.063471 }, { "symbol": "TLT", "weight": 0.4, "return": 0.002997, "contribution": 0.001199 } ], "missing": [], "pnl": -62271.99, "max_drawdown_value": -67111.91, "benchmark_return": -0.105785 }, { "id": "q4_2018", "name": "Q4 2018 selloff", "start_date": "2018-09-20", "end_date": "2018-12-24", "kind": "historical", "available": true, "from_close": "2018-09-19", "to_close": "2018-12-24", "trading_days": 66, "return": -0.092097, "max_drawdown": -0.098139, "worst_day": { "date": "2018-10-10", "return": -0.020156 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.18693, "contribution": -0.112158 }, { "symbol": "TLT", "weight": 0.4, "return": 0.050153, "contribution": 0.020061 } ], "missing": [], "pnl": -92097.04, "max_drawdown_value": -98138.57, "benchmark_return": -0.18693 }, { "id": "covid_2020", "name": "COVID crash", "start_date": "2020-02-19", "end_date": "2020-03-23", "kind": "historical", "available": true, "from_close": "2020-02-18", "to_close": "2020-03-23", "trading_days": 24, "return": -0.143511, "max_drawdown": -0.177921, "worst_day": { "date": "2020-03-18", "return": -0.053396 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.333996, "contribution": -0.200397 }, { "symbol": "TLT", "weight": 0.4, "return": 0.142217, "contribution": 0.056887 } ], "missing": [], "pnl": -143510.83, "max_drawdown_value": -177921.09, "benchmark_return": -0.333996 }, { "id": "rate_shock_2022", "name": "2022 rate shock", "start_date": "2022-01-03", "end_date": "2022-10-12", "kind": "historical", "available": true, "from_close": "2021-12-31", "to_close": "2022-10-12", "trading_days": 196, "return": -0.269113, "max_drawdown": -0.269113, "worst_day": { "date": "2022-06-13", "return": -0.035447 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.240585, "contribution": -0.144351 }, { "symbol": "TLT", "weight": 0.4, "return": -0.311904, "contribution": -0.124762 } ], "missing": [], "pnl": -269112.96, "max_drawdown_value": -269112.96, "benchmark_return": -0.240585 }, { "id": "banks_2023", "name": "March 2023 regional banks", "start_date": "2023-03-08", "end_date": "2023-03-15", "kind": "historical", "available": true, "from_close": "2023-03-07", "to_close": "2023-03-15", "trading_days": 6, "return": 0.003669, "max_drawdown": -0.010117, "worst_day": { "date": "2023-03-09", "return": -0.010117 }, "holdings": [ { "symbol": "SPY", "weight": 0.6, "return": -0.022556, "contribution": -0.013534 }, { "symbol": "TLT", "weight": 0.4, "return": 0.043006, "contribution": 0.017202 } ], "missing": [], "pnl": 3668.74, "max_drawdown_value": -10116.59, "benchmark_return": -0.022556 } ], "worst_scenario": { "id": "rate_shock_2022", "name": "2022 rate shock", "return": -0.269113 }, "hypothetical": { "benchmark": "SPY", "beta_window_days": 252, "portfolio_beta": 0.677136, "scenarios": [ { "benchmark_move": -0.1, "portfolio_move": -0.067714, "holdings": [ { "symbol": "SPY", "beta": 1.0, "move": -0.1, "contribution": -0.06 }, { "symbol": "TLT", "beta": 0.192839, "move": -0.019284, "contribution": -0.007714 } ], "pnl": -67713.58 }, { "benchmark_move": -0.2, "portfolio_move": -0.135427, "holdings": [ { "symbol": "SPY", "beta": 1.0, "move": -0.2, "contribution": -0.12 }, { "symbol": "TLT", "beta": 0.192839, "move": -0.038568, "contribution": -0.015427 } ], "pnl": -135427.15 }, { "benchmark_move": -0.3, "portfolio_move": -0.203141, "holdings": [ { "symbol": "SPY", "beta": 1.0, "move": -0.3, "contribution": -0.18 }, { "symbol": "TLT", "beta": 0.192839, "move": -0.057852, "contribution": -0.023141 } ], "pnl": -203140.73 } ], "note": "Linear beta model: holding move = beta x benchmark move. Missing betas assume 1." } }, "meta": { "op": "stress", "units": 5, "cost_usd": 0.0, "billing": "internal", "free_call": false, "free_calls_left": 0, "balance_usd": 5.0, "ms": 9, "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.