cross-asset-arbitrage-engine

cross-asset-arbitrage-engine is a skill for Claude Code from mahmoud20138/Tradecraft. It costs 106 tokens per session (1,231 once invoked), scanned A, original, MIT.

A toolkit for finding arbitrage opportunities, where related instruments may be temporarily priced inconsistently, using methods such as pairs, triangular, basis, and statistical arbitrage.

In plain words
What is it for?
It helps test cointegration, calculate a hedge ratio, examine whether a price spread is stationary, and assess whether a pairs trade may be viable.
Why use it?
It tests whether two price series move together in a stable way before treating their difference as a possible mean-reverting trade.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the tradecraft plugin — 58 skills shipped together

Good fit It helps test cointegration, calculate a hedge ratio, examine whether a price spread is stationary, and assess whether a pairs trade may be viable.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mahmoud20138/Tradecraft --skill cross-asset-arbitrage-engine
Clone the repo
git clone --depth 1 https://github.com/mahmoud20138/Tradecraft

Made for: Claude Code.

Or install tradecraft, the plugin that ships this one along with the rest of its 58 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for cross-asset-arbitrage-engine

README.md
[![agentmods](https://agentmods.dev/badge/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine/github.svg)](https://agentmods.dev/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine)
Your own site
<a href="https://agentmods.dev/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine"><img src="https://agentmods.dev/badge/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for cross-asset-arbitrage-engine

Your own site · 80×15
<a href="https://agentmods.dev/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine"><img src="https://agentmods.dev/badge/skills/mahmoud20138/tradecraft/cross-asset-arbitrage-engine.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 106 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,231 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00106 $0.01231
Opus 5 $0.00053 $0.00616
Sonnet 5 $0.00021 $0.00246
Haiku 4.5 $0.00011 $0.00123

Measured 12d ago against content hash 129c9d8461f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

cross-asset-arbitrage-engine scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/tradecraft/skills/cross-asset-arbitrage-engine/SKILL.md · 112 lines

What it actually says

Cross-Asset Arbitrage Engine

import numpy as np
import pandas as pd
from statsmodels.tsa.stattools import coint, adfuller

class ArbitrageEngine:

    @staticmethod
    def cointegration_test(series_a: pd.Series, series_b: pd.Series) -> dict:
        """Test if two series are cointegrated (mean-reverting spread)."""
        score, pvalue, _ = coint(series_a.dropna(), series_b.dropna())
        return {
            "cointegrated": pvalue < 0.05,
            "p_value": round(pvalue, 4),
            "test_stat": round(score, 4),
            "signal": "COINTEGRATED — pairs trade viable" if pvalue < 0.05 else "NOT cointegrated — avoid pairs trade",
        }

    @staticmethod
    def hedge_ratio(series_a: pd.Series, series_b: pd.Series) -> dict:
        """OLS hedge ratio for pairs trade construction."""
        from numpy.polynomial.polynomial import polyfit
        b, a = np.polyfit(series_b, series_a, 1)
        spread = series_a - b * series_b
        adf_stat, adf_p, *_ = adfuller(spread.dropna())
        return {
            "hedge_ratio": round(b, 6),
            "intercept": round(a, 6),
            "spread_stationary": adf_p < 0.05,
            "spread_adf_p": round(adf_p, 4),
            "entry_rule": f"Buy A, sell {abs(b):.4f} B when z-score < -2. Reverse when z-score > 2.",
        }

    @staticmethod
    def triangular_arb_check(rates: dict) -> dict:
        """
        Check for triangular arbitrage opportunity.
        rates: {"EURUSD": 1.0850, "GBPUSD": 1.2650, "EURGBP": 0.8570}
        """
        try:
            eurusd = rates["EURUSD"]
            gbpusd = rates["GBPUSD"]
            eurgbp = rates["EURGBP"]
            # Path 1: USD → EUR → GBP → USD
            implied_eurgbp = eurusd / gbpusd
            arb_1 = (implied_eurgbp / eurgbp - 1) * 10000  # in pips
            # Path 2: USD → GBP → EUR → USD
            implied_eurusd = eurgbp * gbpusd
            arb_2 = (implied_eurusd / eurusd - 1) * 10000
            return {
                "implied_eurgbp": round(implied_eurgbp, 5),
                "actual_eurgbp": eurgbp,
                "arb_pips": round(arb_1, 1),
                "opportunity": abs(arb_1) > 2,
                "direction": "Buy EURGBP" if arb_1 < -2 else "Sell EURGBP" if arb_1 > 2 else "No arb",
                "note": "Account for spread + execution latency. Sub-2pip arbs rarely executable.",
            }
        except KeyError:
            return {"error": "Need EURUSD, GBPUSD, EURGBP rates"}

    @staticmethod
    def spread_z_score_signals(spread: pd.Series, window: int = 60,
                                entry_z: float = 2.0, exit_z: float = 0.5) -> pd.DataFrame:
        """Generate entry/exit signals from spread z-score."""
        mean = spread.rolling(window).mean()
        std = spread.rolling(window).std()
        z = (spread - mean) / std.replace(0, np.nan)
        signals = pd.DataFrame(index=spread.index)
        signals["z_score"] = z
        signals["signal"] = 0
        signals.loc[z < -entry_z, "signal"] = 1   # Buy spread
        signals.loc[z > entry_z, "signal"] = -1    # Sell spread
        signals.loc[z.abs() < exit_z, "signal"] = 0  # Exit
        return signals

    @staticmethod
    def scan_cointegrated_pairs(prices: pd.DataFrame, max_pvalue: float = 0.05) -> list[dict]:
        """Scan all pair combinations for cointegration."""
        symbols = prices.columns.tolist()
        results = []
        for i, a in enumerate(symbols):
            for b in symbols[i+1:]:
                try:
                    test = ArbitrageEngine.cointegration_test(prices[a], prices[b])
                    if test["cointegrated"]:
                        hr = ArbitrageEngine.hedge_ratio(prices[a], prices[b])
                        results.append({"pair": f"{a}/{b}", **test, **hr})
                except: continue
        return sorted(results, key=lambda x: x["p_value"])

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 112 lines · 106 tokens per session scan A 129c9d8461f9

Subscribe to this mod's changes

cross-asset-arbitrage-engine is a skill published in the GitHub repository mahmoud20138/Tradecraft (15 stars, last pushed 4mo ago), licensed MIT. It adds 106 tokens to every session and 1,231 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.