All Projects

๐Ÿ“Š Polymarket Market-Making Bot

๐Ÿ“ˆ Market-making bot for Polymarket prediction markets with a fair-value model using BTC momentum (Binance WebSocket) and order book imbalance signals. Two-sided YES/NO quoting, inventory skewing, risk kill-switches, and a backtesting simulator with PnL tracking.

Personal Project2023โ€“2024

Stack

TypeScriptNode.jsPolymarket CLOB APIBinance WebSocketREST APIs

Polymarket Market-Making Bot

๐Ÿ”ญ Overview

A market-making bot for Polymarket prediction markets that goes beyond simple spread posting. It implements a fair-value model informed by external market microstructure signals โ€” BTC price momentum and order book imbalance โ€” to generate adaptive two-sided quotes that adjust dynamically to market conditions.

โ“ The Problem

Naive market-making on prediction markets is a losers' game: if you just post fixed spreads, informed traders pick off your quotes whenever a signal moves. Profitable market-making requires a fair-value estimate that's continuously updated based on observable signals, plus risk controls to limit inventory exposure.

๐Ÿ› ๏ธ What I Built

๐Ÿ“Š Fair-Value Model

  • ๐Ÿ“ˆ BTC momentum signal: Binance WebSocket feed provides real-time BTC price; momentum (recent directional move) is used as a proxy for broader market risk sentiment, adjusting fair value of correlated prediction markets
  • โš–๏ธ Order book imbalance signal: Polymarket CLOB order book is analyzed in real time; high bid-side imbalance shifts fair value toward YES, high ask-side imbalance shifts toward NO
  • ๐Ÿ”„ Combined signal produces a continuously-updated fair value estimate for each market

๐Ÿ’ฌ Quote Generation

  • ๐Ÿ“ Two-sided YES/NO quotes generated around fair value with configurable base spread
  • ๐Ÿ“ Spread widens automatically when volatility is elevated (volatility kill-switch)
  • ๐Ÿ”„ Quotes are repriced on every signal update โ€” no stale orders

๐Ÿ“ฆ Inventory Management

  • ๐Ÿ“ Inventory skewing: when long YES, widen the YES ask and tighten the NO ask to reduce exposure
  • ๐Ÿšซ Max position limits: configurable per-market position caps, bot stops quoting when limit is hit
  • ๐Ÿ“Š Inventory PnL tracking: marks positions to fair value for real-time unrealized PnL

๐Ÿ›ก๏ธ Risk Controls

  • ๐Ÿ“‰ Spread kill-switch: halts quoting if spread collapses below minimum profitability threshold
  • โšก Volatility kill-switch: halts quoting during extreme BTC volatility (unreliable fair-value conditions)
  • ๐Ÿ›‘ Manual override: kill-switch commands for immediate position exit

๐Ÿงช Backtesting Simulator

  • ๐Ÿ”„ Round-based backtesting framework replays historical Polymarket CLOB data
  • ๐Ÿ“Š Simulates fill probability based on historical order flow
  • ๐Ÿ’ฐ PnL tracking per round: realized spread income, inventory mark-to-market, position costs

โญ Key Highlights

  • ๐Ÿ“Š Fair-value model using external signals (BTC momentum + order imbalance) โ€” not static spread posting
  • ๐Ÿ“ Inventory-aware quoting with dynamic skewing
  • ๐Ÿ›ก๏ธ Multiple kill-switches for risk management in volatile conditions
  • ๐Ÿงช Full backtesting framework with historical data replay and PnL tracking