
arbitrage-anyprice
io.github.pjrpjr/arbitrage-anyprice
Read-only prediction-market firewall, GPU-vs-LLM compute arbitrage, and SHA-256 ledger analytics.
Documentation
Arbitrage-AnyPrice
Cross-Market Real-Time Pricing Inefficiency, GPU-vs-LLM Token Compute Arbitrage & Prediction-Market Resolution-Rule Firewall Terminal.
Strictly Zero-Custody & Read-Only Posture (MM-04): Pure read-only quantitative market-data analytics, resolution-rule equivalence auditing, and signed JSON/MCP/x402 feeds.
$0client capital custodied, zero automated trading on restricted venues, and zero individualized investment advice.
Why Arbitrage-AnyPrice Exists
Retail arbitrage scanners fail in production because they compare top-of-book midpoints across Polymarket and Kalshi without auditing settlement clauses, ignore Kalshi quadratic fees and FRED risk-free capital lockup carry, or claim "90% GPU compute savings" using VRAM-OOM or 100%-utilization fantasies.
Arbitrage-AnyPrice unifies three live public pricing arenas inside one deterministic, cryptographically hash-chained SQLite WAL terminal:
- Prediction & Event Markets (
>= 2,300live contracts) — Polymarket Gamma + sorted CLOB L2 books (feesEnabledmodeled), Kalshi Trade API v2 non-MVE series &orderbook_fpL2 books, plus Manifold (MANA_PLAY) and Metaculus (POINTS_PLAY) strictly quarantined as non-cash calibration feeds. - AI Compute & Token Markets (
468OpenRouter LLMs +500+live GPU offers) — Vast.ai spot GPU slices, stock-verified RunPod GraphQL, and Azure Retail Prices On-Demand baselines compared against open-weight OpenRouter per-1M-token pricing under hard VRAM physics (weights + 25% KV cache + >=2.5 GB/GPU CUDA/NCCL),<= 70%realistic utilization ceiling,3:1input:output token mix,1 / reliabilitypreemption haircut, and sublinear PCIe vs NVLink tensor-parallel scaling. - FX, Macro Carry & Digital-Asset Valuation — Frankfurter ECB FX rates, live FRED DFF / NY Fed EFFR risk-free carry (
3.89%), CoinGecko/Kraken/Coinbase executable bid/ask spot quotes, and ICANN RDAP domain expiry metadata.
Core Anti-Phantom Architecture
- Fail-Closed Resolution-Rule Equivalence Firewall: Blocks divergent oracles (e.g., Binance BTC/USDT vs CF Benchmarks BRTI), asymmetric macro definitions (e.g., BEA-only vs BEA-or-NBER recession), UTC cutoff/timezone gaps (
> 15 min), boundary mismatches (>vs>=, intraday touch vs close), one-sided 50-50 void clauses, subjective UMA vs statutory agency rules, inverted polarity/negation traps, play-money conflation, and non-exhaustive Dutch-books. - Depth-Weighted Marginal Book Walk & FRED Carry Gate: Walks sorted opposing orderbooks level-by-level, stops strictly before negative-EV marginal L2 depth, caps executable size at
min(depth_A, depth_B), deducts exact Kalshi quadraticceil_cents(0.07 * N * p * (1 - p))+ Polymarket active taker fees + compound FRED DFF / EFFR lockup carry (days_to_expiry + 2d settlement lag), and rejectsNaN/infinputs fail-closed. - Deep Row-Level SHA-256 SQLite WAL Ledger: Every polling cycle chains
prev_sha256 -> snapshot_sha256across all persisted tables;verify_hash_chain()recomputes every run's canonical content digest directly from stored SQLite rows to detect silent row tampering.
Quickstart
uv venv --python 3.12 .venv
uv pip install --python .venv/bin/python -e ".[dev]"
# 1. Run full test suite (64+ deterministic core + hostile red-team tests, 0 warnings)
.venv/bin/pytest -v -W error
# 2. Run a live multi-venue ingestion cycle into data/ledger.sqlite3
.venv/bin/python scripts/run_collector.py --once
# 3. Launch the read-only FastAPI terminal + MCP HTTP + x402 API
.venv/bin/python scripts/run_server.py --host 127.0.0.1 --port 8787
Independent Verification (Zero Dependencies)
Any independent quant or AI-infrastructure engineer can audit the exported report, SHA-256 manifest checksums, deep SQLite hash chain, and zero-phantom invariants using Python stdlib only:
python3 scripts/verify_report.py
# Or verify published report checksums without the local SQLite database:
python3 scripts/verify_report.py --manifest-only
MCP Server (Stdio & HTTP JSON-RPC 2.0)
Expose 6 strictly read-only quantitative tools to Claude Desktop, Cursor, or autonomous compute routers:
get_verified_spreadsget_quarantined_trapsget_backtest_summaryaudit_resolution_equivalencecalculate_gpu_vs_api_arbitrageverify_ledger_integrity
Stdio MCP client config:
{
"mcpServers": {
"arbitrage-anyprice": {
"command": "arbitrage-anyprice-mcp",
"args": ["--db", "data/ledger.sqlite3"]
}
}
}
HTTP MCP endpoint: POST /mcp (JSON-RPC 2.0 initialize, tools/list, tools/call).
x402 Base Mainnet USDC & Creem Subscription API
- x402 Pay-Per-Query (
$0.01 USDCon Base):GET /api/v1/x402/spreadsandGET /api/v1/x402/backtestreturn anx402Version: 1HTTP 402manifest when unauthenticated, and verify real Base mainneteth_getTransactionReceiptUSDCTransferlogs (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913,status=0x1, exactX402_PAY_TO_ADDRESS,>= 10000units) with atomic SQLite replay protection. - Subscription Plans (
GET /api/v1/billing/plans) (strictly zero-custody read-only analytics via Creem):- Starter / Independent (
$99/mo): Subscribe via Creem - Pro Quant API & Backtester (
$299/mo): Subscribe via Creem - Institutional Terminal Seat (
$995/mo): Subscribe via Creem - Automated fulfillment webhook (
POST /api/v1/billing/creem/webhook) enforces constant-time HMAC-SHA256 verification and fails closed (HTTP 503) whenCREEM_API_KEY/CREEM_WEBHOOK_SECRETare unset.
- Starter / Independent (
License
MIT License — see LICENSE.
ghcr.io/pjrpjr/arbitrage-anyprice:0.2.0docker pull ghcr.io/pjrpjr/arbitrage-anyprice:0.2.0:undefined