SX BetBlog
Exchange ↗SX Bet

I Built a Sports Prediction Market Aggregator with Claude

An open-source aggregator that pulls live odds from SX Bet and Polymarket, adjusts for fees, and routes each fill to the best all-in price. Built with Claude Code over a weekend.

ByDeclan··8 min read·View on GitHub ↗
/developers/builds/sports-prediction-market-aggregator

I Built a Sports Prediction Market Aggregator with Claude

An open-source tool that pulls live odds from SX Bet and Polymarket, adjusts for fees, and routes each fill to the best all-in price.

Read-only dashboard: spm-aggregator-readonly.vercel.app

Bot GitHub repo: github.com/declansx/sports-prediction-market-aggregator


Polymarket's Sports Product is Not Competitive

Last month, Polymarket introduced a 3% taker fee on all sports bets made through the platform. Pivoting from 0% commission took them from having some of the most competitive sports odds globally to being uncompetitive with leading sports prediction market platforms like SX Bet overnight. Polymarket still displays pre-fee odds on their website to create the illusion of tight spreads but don't be fooled — once you factor in the fee, these odds become far less attractive.

For non-recreational users, Polymarket's jump to a large, well-hidden fee that's difficult to calculate makes the platform largely unusable. Margin is the name of the game for this audience, and for most takers any edge remaining after fees is minimal. Take a look at this screenshot of upcoming EPL markets on the aggregator:

EPL markets comparison: SX Bet vs Polymarket odds

The teal odds are outcomes where SX Bet has the best available price; dark blue odds are outcomes where Polymarket has the best price. SX has better pricing on 55/56 outcomes. Unless you're betting 5-figure units, you'd rarely fill any of Polymarket's liquidity through this aggregator.

With alt-lines in the picture, the gap widens. Polymarket can't offer whole-line spreads and totals like SX Bet, due to infrastructure limitations that prevent them from voiding/pushing markets. A Polymarket user betting on Game 6 of the Hawks vs. Knicks playoff series today, for example, could trade an additional 24 spread and total lines through the aggregator.

NBA alternate lines available on SX Bet but not Polymarket


How the Aggregator Works

The aggregator pulls real-time sports market odds from SX Bet and Polymarket, stitches their order books into one combined view, and automatically routes your bet to the best odds by filling the best-priced levels across the combined book. If SX has the top three best-priced levels, you fill all three from SX. If the fourth-best is on Polymarket, the aggregator fills that too.

Combined orderbook view across SX Bet and Polymarket

The flow:

  1. Match fixtures across venues. Team names go through a canonicalisation chain (manual aliases + affix stripping) so "Manchester City FC" and "Manchester City" collapse. Fixtures are then grouped by sport, league, sorted team names, and a start-time bucket so SX and Polymarket events for the same game merge.
  2. Match bets within each fixture. Every outcome maps to a canonical key (1x2:home, spread:away:+1.5, total:over:2.5) so SX and Polymarket outcomes representing the same wager merge into one synthetic market.
  3. Stream live order books. SX Bet via its Centrifugo WebSocket, Polymarket via its CLOB WebSocket. Polymarket's 3% sports fee is applied at the adapter layer so every downstream price is taker-facing.
  4. Allocate greedily. Combined levels are sorted ascending by odds and walked cheapest-first until your stake is filled. If the weighted fill price exceeds your slippage tolerance, the trade is rejected before signing.
  5. Execute concurrently. Polymarket fills go out as Fill-or-Kill orders via @polymarket/clob-client-v2; SX Bet fills are signed EIP-712 taker orders. Trade rows are persisted, Telegram sends a fill summary.

The Data

The aggregator tracks prices and available liquidity across all aggregated matches beginning in the next 24 hours. Below is a snapshot of the summarized data from approximately 12PM ET today:

Liquidity and pricing comparison stats: SX Bet vs Polymarket

ScopeOutcomes comparedSX has best pricePolymarket has best priceAvg liquidity above other venue
Match winners (ML, 1X2)6456 (88%)8 (12%)$2.4k
All market types (incl. spreads, totals, alt-lines)768680 (89%)88 (11%)$1.7k

Three takeaways:

  1. 88% of match-winner lines are priced better on SX. Specifically, this includes all 1X2 and Moneyline markets.
  2. Alternate lines widen the gap. Polymarket can't offer whole lines (i.e. Over 6.0). When you include all available spread and total lines, Polymarket's coverage and pricing falls off significantly.
  3. $2.4k average depth above Polymarket's best odds ($1.7k across all markets). Available depth at top-of-market odds varies between leagues and markets, but the overwhelming majority of traders will see meaningfully better margins by capturing the prices available on SX Bet.

Why the Fee Hurts Where it Matters Most

Polymarket charges a 3% taker fee on sports markets. The fee formula is p + feeRate * p * (1 - p), which means the fee cost peaks at p = 0.50 — midpoint odds (2.00 / +100). At true 50/50 odds, the taker pays 0.75% of notional before the bet fills. At 80/20 it's 0.48%. At 95/5 it's 0.14%.

That shape matters because the midpoint is where the majority of volume falls for most serious sports bettors. Main line spreads and totals are priced near 50/50 by nature. The fee, by formula, is greatest where advanced traders do the majority of their volume.

For a high-volume bettor turning over $50K a week near the midpoint, that's already ~$39K a year in fees before a single dollar of profit. For an arbitrage bettor operating on 50–200bps margins, the fee eats most or all of the edge. Trades that look profitable on screen aren't after fees, and a 3% taker rate effectively removes Polymarket from most arb tools.


Three Ways to Use the Aggregator

1. Public read-only dashboard (odds comparison site)

Open spm-aggregator-readonly.vercel.app. Browse aggregated odds from both platforms and select any specific market to see combined orderbook liquidity.

2. Clone and run the trading bot yourself for bet execution

Clone the repo and configure the project with your wallet and API keys to execute trades. The aggregator routes your fills through whichever venue has the best all-in price, splitting across both when that's cheaper.

Full setup in the GitHub repo's docs/setup.md. github.com/declansx/sports-prediction-market-aggregator

3. Use the code as a reference.

If you're building on the SX Bet API yourself, the adapters in bot/src/adapters/sxbet.ts and the routing loop in bot/src/router/index.ts are working reference implementations. CLAUDE.md and the .claude/sxbet/ directory in the repo capture the SX-specific traps LLMs trip on — drop them into your own agentic coding setup.


Building on the SX Bet API with Claude Code

I planned and built this entire project over a weekend. The new SX Bet docs are extremely LLM-friendly, and paired with the MCP server they make it genuinely easy to build on SX with an agent. Here's how I setup a project with the SX Bet API in Claude Code — you can easily adapt for Cursor, Windsurf, or any other AI powered IDE.

1. Install the SX Docs MCP server.

claude mcp add --transport http sx-bet https://docs.sx.bet/mcp

This gives the agent access to search and read the SX Bet docs during a coding session. No need to paste screenshots or excerpts into prompts — the LLM fetches exactly what it needs on demand. Setup instructions for every MCP-compatible client is available at docs.sx.bet/developers/build-with-llms.

2. Optimize your CLAUDE.md and .claude for working with the SX Bet API

CLAUDE.md is an instructions file that Claude reads at the start of every session. The MCP server lets it look up the docs; CLAUDE.md gives it best practices, hard rules and conventions to follow when working with the SX Bet API (odds format, signing, real-time feeds, what to pull from /metadata). Most of the detail lives in .claude/sxbet/ so Claude only brings it into the context window when relevant.

Copy CLAUDE.md and the .claude/sxbet/ folder from the repo, paste into your project, and edit the top section to match what you're building.

3. Plan, then build.

Start in plan mode, describe what you want, let the agent explore both the docs MCP and your codebase before writing code.


Live dashboard: spm-aggregator-readonly.vercel.app

Fork on GitHub: github.com/declansx/sports-prediction-market-aggregator

SX Bet API docs: docs.sx.bet


Disclaimer

Personal project. Not an official SX Bet product. Not audited. Not financial advice. I am part of the SX Team — obviously I'm biased, which is why the dashboard, the code, and the data are all public so you can verify. Start on testnet. Cap order sizes in config. Read every line of the executor before trusting it with real funds.

Build on SX Bet's Open API

No API key required. Fetch live odds, markets, and orderbook data with a single HTTP call — then place orders peer-to-peer.