---
title: "Horizon Simple Market Maker"
description: "The simplest possible Horizon strategy: fixed fair value with a fixed spread."
icon: "play"
---

The simplest possible strategy. Quotes a fixed fair value with a fixed spread on paper.

## Full Code

```python
"""Minimal 20-line Horizon example."""

import horizon as hz


def fair_value(ctx: hz.Context) -> float:
    """Simple fair value: just return 0.5 (coin flip)."""
    return 0.50


def quoter(ctx: hz.Context, fair: float) -> list[hz.Quote]:
    """Quote around the fair value with a fixed spread."""
    return hz.quotes(fair, spread=0.06, size=5)


hz.run(
    name="simple_mm",
    markets=["test-market"],
    pipeline=[fair_value, quoter],
    risk=hz.Risk(max_position=100, max_drawdown_pct=5),
    interval=1.0,
    mode="paper",
)
```

## How It Works

1. **`fair_value`** returns a constant `0.50`, a 50/50 coin flip market
2. **`quoter`** receives the fair value and creates quotes:
   - Bid: `0.50 - 0.03 = 0.47`
   - Ask: `0.50 + 0.03 = 0.53`
   - Size: 5 contracts
3. Each cycle, the paper exchange matches orders against the mid price
4. When fills occur, positions are tracked and P&L is calculated

## Run It

```bash
python examples/simple.py

# Or with dashboard
python -m horizon run examples/simple.py --dashboard
```

## Extending

Add inventory skew to lean quotes away from your position:

```python
def quoter(ctx: hz.Context, fair: float) -> list[hz.Quote]:
    skew = ctx.inventory.net * 0.001
    return hz.quotes(fair - skew, spread=0.06, size=5)
```

Add a feed for dynamic fair value:

```python
from horizon.context import FeedData

def fair_value(ctx: hz.Context) -> float:
    btc = ctx.feeds.get("btc", FeedData())
    return btc.price * 0.01 if btc.price > 0 else 0.50

hz.run(
    feeds={"btc": hz.BinanceWS("btcusdt")},
    ...
)
```
