2
0 Comments

Building Risk Management Into a Polymarket Crypto Trading Bot

Polymarket's 5-minute Crypto Up/Down markets look simple:

BTC goes up → UP
BTC goes down → DOWN

But building a bot that trades them continuously is much more complicated than predicting the next BTC move.

The system has to account for:

  • Spot price
  • Chainlink TWAP
  • Strike price
  • Time remaining
  • Polymarket token price
  • Liquidity and spreads
  • Volatility
  • Position size
  • Execution speed
  • Data freshness

After working on automated strategies for these markets, one lesson stands out:

The signal is only one part of the system. Risk management determines what happens when the signal is wrong.

Spot Price Isn't the Settlement Price

One of the biggest mistakes is treating the current BTC price as the final outcome.

These markets use a Chainlink-based TWAP, which means spot and TWAP can temporarily diverge:

Exchange Spot
      ↓
Chainlink / TWAP
      ↓
Polymarket Price

If BTC suddenly moves 0.5%, the TWAP doesn't necessarily move at the same speed.

That difference can provide information—but it can also create risk.

A large spot move doesn't automatically mean the final TWAP will move in the same direction.


Position Size Comes First

A good signal with an oversized position can still destroy an account.

The first question shouldn't be:

"How much can I make?"

It should be:

"How much can I afford to lose?"

For example, a strategy might limit each trade to roughly 0.5–1% of bankroll.

For a $10,000 account:

0.5% = $50
1.0% = $100

Position size can then adjust based on the market:

Position Size =
Base Size
× Signal Strength
× Liquidity
× Volatility
× Risk Factor

The bot doesn't need to take the same amount of risk on every market.


TWAP Divergence Matters

A useful variable to monitor is:

TWAP Deviation = Spot Price - TWAP

When spot suddenly moves away from TWAP, the system knows market conditions have changed.

That could indicate momentum, a temporary dislocation, a delayed TWAP response, or increased uncertainty.

Instead of automatically increasing exposure, the risk engine can become more conservative:

Large TWAP deviation
        ↓
Reduce size
        ↓
Require confirmation
        ↓
Or skip the trade

More movement doesn't necessarily mean a better entry.


Don't Chase Sudden Moves

A common failure mode looks like this:

BTC +0.10%
     ↓
BTC +0.25%
     ↓
BTC +0.50%
     ↓
BUY UP

By then, the Polymarket token may already reflect much of the move.

A better system can require confirmation:

  • Momentum remains consistent
  • TWAP confirms the direction
  • Market price confirms the move
  • Liquidity is sufficient
  • Spread is acceptable

The goal isn't to guarantee profitable trades.

It's to stop treating every price spike as an opportunity.


Execution Is Part of the Strategy

A correct prediction can still produce a bad trade.

Suppose the bot expects to enter at 0.70:

0.70 → 10 shares
0.73 → 20 shares
0.76 → 30 shares
0.80 → 50 shares

A large order may have an average execution price far above 0.70.

That's why the execution engine needs to monitor:

  • Bid / ask
  • Spread
  • Order-book depth
  • Available size
  • Expected slippage
  • Recent fills

I think of this as two separate questions:

Signal engine:

Should I trade?

Execution engine:

How should I trade?


The Bot Needs Permission to Do Nothing

Automated systems need circuit breakers.

For example:

Daily loss exceeds limit
        ↓
STOP NEW TRADES

Other triggers could include:

  • Consecutive losses
  • Abnormal volatility
  • Thin liquidity
  • High execution latency
  • Stale market data

For example:

MAX_DAILY_LOSS = 0.05
MAX_CONSECUTIVE_LOSSES = 4
MAX_DATA_AGE_MS = 1000

The exact thresholds are strategy-specific.

The principle isn't:

The bot needs permission to do nothing.


Data Freshness Is Risk Management

Imagine:

Exchange feed   → LIVE
Polymarket      → LIVE
TWAP data       → STALE

The bot shouldn't continue trading simply because some of its feeds are working.

It should monitor timestamps, feed age, WebSocket health, reconnects, message sequences, and clock drift.

A simple safety flow:

Data becomes stale
        ↓
Reject new orders
        ↓
Recover connection
        ↓
Validate fresh data
        ↓
Resume

This isn't just infrastructure.

It's trading risk management.


The Architecture

The overall system can be structured like this:

Market Data
     ↓
Data Validation
     ↓
Signal Engine
     ↓
Risk Manager
     ↓
Execution Engine
     ↓
Position Monitor

The signal engine should never be able to bypass the risk manager simply because a signal looks strong.

After entering, the bot should continue monitoring:

  • Entry price
  • Spot
  • TWAP
  • Strike
  • Time remaining
  • Position size
  • Unrealized P&L

Depending on the strategy, it can reduce, exit, or hedge when conditions change.


The Main Lesson

The hardest part of building a Polymarket Crypto Up/Down bot isn't creating a BUY signal.

It's answering three questions:

Should I trade?

How much should I trade?

When should I stop?

That's why I think about the system as:

Data
 ↓
Signal
 ↓
Risk
 ↓
Execution
 ↓
Position Management

rather than:

Price ↑
 ↓
BUY

In short-duration markets, risk management isn't an extra feature. It's part of the trading strategy itself.

I'm continuing to work on Polymarket trading-bot strategies and infrastructure in Python.

GitHub: Benjam1nCup/Polymarket-trading-bot-python-V2

The repository is intended primarily for educational and research purposes, not as a guarantee of trading performance.

on September 28, 2026