Skip to main content
Glama

TradingCalc MCP: Options, Forex, Risk Stats, Prediction Markets, On-Chain & Crypto Futures

Cointegration Test

workflow.run_cointegration
Read-only

Engle-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

NameRequiredDescriptionDefault
xYesSecond price series, same length and dates as y
yYesFirst price series (the dependent variable in the cointegrating regression)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Added

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnly/closedWorld/non-destructive, and the description goes well beyond them: directional regression (y on x), input constraints that raise errors (min 20 values, equal length, one obs per date, zero-variance residuals), and the exact return fields. It also states the directional limitation and disclaims continuation of the relationship.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core question and dense with constraints, but the closing "Returns: alpha, beta, t_stat..." restates the hedge ratio and ADF statistic already described in the first two sentences, so it is slightly redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description fully carries the return contract (alpha, beta, t_stat, critical values, per-level booleans), covers error conditions, and bounds the scope. Nothing an agent needs to call or interpret it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and already labels y as the dependent variable, but the description adds the asymmetry of the test (one direction, Engle-Granger) and the one-observation-per-date constraint that the schema only partly implies. That is real added meaning rather than repetition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names the specific test (Engle-Granger two-step), the input (a pair of price series), and the question it answers (shared long-run equilibrium, stationary spread). It also positions itself against siblings by naming the primitive/related concepts: hedge ratio output, ADF residuals, and explicitly excluding Johansen multi-series tests.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives explicit trigger phrases ("are these two assets cointegrated?", "is this a valid pairs trade?") and an explicit exclusion list (more than two series, structural breaks, time trend, half-life, transaction costs). An agent can decide to use or skip this tool without opening the schema.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.