Cointegration Test
workflow.run_cointegrationEngle-Granger two-step cointegration test for a pair of price series: do they share a long-run equilibrium relationship (their spread is stationary/mean-reverting)? The standard pairs-trading signal test. Returns the cointegrating regression's hedge ratio (beta) and an ADF t-statistic on the residuals, compared against 1%/5%/10% critical values. Edge cases: x and y each at least 20 values and the same length, one observation per date (otherwise an error); constant residuals (zero variance) are an error; the test is one direction (y regressed on x), Engle-Granger. Not covered: more than two series (Johansen), structural breaks, a time trend in the regression, half-life of the spread, transaction costs, and any claim that the relation continues. Use when user asks "are these two assets cointegrated?" or "is this a valid pairs trade?". Returns: alpha, beta (hedge ratio), t_stat, critical_values, cointegrated (booleans at each significance level).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"y": "<y>",
"x": "<x>"
},
"name": "workflow.run_cointegration"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | Second price series, same length and dates as y | |
| y | Yes | First price series (the dependent variable in the cointegrating regression) |