Skip to main content

Market Making Guide

Build market making strategies with the ZenOTC SDK.

Basic Market Maker

async def market_maker(client):
while True:
# Get reference price
price = await client.market_data.get_price("BTC")

# Calculate spread
spread_bps = 20 # 20 basis points
half_spread = float(price.mid) * spread_bps / 10000 / 2

# Submit quote
quote = await client.market_making.submit_quote(
asset="BTC",
bid_price=float(price.mid) - half_spread,
ask_price=float(price.mid) + half_spread,
bid_size=1.0,
ask_size=1.0,
valid_for_seconds=30
)

# Wait for quote to expire
await asyncio.sleep(25)

# Cancel and refresh
await client.market_making.cancel_quote(quote.id)

Dynamic Spread

Adjust spread based on volatility:

volatility = calculate_volatility(...)
spread_bps = 10 + volatility * 100

Inventory Management

Monitor position and adjust quotes:

position = await client.portfolio.get_position("BTC")
if position.quantity > 5:
# Skew quotes to reduce inventory
bid_size *= 0.5
ask_size *= 1.5