DEV Community

Benjamin-Cup
Benjamin-Cup

Posted on

# Building a Polymarket Liquidity Maker Bot in Python (Crypto 5m–1d Markets)

Prediction markets are one of the most interesting financial experiments on the internet. Platforms like Polymarket allow traders to buy and sell event outcomes using YES and NO tokens.

Most trading bots attempt to predict market direction.

But there is another approach that is often more stable:

Liquidity Market Making

Instead of betting on outcomes, the bot simply captures the spread.

In this article, I’ll explain how I built a Python liquidity-maker trading bot for Polymarket that works across:

  • 5 minute markets
  • 15 minute markets
  • 1 hour markets
  • 4 hour markets
  • 1 day markets

for crypto assets like:

  • BTC
  • ETH
  • SOL
  • XRP

The bot runs a ladder-based market making strategy and earns profit by selling both YES and NO tokens at prices whose combined value exceeds $1.


How Polymarket Outcome Tokens Work

Each Polymarket market has two tokens:

Token Payout
YES $1 if event happens
NO $1 if event does not happen

At resolution:

  • one token becomes $1
  • the other becomes $0

If you hold both tokens, your total value is always $1.

This is the key idea behind the strategy.


The Core Strategy

The bot creates token pairs and sells them above $1 combined.

Example:

Token Sell Price
YES 0.54
NO 0.49

Total received:

0.54 + 0.49 = 1.03
Enter fullscreen mode Exit fullscreen mode

Cost to create pair:

1.00
Enter fullscreen mode Exit fullscreen mode

Profit before fees:

1.03 - 1.00 = 0.03
Enter fullscreen mode Exit fullscreen mode

This means the bot does not need to predict market direction.

It simply captures the spread between buyers and sellers.

Typical target range:

1.03 — 1.10 total pair value
Enter fullscreen mode Exit fullscreen mode

Bot Workflow

The bot runs a simple state machine.

IDLE
 ↓
SPLIT
 ↓
PAIR_SELL
 ↓
MONITOR
 ↓
REDEEM
 ↓
IDLE
Enter fullscreen mode Exit fullscreen mode

1️⃣ Split Collateral

The bot converts USDC.e into YES + NO tokens.

This creates a neutral inventory.


2️⃣ Pair Selling

Instead of selling everything at once, the bot sells small token pairs.

For each pair:

  1. Read the orderbook
  2. Calculate optimal prices
  3. Place limit orders
  4. Wait for fills

Example pair size:

pair_size = 5 tokens
Enter fullscreen mode Exit fullscreen mode

3️⃣ Monitor Market

Once the tokens are sold, the bot waits until the market resolves.

Crypto markets resolve quickly:

Interval Resolution Time
5m 5 minutes
15m 15 minutes
1h 1 hour
4h 4 hours
1d 24 hours

4️⃣ Redeem

When the market resolves:

  • one token becomes $1
  • the other becomes $0

The bot redeems the winning token back to USDC.e.


Dynamic Pricing Algorithm

The bot reads the orderbook from the Polymarket CLOB API.

Then calculates prices:

yes_price = best_bid_yes + spread
no_price  = best_bid_no  + spread
Enter fullscreen mode Exit fullscreen mode

Example:

best_bid_yes = 0.49
best_bid_no  = 0.50
spread       = 0.01
Enter fullscreen mode Exit fullscreen mode

Calculated:

yes_price = 0.50
no_price  = 0.51
Enter fullscreen mode Exit fullscreen mode

Total:

1.01
Enter fullscreen mode Exit fullscreen mode

But the bot enforces:

yes_price + no_price ≥ min_pair_sum
Enter fullscreen mode Exit fullscreen mode

Example configuration:

min_pair_sum = 1.03
Enter fullscreen mode Exit fullscreen mode

If the pair is too small, the bot raises prices proportionally.


Example Bot Configuration

config/default.yaml

liquidity_maker:
  portfolio_allocation_usdc: 100

  pair_size: 5
  min_pair_sum: 1.03

  price_follow_spread: 0.01

  pair_sell_timeout_seconds: 300
  order_check_interval_seconds: 5

  redeem_delay_seconds: 10
  stagger_delay_seconds: 2
Enter fullscreen mode Exit fullscreen mode

Important parameters:

Parameter Description
portfolio_allocation_usdc Capital used per market
pair_size YES/NO tokens per pair
min_pair_sum Minimum combined sell price
price_follow_spread Price offset above best bid
pair_sell_timeout_seconds Cancel orders if unfilled

Supported Markets

The bot focuses on short-term crypto prediction markets.

Asset 5m 15m 1h 4h 1d
BTC
ETH
SOL
XRP

Market slug example:

btc-updown-5m-1709916600
Enter fullscreen mode Exit fullscreen mode

Bot Architecture

polymarket-trading-ladder-bot
│
├── config
│   ├── default.yaml
│   └── paper.yaml
│
├── src/polybot5m
│
│   ├── cli.py
│   ├── config.py
│   ├── constants.py
│   ├── engine.py
│
│   ├── data
│   │   ├── gamma.py
│   │   └── slug_builder.py
│
│   └── execution
│       ├── clob_client.py
│       ├── executor.py
│       ├── split.py
│       └── redeem.py
│
└── exports
    └── liquidity_maker_activity.json
Enter fullscreen mode Exit fullscreen mode

The bot interacts with:

  • Gamma API → market discovery
  • CLOB API → orderbook + trading

Running the Bot

Paper Trading

Always test with paper trading first.

polybot5m run --dry-run
Enter fullscreen mode Exit fullscreen mode

or

polybot5m -c config/paper.yaml run
Enter fullscreen mode Exit fullscreen mode

Live Trading

Example run:

polybot5m run --cycles 1 --allocation 10
Enter fullscreen mode Exit fullscreen mode

Meaning:

  • run 1 market cycle
  • allocate $10 per market

Example Profit Scenario

If the bot captures:

$0.03 per pair
Enter fullscreen mode Exit fullscreen mode

And sells:

100 pairs per hour
Enter fullscreen mode Exit fullscreen mode

Potential hourly revenue:

≈ $3
Enter fullscreen mode Exit fullscreen mode

Across multiple markets:

Markets Estimated Hourly Profit
1 ~$36
2 ~$72
4 ~$144

(before fees and slippage)


Risk Considerations

Even market making bots have risks.

Important ones include:

Liquidity Risk

Orders might not fill.

Fee Risk

Trading fees reduce spread profit.

Inventory Risk

If one side fills and the other doesn't.

Market Resolution Delays

Capital may be locked longer than expected.

Proper monitoring and cancellation logic is essential.


Final Thoughts

This liquidity-maker bot demonstrates how market making strategies can work even in prediction markets.

Instead of predicting price movements, the bot simply:

  • creates neutral token pairs
  • sells both sides
  • captures spread
  • redeems collateral

It’s a systematic strategy, not speculation.

Prediction markets are still evolving, and automated liquidity providers may play a big role in improving market efficiency.


If you're building trading infrastructure for prediction markets, experimenting with spread capture strategies like this can be a great starting point.

Happy building 🚀

Try the Polymarket Trading Bot

You can also test a Telegram demo version of the bot.

Telegram Bot

https://t.me/benjamin_polymarket_trading_bot


Video Demo

https://www.youtube.com/watch?v=4cklMPZs0y8


Contributing

Contributions are welcome.

Submit ideas, pull requests, or issues on GitHub.

https://github.com/Gabagool2-2/polymarket-trading-bot-python


Continuous Updates & Development

This Polymarket trading bot is actively maintained and continuously updated to adapt to new Polymarket trading opportunities, crypto market conditions, and strategy improvements.

New features, optimizations, and trading strategy enhancements are released regularly to improve performance, stability, and profitability.

If you're interested in:

Polymarket trading automation

crypto trading strategies

prediction market bots

or contributing to the project

feel free to stay in touch.

If you'd like to see the system in action, I can arrange a live Google Meeting demonstration to showcase the bot running in real time and explain how the trading strategies operate.

I'm always happy to connect with developers, traders, and researchers working in the Polymarket and crypto ecosystem.


Contact

Email
benjamin.bigdev@gmail.com

Telegram
https://t.me/BenjaminCup

X
https://x.com/benjaminccup


If you're building in:

  • Polymarket trading
  • Crypto automation
  • Prediction market strategies
  • Algorithmic trading bots

this project can be a strong foundation.

Happy trading and coding in 2026 🚀📊

polymarket #polymarket-trading-bot #trading #bot #Crypto


Top comments (3)

Collapse
 
milan_saar_0fbc57fb97f39a profile image
Milan Saar

Overall, this is a great contribution for anyone looking to explore systematic trading strategies in prediction markets. I’m particularly interested in how automated liquidity providers can improve market efficiency over time, and your work illustrates that nicely.
Thank you for sharing your insights—this will definitely be valuable for developers and traders in the space.

Collapse
 
benjamin_martin_749c1d57f profile image
Benjamin-Cup

Thanks

Collapse
 
tom_phillips_c3c17afe434f profile image
Tom Phillips

The ladder-based pair selling combined with short-duration markets is a clever way to increase capital turnover.

Cool