---
title: "Parity Arbitrage Scanner"
description: "Scan for YES + NO < \$1.00 on the same exchange for guaranteed profit."
icon: "equals"
---

<Note>**Pro Feature.** Requires a Pro or Ultra subscription. [Get started at api.mathematicalcompany.com](https://api.mathematicalcompany.com)</Note>

Scan for parity violations where the YES and NO contracts on the same market sum to less than \$1.00, creating risk-free profit opportunities.

## Full Code

```python
"""Parity arbitrage: buy YES + NO when combined cost < $1.00."""

import horizon as hz
from horizon.context import FeedData


def check_parity(ctx: hz.Context) -> float:
    """Compute the fair value from book feed."""
    book = ctx.feeds.get("polymarket", FeedData())
    return book.price if book.price > 0 else 0.50


# Pipeline scanner detects and auto-executes parity arb
scanner = hz.parity_arb_scanner(
    market_id="election-winner",
    feed_name="polymarket",
    min_edge=0.005,       # minimum 0.5 cent edge
    auto_execute=True,    # submit orders automatically
    cooldown=5.0,         # seconds between executions
)

hz.run(
    name="parity_arb",
    markets=["election-winner"],
    feeds={
        "polymarket": hz.PolymarketBook("election-winner"),
    },
    pipeline=[check_parity, scanner],
    risk=hz.Risk(max_position=200, max_drawdown_pct=2),
    interval=0.5,
    mode="paper",
)
```

## How It Works

1. **`PolymarketBook`** streams live bid/ask for both YES and NO sides
2. **`parity_arb_scanner()`** checks if `best_ask_yes + best_ask_no < 1.00`
3. When a violation is found, it buys both sides to lock in the difference
4. **`auto_execute=True`** submits the orders immediately; set to `False` for alerts only

## One-Shot Sweep

For a quick check without a live loop, use `parity_arb_sweep()`:

```python
"""One-shot parity check on a running engine."""

import horizon as hz

engine = hz.Engine()
engine.start_feed("polymarket", "polymarket_book", config_json='{"condition_id": "election-winner"}')

result = hz.parity_arb_sweep(engine, market_id="election-winner", feed_name="polymarket")
if result:
    print(f"Parity violation: YES ask={result.yes_ask:.4f}, NO ask={result.no_ask:.4f}")
    print(f"Combined cost: ${result.yes_ask + result.no_ask:.4f}")
    print(f"Edge: ${result.edge:.4f} per pair")
else:
    print("No parity violation found")
```

## Run It

```bash
python examples/parity_arb_scanner.py
```

## Dual Scanner

Combine parity scanning with cross-exchange arb for maximum coverage:

```python
scanner = hz.composite_arb(
    methods=[
        hz.ArbMethodConfig(method="parity", market_id="election-winner", feed_name="polymarket"),
        hz.ArbMethodConfig(
            method="cross_exchange",
            market_id="election-winner",
            exchanges=["polymarket", "kalshi"],
            feed_map={"polymarket": "polymarket", "kalshi": "kalshi"},
        ),
    ],
    min_edge=0.005,
    auto_execute=True,
)
```

See [Parity Arbitrage](/arbitrage/parity) for the full method reference.
