ClickAPIs
Docs · Pairs analysis

Docs / Endpoints

Pairs analysis

POST/v1/pairsunits: 5daily

Hedge ratio (static and rolling), spread and z-score, Engle-Granger cointegration with a MacKinnon p-value, half-life, correlation, z-band signals and a no-look-ahead backtest.

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
symbol_arequiredstring—First symbol (the one regressed).
symbol_brequiredstring—Second symbol (the hedge).
start_datedate—First date (YYYY-MM-DD). When given, lookback_days is ignored.
end_datedate—Last date to include (YYYY-MM-DD). Default: the latest bar.
lookback_daysinteger504Most recent common trading days when start_date is not given.
use_logbooleantrueRegress log prices (true) or price levels (false).
hedge_windowinteger60Window of the rolling hedge ratio used by the backtest.
z_windowinteger60Window of the rolling spread z-score.
entry_znumber2.0Open a trade when |z| exceeds this.
exit_znumber0.5Close when z comes back inside +/- this.
stop_znumber4.0Close when |z| exceeds this (null = no stop).
fee_bpsnumber0.0Cost per leg per side in basis points.
max_pointsinteger120Points of the spread / z series to return.

Example request

Are Australia and Canada ETFs a tradable pair? Read the walkthrough →

Request POST /v1/pairs
{
  "symbol_a": "EWA",
  "symbol_b": "EWC"
}
The same call with curl, Python and JavaScript
curl https://clickapis.com/v1/pairs \
  -H "Authorization: Bearer $CLICKAPIS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"symbol_a":"EWA","symbol_b":"EWC"}'
import os, requests

r = requests.post(
    "https://clickapis.com/v1/pairs",
    headers={"Authorization": f"Bearer {os.environ['CLICKAPIS_KEY']}"},
    json={
      "symbol_a": "EWA",
      "symbol_b": "EWC"
    },
    timeout=60,
)
print(r.json()["data"])
const r = await fetch("https://clickapis.com/v1/pairs", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.CLICKAPIS_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "symbol_a": "EWA",
    "symbol_b": "EWC"
  }),
});
console.log((await r.json()).data);

Example response

Response 200 OK
{
  "ok": true,
  "data": {
    "symbol_a": "EWA",
    "symbol_b": "EWC",
    "start": "2024-11-07",
    "end": "2026-11-12",
    "observations": 505,
    "price_transform": "log",
    "hedge_ratio": 0.55469,
    "intercept": 1.097895,
    "r_squared": 0.91,
    "rolling_hedge_ratio": {
      "window": 60,
      "latest": 1.072417,
      "min": -0.442461,
      "max": 1.909426
    },
    "correlation_returns": 0.8094,
    "correlation_prices": 0.9552,
    "cointegration": {
      "test": "Engle-Granger (ADF on OLS residuals, no constant, lags by BIC)",
      "adf_stat": -3.881,
      "lags": 0,
      "p_value": 0.0105,
      "critical_values": {
        "1%": -3.9182,
        "5%": -3.3483,
        "10%": -3.0529
      },
      "cointegrated_5pct": true
    },
    "half_life_bars": 12.73,
    "spread": {
      "latest": 0.004132,
      "mean": 0.0,
      "stdev": 0.026893,
      "z_static": 0.1536,
      "z_rolling": -1.868,
      "z_window": 60
    },
    "bands": {
      "entry_z": 2.0,
      "exit_z": 0.5,
      "stop_z": 4.0,
      "signal_now": "hold",
      "position_now": "long_spread"
    },
    "backtest": {
      "trades": 4,
      "win_rate": 0.5,
      "total_return": 0.001573,
      "avg_trade_return": 0.000961,
      "avg_bars": 54.5,
      "max_drawdown": -0.09565,
      "time_in_market": 0.437624,
      "fee_bps": 0.0,
      "recent_trades": [
        {
          "side": "short_spread",
          "entry_date": "2025-07-18",
          "exit_date": "2025-12-24",
          "entry_z": 2.039,
          "exit_z": 0.373,
          "bars": 111,
          "return": 0.01243
        },
        {
          "side": "long_spread",
          "entry_date": "2026-01-27",
          "exit_date": "2026-03-31",
          "entry_z": -2.133,
          "exit_z": -0.488,
          "bars": 44,
          "return": 0.017761
        },
        {
          "side": "short_spread",
          "entry_date": "2026-06-25",
          "exit_date": "2026-07-27",
          "entry_z": 2.214,
          "exit_z": 0.488,
          "bars": 21,
          "return": -0.01659
        },
        {
          "side": "long_spread",
          "entry_date": "2026-08-07",
          "exit_date": "2026-10-07",
          "entry_z": -2.007,
          "exit_z": -0.486,
          "bars": 42,
          "return": -0.009758
        }
      ]
    },
    "series": [
      {
        "date": "2026-05-26",
        "spread": -0.002528,
        "z_rolling": 1.404247,
        "hedge_ratio": 0.850991
      },
      {
        "date": "2026-05-27",
        "spread": 0.000869,
        "z_rolling": 1.414786,
        "hedge_ratio": 0.831547
      },
      {
        "date": "2026-05-28",
        "spread": -0.000783,
        "z_rolling": 1.408536,
        "hedge_ratio": 0.816178
      },
      {
        "date": "2026-05-29",
        "spread": 0.006535,
        "z_rolling": 1.403204,
        "hedge_ratio": 0.803379
      },
      {
        "date": "2026-06-01",
        "spread": 0.003662,
        "z_rolling": 1.388229,
        "hedge_ratio": 0.792263
      },
      {
        "date": "2026-06-02",
        "spread": 0.008008,
        "z_rolling": 1.392515,
        "hedge_ratio": 0.776505
      },
      {
        "date": "2026-06-03",
        "spread": 0.004579,
        "z_rolling": 1.37762,
        "hedge_ratio": 0.768183
      },
      {
        "date": "2026-06-04",
        "spread": -0.006176,
        "z_rolling": 1.396407,
        "hedge_ratio": 0.746627
      },
      {
        "date": "2026-06-05",
        "spread": -0.027534,
        "z_rolling": 1.389131,
        "hedge_ratio": 0.734002
      },
      {
        "date": "2026-06-08",
        "spread": -0.027461,
        "z_rolling": 1.4046,
        "hedge_ratio": 0.719573
      },
      {
        "date": "2026-06-09",
        "spread": -0.020691,
        "z_rolling": 1.430522,
        "hedge_ratio": 0.704846
      },
      {
        "date": "2026-06-10",
        "spread": -0.020125,
        "z_rolling": 1.422147,
        "hedge_ratio": 0.702309
      },
      {
        "date": "2026-06-11",
        "spread": -0.000276,
        "z_rolling": 1.437159,
        "hedge_ratio": 0.700246
      },
      {
        "date": "2026-06-12",
        "spread": 0.006315,
        "z_rolling": 1.461345,
        "hedge_ratio": 0.695219
      },
      {
        "date": "2026-06-15",
        "spread": -0.0056,
        "z_rolling": 1.420405,
        "hedge_ratio": 0.701617
      },
      {
        "date": "2026-06-16",
        "spread": 0.005908,
        "z_rolling": 1.473236,
        "hedge_ratio": 0.686088
      },
      {
        "date": "2026-06-17",
        "spread": 0.003156,
        "z_rolling": 1.41213,
        "hedge_ratio": 0.696083
      },
      {
        "date": "2026-06-18",
        "spread": 0.003069,
        "z_rolling": 1.44828,
        "hedge_ratio": 0.681976
      },
      {
        "date": "2026-06-22",
        "spread": -0.000982,
        "z_rolling": 1.475372,
        "hedge_ratio": 0.669295
      },
      {
        "date": "2026-06-23",
        "spread": -0.0141,
        "z_rolling": 1.637333,
        "hedge_ratio": 0.62171
      },
      {
        "date": "2026-06-24",
        "spread": -0.014366,
        "z_rolling": 1.834301,
        "hedge_ratio": 0.566373
      },
      {
        "date": "2026-06-25",
        "spread": -0.016836,
        "z_rolling": 2.213861,
        "hedge_ratio": 0.459907
      },
      {
        "date": "2026-06-26",
        "spread": -0.017135,
        "z_rolling": 2.454535,
        "hedge_ratio": 0.375908
      },
      {
        "date": "2026-06-29",
        "spread": -0.009159,
        "z_rolling": 2.563681,
        "hedge_ratio": 0.316546
      },
      {
        "date": "2026-06-30",
        "spread": -0.008827,
        "z_rolling": 2.738835,
        "hedge_ratio": 0.228474
      },
      {
        "date": "2026-07-01",
        "spread": -0.025586,
        "z_rolling": 2.900525,
        "hedge_ratio": 0.123744
      },
      {
        "date": "2026-07-02",
        "spread": -0.012565,
        "z_rolling": 2.974327,
        "hedge_ratio": 0.036214
      },
      {
        "date": "2026-07-06",
        "spread": -0.006835,
        "z_rolling": 2.58385,
        "hedge_ratio": 0.095243
      },
      {
        "date": "2026-07-07",
        "spread": -0.016779,
        "z_rolling": 2.064927,
        "hedge_ratio": 0.214027
      },
      {
        "date": "2026-07-08",
        "spread": -0.013415,
        "z_rolling": 1.458264,
        "hedge_ratio": 0.379888
      },
      {
        "date": "2026-07-09",
        "spread": -0.014483,
        "z_rolling": 0.994659,
        "hedge_ratio": 0.508687
      },
      {
        "date": "2026-07-10",
        "spread": -0.008217,
        "z_rolling": 0.780847,
        "hedge_ratio": 0.565289
      },
      {
        "date": "2026-07-13",
        "spread": -0.012494,
        "z_rolling": 0.795386,
        "hedge_ratio": 0.552104
      },
      {
        "date": "2026-07-14",
        "spread": -0.004109,
        "z_rolling": 0.753996,
        "hedge_ratio": 0.558292
      },
      {
        "date": "2026-07-15",
        "spread": -0.003878,
        "z_rolling": 0.920423,
        "hedge_ratio": 0.503198
      },
      {
        "date": "2026-07-16",
        "spread": -0.008865,
        "z_rolling": 1.158808,
        "hedge_ratio": 0.425404
      },
      {
        "date": "2026-07-17",
        "spread": -0.005242,
        "z_rolling": 1.050197,
        "hedge_ratio": 0.447071
      },
      {
        "date": "2026-07-20",
        "spread": -0.005475,
        "z_rolling": 0.971191,
        "hedge_ratio": 0.459704
      },
      {
        "date": "2026-07-21",
        "spread": -0.003935,
        "z_rolling": 0.878045,
        "hedge_ratio": 0.477624
      },
      {
        "date": "2026-07-22",
        "spread": 0.000165,
        "z_rolling": 0.775701,
        "hedge_ratio": 0.49887
      },
      {
        "date": "2026-07-23",
        "spread": -0.008417,
        "z_rolling": 0.728476,
        "hedge_ratio": 0.502103
      },
      {
        "date": "2026-07-24",
        "spread": -0.002729,
        "z_rolling": 0.587754,
        "hedge_ratio": 0.534024
      },
      {
        "date": "2026-07-27",
        "spread": -0.00017,
        "z_rolling": 0.487518,
        "hedge_ratio": 0.554348
      },
      {
        "date": "2026-07-28",
        "spread": 0.010763,
        "z_rolling": 0.316322,
        "hedge_ratio": 0.594733
      },
      {
        "date": "2026-07-29",
        "spread": 0.008697,
        "z_rolling": 0.190943,
        "hedge_ratio": 0.620111
      },
      {
        "date": "2026-07-30",
        "spread": 0.028136,
        "z_rolling": -0.18015,
        "hedge_ratio": 0.711094
      },
      {
        "date": "2026-07-31",
        "spread": 0.015632,
        "z_rolling": -0.475239,
        "hedge_ratio": 0.775203
      },
      {
        "date": "2026-08-03",
        "spread": 0.015252,
        "z_rolling": -0.761664,
        "hedge_ratio": 0.839162
      },
      {
        "date": "2026-08-04",
        "spread": 0.036201,
        "z_rolling": -1.295491,
        "hedge_ratio": 0.969374
      },
      {
        "date": "2026-08-05",
        "spread": 0.029701,
        "z_rolling": -1.635686,
        "hedge_ratio": 1.050346
      },
      {
        "date": "2026-08-06",
        "spread": 0.031095,
        "z_rolling": -1.887772,
        "hedge_ratio": 1.118973
      },
      {
        "date": "2026-08-07",
        "spread": 0.033207,
        "z_rolling": -2.007095,
        "hedge_ratio": 1.1591
      },
      {
        "date": "2026-08-10",
        "spread": 0.020178,
        "z_rolling": -1.994237,
        "hedge_ratio": 1.164899
      },
      {
        "date": "2026-08-11",
        "spread": 0.016754,
        "z_rolling": -1.899508,
        "hedge_ratio": 1.151766
      },
      {
        "date": "2026-08-12",
        "spread": 0.012409,
        "z_rolling": -1.796526,
        "hedge_ratio": 1.133735
      },
      {
        "date": "2026-08-13",
        "spread": 0.004423,
        "z_rolling": -1.617793,
        "hedge_ratio": 1.091924
      },
      {
        "date": "2026-08-14",
        "spread": 0.000232,
        "z_rolling": -1.408091,
        "hedge_ratio": 1.039888
      },
      {
        "date": "2026-08-17",
        "spread": -0.0027,
        "z_rolling": -1.215719,
        "hedge_ratio": 0.990946
      },
      {
        "date": "2026-08-18",
        "spread": 0.004706,
        "z_rolling": -1.132818,
        "hedge_ratio": 0.974182
      },
      {
        "date": "2026-08-19",
        "spread": 0.014544,
        "z_rolling": -1.090962,
        "hedge_ratio": 0.967989
      },
      {
        "date": "2026-08-20",
        "spread": 0.007715,
        "z_rolling": -1.037477,
        "hedge_ratio": 0.955518
      },
      {
        "date": "2026-08-21",
        "spread": 0.015466,
        "z_rolling": -1.009579,
        "hedge_ratio": 0.952704
      },
      {
        "date": "2026-08-24",
        "spread": 0.014947,
        "z_rolling": -0.983645,
        "hedge_ratio": 0.949856
      },
      {
        "date": "2026-08-25",
        "spread": 0.022556,
        "z_rolling": -0.980389,
        "hedge_ratio": 0.95432
      },
      {
        "date": "2026-08-26",
        "spread": 0.016955,
        "z_rolling": -0.969344,
        "hedge_ratio": 0.955131
      },
      {
        "date": "2026-08-27",
        "spread": 0.01536,
        "z_rolling": -0.941227,
        "hedge_ratio": 0.951684
      },
      {
        "date": "2026-08-28",
        "spread": 0.016442,
        "z_rolling": -0.938151,
        "hedge_ratio": 0.956886
      },
      {
        "date": "2026-08-31",
        "spread": 0.019811,
        "z_rolling": -0.92622,
        "hedge_ratio": 0.960178
      },
      {
        "date": "2026-09-01",
        "spread": 0.015966,
        "z_rolling": -0.875863,
        "hedge_ratio": 0.951457
      },
      {
        "date": "2026-09-02",
        "spread": 0.021591,
        "z_rolling": -0.831468,
        "hedge_ratio": 0.94417
      },
      {
        "date": "2026-09-03",
        "spread": 0.02209,
        "z_rolling": -0.795078,
        "hedge_ratio": 0.937127
      },
      {
        "date": "2026-09-04",
        "spread": 0.021301,
        "z_rolling": -0.757877,
        "hedge_ratio": 0.93173
      },
      {
        "date": "2026-09-08",
        "spread": 0.018603,
        "z_rolling": -0.75869,
        "hedge_ratio": 0.937116
      },
      {
        "date": "2026-09-09",
        "spread": 0.010384,
        "z_rolling": -0.761776,
        "hedge_ratio": 0.941993
      },
      {
        "date": "2026-09-10",
        "spread": -0.001612,
        "z_rolling": -0.741827,
        "hedge_ratio": 0.93932
      },
      {
        "date": "2026-09-11",
        "spread": 0.002239,
        "z_rolling": -0.723766,
        "hedge_ratio": 0.939704
      },
      {
        "date": "2026-09-14",
        "spread": -0.004229,
        "z_rolling": -0.725768,
        "hedge_ratio": 0.94398
      },
      {
        "date": "2026-09-15",
        "spread": -0.008167,
        "z_rolling": -0.73925,
        "hedge_ratio": 0.952904
      },
      {
        "date": "2026-09-16",
        "spread": -0.018139,
        "z_rolling": -0.757006,
        "hedge_ratio": 0.962447
      },
      {
        "date": "2026-09-17",
        "spread": -0.000997,
        "z_rolling": -0.715964,
        "hedge_ratio": 0.959732
      },
      {
        "date": "2026-09-18",
        "spread": -0.01238,
        "z_rolling": -0.702647,
        "hedge_ratio": 0.960103
      },
      {
        "date": "2026-09-21",
        "spread": -0.004275,
        "z_rolling": -0.653736,
        "hedge_ratio": 0.95441
      },
      {
        "date": "2026-09-22",
        "spread": -0.005575,
        "z_rolling": -0.598299,
        "hedge_ratio": 0.944487
      },
      {
        "date": "2026-09-23",
        "spread": -0.020763,
        "z_rolling": -0.624489,
        "hedge_ratio": 0.957895
      },
      {
        "date": "2026-09-24",
        "spread": -0.020571,
        "z_rolling": -0.65405,
        "hedge_ratio": 0.974126
      },
      {
        "date": "2026-09-25",
        "spread": -0.01774,
        "z_rolling": -0.594634,
        "hedge_ratio": 0.964056
      },
      {
        "date": "2026-09-28",
        "spread": -0.010419,
        "z_rolling": -0.590811,
        "hedge_ratio": 0.970235
      },
      {
        "date": "2026-09-29",
        "spread": -0.013674,
        "z_rolling": -0.637629,
        "hedge_ratio": 0.985004
      },
      {
        "date": "2026-09-30",
        "spread": -0.01059,
        "z_rolling": -0.577152,
        "hedge_ratio": 0.977167
      },
      {
        "date": "2026-10-01",
        "spread": -0.021007,
        "z_rolling": -0.624629,
        "hedge_ratio": 0.990526
      },
      {
        "date": "2026-10-02",
        "spread": -0.013458,
        "z_rolling": -0.597571,
        "hedge_ratio": 0.991244
      },
      {
        "date": "2026-10-05",
        "spread": -0.010148,
        "z_rolling": -0.583771,
        "hedge_ratio": 0.994356
      },
      {
        "date": "2026-10-06",
        "spread": -0.009698,
        "z_rolling": -0.556872,
        "hedge_ratio": 0.99342
      },
      {
        "date": "2026-10-07",
        "spread": -0.009224,
        "z_rolling": -0.485779,
        "hedge_ratio": 0.986555
      },
      {
        "date": "2026-10-08",
        "spread": -0.01285,
        "z_rolling": -0.47705,
        "hedge_ratio": 0.98837
      },
      {
        "date": "2026-10-09",
        "spread": -0.005841,
        "z_rolling": -0.431619,
        "hedge_ratio": 0.985112
      },
      {
        "date": "2026-10-12",
        "spread": -0.008029,
        "z_rolling": -0.420935,
        "hedge_ratio": 0.986656
      },
      {
        "date": "2026-10-13",
        "spread": -0.008822,
        "z_rolling": -0.437751,
        "hedge_ratio": 0.992806
      },
      {
        "date": "2026-10-14",
        "spread": -0.010798,
        "z_rolling": -0.448067,
        "hedge_ratio": 0.998995
      },
      {
        "date": "2026-10-15",
        "spread": -0.011308,
        "z_rolling": -0.465852,
        "hedge_ratio": 1.002869
      },
      {
        "date": "2026-10-16",
        "spread": -0.016382,
        "z_rolling": -0.440064,
        "hedge_ratio": 1.00056
      },
      {
        "date": "2026-10-19",
        "spread": -0.010154,
        "z_rolling": -0.443636,
        "hedge_ratio": 1.005526
      },
      {
        "date": "2026-10-20",
        "spread": -0.004518,
        "z_rolling": -0.425202,
        "hedge_ratio": 1.005786
      },
      {
        "date": "2026-10-21",
        "spread": -0.005863,
        "z_rolling": -0.387481,
        "hedge_ratio": 1.002871
      },
      {
        "date": "2026-10-22",
        "spread": -0.01135,
        "z_rolling": -0.477859,
        "hedge_ratio": 1.010428
      },
      {
        "date": "2026-10-23",
        "spread": -0.003905,
        "z_rolling": -0.66173,
        "hedge_ratio": 1.025783
      },
      {
        "date": "2026-10-26",
        "spread": -0.003741,
        "z_rolling": -0.936661,
        "hedge_ratio": 1.04256
      },
      {
        "date": "2026-10-27",
        "spread": 0.005101,
        "z_rolling": -1.126286,
        "hedge_ratio": 1.056036
      },
      {
        "date": "2026-10-28",
        "spread": 0.004662,
        "z_rolling": -1.345846,
        "hedge_ratio": 1.070264
      },
      {
        "date": "2026-10-29",
        "spread": 0.005832,
        "z_rolling": -1.248065,
        "hedge_ratio": 1.065801
      },
      {
        "date": "2026-10-30",
        "spread": 0.011055,
        "z_rolling": -1.214311,
        "hedge_ratio": 1.064478
      },
      {
        "date": "2026-11-02",
        "spread": 0.005406,
        "z_rolling": -1.139712,
        "hedge_ratio": 1.052891
      },
      {
        "date": "2026-11-03",
        "spread": -0.000875,
        "z_rolling": -1.116951,
        "hedge_ratio": 1.044459
      },
      {
        "date": "2026-11-04",
        "spread": 0.010777,
        "z_rolling": -1.161058,
        "hedge_ratio": 1.039476
      },
      {
        "date": "2026-11-05",
        "spread": 0.005322,
        "z_rolling": -1.13296,
        "hedge_ratio": 1.034032
      },
      {
        "date": "2026-11-06",
        "spread": 0.004708,
        "z_rolling": -1.29324,
        "hedge_ratio": 1.037236
      },
      {
        "date": "2026-11-09",
        "spread": 0.012162,
        "z_rolling": -1.760396,
        "hedge_ratio": 1.055641
      },
      {
        "date": "2026-11-10",
        "spread": 0.009672,
        "z_rolling": -2.092606,
        "hedge_ratio": 1.073788
      },
      {
        "date": "2026-11-11",
        "spread": 0.007587,
        "z_rolling": -2.085751,
        "hedge_ratio": 1.077559
      },
      {
        "date": "2026-11-12",
        "spread": 0.004132,
        "z_rolling": -1.867984,
        "hedge_ratio": 1.072417
      }
    ],
    "notes": [
      "long_spread = long symbol_a, short hedge_ratio x symbol_b (equal gross: P&L / (1 + |hedge|)).",
      "Backtest uses the trailing hedge ratio and trailing z (no look-ahead); entry at the close where |z| > entry_z, exit when z crosses back inside exit_z or beyond stop_z.",
      "Cointegration p-value: MacKinnon (1994) response surface, 2 variables, constant."
    ]
  },
  "meta": {
    "op": "pairs",
    "units": 5,
    "cost_usd": 0.0,
    "billing": "internal",
    "free_call": false,
    "free_calls_left": 0,
    "balance_usd": 5.0,
    "ms": 11,
    "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.