Abstract
This paper documents the development and evolution of an automated trading bot for Polymarket. Over the course of development, we implement and test a market inefficiency exploitation. We present our findings on what worked, what failed, and why—culminating in our current focus on a mathematically rigorous arbitrage strategy based on Bregman projection and the Frank-Wolfe optimization algorithm.
Introduction
Prediction markets like Polymarket offer unique opportunities for algorithmic trading. Unlike traditional financial markets, prediction markets have bounded outcomes (probabilities must sum to 1), defined resolution times, and often exhibit pricing inefficiencies due to retail-dominated order flow.
Our goal was to build a profitable automated trading system that could:
• Identify market inefficiencies
• Execute trades with proper risk management
• Operate 24/7 with minimal intervention
• Track performance and adapt strategies
The bot was built using TypeScript, and includes a dashboard with real-time notifications via Slack.
Technical Architecture
I built a TypeScript Bun project with a modular architecture so strategies could be iterated on quickly and cleanly. The project is open source and available here:
https://github.com/jaredzwick/polymarket-trading-bot
It includes instructions for writing your own strategy along with a P/L dashboard.
Bregman Projection Arbitrage
The strategy is based on the mathematical insight that prediction market prices should form valid probability distributions. When they do not, arbitrage opportunities exist.
Key concepts:
Probability Simplex
Prices should sum to 1 for mutually exclusive outcomes.
Bregman Divergence
Measures distance from a valid probability distribution.
KL-Divergence
D(μ||θ) = Σ μᵢ log(μᵢ / θᵢ) quantifies mispricing.
Frank-Wolfe Algorithm
Efficiently finds optimal trade allocation.
Arbitrage Types
Simple Arbitrage
Binary markets where YES + NO < $1.00
Multi-Outcome Arbitrage
Markets with more than two outcomes not summing to $1.00
Cross-Market Arbitrage
Related markets with logical constraints
The Math, Concretely
Step 1: Detect mispricing
For a market with outcomes i = 1..n, let θᵢ be the current mid-price of token i.
Valid probability requires:
Σ θᵢ = 1
θᵢ > 0
If Σ θᵢ < 1: buy all outcomes, resulting in guaranteed profit of 1 − Σ θᵢ per share.
If Σ θᵢ > 1: the overpricing creates sell-side opportunities.
For a normal efficient market:
Up = 0.815
Down = 0.185
Sum = 1.000 — no simple arbitrage here.
But in practice you will often see sums like 0.97 or 1.04, especially on newer or less liquid markets.
Step 2: KL-Divergence (Bregman Projection)
When mispricing is subtle or when you want to optimally allocate across outcomes, you project the market prices onto the probability simplex.
Given market prices θ (which may not sum to 1), find the closest valid distribution μ*:
μ* = argmin D_KL(μ || θ) subject to Σ μᵢ = 1 and μᵢ > 0
For KL divergence, the solution is simple normalization:
μ*ᵢ = θᵢ / Σ θⱼ
The divergence D_KL(μ* || θ) tells you the magnitude of mispricing.
The difference μ*ᵢ − θᵢ tells you the direction for each outcome.
Step 3: Frank-Wolfe for trade allocation
Once you know the target distribution μ*, Frank-Wolfe iteratively solves for optimal trade sizes given order book depth and transaction costs.
1for (let iter = 0; iter < MAX_ITERATIONS; iter++) {2 const gradient = computeGradient(current, marketPrices);3 const vertex = argmin(gradient);4 const stepSize = 2 / (iter + 2);5 current = (1 - stepSize) * current + stepSize * vertex;6 if (converged(current, previous)) break;7}
Putting It to the Test
All of this sounds great in theory, but practice is trickier. You still need to identify where inefficiencies exist and code them into the bot, rather than blindly handing everything to the computer.
Perhaps in the future, we can analyze all markets and have an AI predict which one to bet on, but for now a good starting point when the action space is huge is to keep things simple.
Pick one chart, one hypothesis, and evaluate.
For this experiment we chose:
Earnings Calendar — Will company X beat quarterly earnings?

This is a binary market where YES + NO probabilities should equal 1. On first glance, many of these markets appear mispriced, making them a good place to start.
Every 30 seconds, the bot fetches the latest earnings betting markets from the Polymarket Gamma API and evaluates them against our arbitrage rules to determine whether a suitable trade exists.
I built a dashboard to monitor live performance and strategy behavior:
https://polymarket-trading-bot.onrender.com/
Credit & Inspiration: