---
title: "MM Arb"
description: "Quote on one exchange and hedge on another for delta-neutral spread capture."
icon: "scale-balanced"
---

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

# Market-Making Arbitrage

Quote on one exchange (earn the bid-ask spread), hedge on another exchange (neutralize directional risk). Combines Avellaneda-Stoikov market making with cross-venue delta hedging.

## How It Works

1. Generate quotes on the **quoting exchange** using Avellaneda-Stoikov (reservation price + optimal spread)
2. Track net position (delta) from fills
3. When `|delta| > hedge_threshold`: submit aggressive FOK orders on the **hedge exchange**
4. Result: you earn the spread on exchange A while staying delta-neutral via exchange B

## MMArbConfig

```python
config = hz.MMArbConfig(
    quote_exchange="polymarket",
    hedge_exchange="kalshi",
    quote_feed="polymarket",
    hedge_feed="kalshi",
    base_spread=0.04,
    gamma=0.5,
    max_position=100.0,
    hedge_threshold=10.0,
    hedge_aggression=0.01,
    size=5.0,
)
```

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `quote_exchange` | `str` | required | Exchange to quote on |
| `hedge_exchange` | `str` | required | Exchange to hedge on |
| `quote_feed` | `str` | required | Feed for quoting exchange |
| `hedge_feed` | `str` | required | Feed for hedge exchange |
| `base_spread` | `float` | `0.04` | Base spread width |
| `gamma` | `float` | `0.5` | Avellaneda-Stoikov risk aversion |
| `max_position` | `float` | `100.0` | Max hedge order size |
| `hedge_threshold` | `float` | `10.0` | Delta threshold to trigger hedge |
| `hedge_aggression` | `float` | `0.01` | Price improvement for hedge orders |
| `size` | `float` | `5.0` | Quote size |

## Pipeline: mm_arb

```python
quoter = hz.mm_arb(config)

hz.run(
    name="mm_arb_bot",
    pipeline=[quoter],
    ...
)
```

**Returns `list[Quote]`**: generates quotes for the quoting exchange. Hedges are side-effects via the engine.

## Example

```python
import horizon as hz

config = hz.MMArbConfig(
    quote_exchange="polymarket",
    hedge_exchange="kalshi",
    quote_feed="polymarket",
    hedge_feed="kalshi",
    base_spread=0.04,
    gamma=0.3,
    hedge_threshold=15.0,
    size=5.0,
)

hz.run(
    name="cross_venue_mm",
    exchanges=[
        hz.Polymarket(private_key="0x..."),
        hz.Kalshi(api_key="..."),
    ],
    markets=["election-winner"],
    feeds={
        "polymarket": hz.PolymarketBook("election-winner"),
        "kalshi": hz.KalshiBook("KXELECTION-25"),
    },
    pipeline=[hz.mm_arb(config)],
    interval=0.5,
)
```

<Note>
  MM Arb composes existing `reservation_price()` and `optimal_spread()` Rust functions. See the [Market Making docs](/market-making) for details on Avellaneda-Stoikov parameters.
</Note>
