$ cat ./how-it-works

A technical breakdown of how distinct-baguette trades Polymarket crypto UP/DOWN bucket markets. Three automated strategies running 24/7 across BTC, ETH, SOL, and XRP.

$ cat ./bucket-markets

Polymarket's crypto UP/DOWN markets are binary contracts that resolve based on whether an asset's price is above or below a strike price at expiry. Each market has two tokens:

UP Token
Pays $1.00 if the asset closes above the strike. Otherwise $0.
DOWN Token
Pays $1.00 if the asset closes below the strike. Otherwise $0.

New markets open every 5 minutes, 15 minutes, and 1 hour across four assets. Because UP + DOWN must resolve to exactly $1.00, any pricing that sums to less creates a risk-free arbitrage opportunity. Any pricing that deviates from fair value creates a directional opportunity.

BTCETHSOLXRP5m / 15m / 1h windows

$ cat ./strategies

Momentum Trading

The momentum strategy exploits the latency between Binance spot prices and Polymarket contract pricing. When BTC moves sharply on Binance, Polymarket's UP/DOWN tokens take seconds to reprice. The bot detects the move via a real-time Binance aggTrade WebSocket feed and enters a Polymarket position before the market adjusts.

Signal detection uses a configurable lookback window and minimum delta threshold. When the price move exceeds the threshold, the bot fires an order on the corresponding UP or DOWN token.

4 execution modes: single_taker (FOK at ask — default), gtc_at_ask (GTC limit at ask, rests if no fill), single_maker (GTC at bid for maker fees), dual_hybrid (taker on signal side + maker on contra side simultaneously). Each mode trades off fill probability against execution cost. See the parameter tuning guide for details.

Market Making

Two-sided quoting on both UP and DOWN tokens. The bot posts resting limit orders on both sides of the spread and profits from the bid-ask gap. The key edge is Binance preemptive cancel: the bot monitors the real-time Binance price feed and cancels resting orders before an adverse price move results in a toxic fill.

When the Binance feed signals a sharp BTC move, the bot cancels its exposed side (e.g., cancels resting UP bids if BTC is about to dump) in sub-second, then re-quotes once the move settles. This dramatically reduces adverse selection — the #1 killer of market-making strategies.

Automatic position rebalancing and on-chain merging via ProxyWallet Factory. When the bot accumulates both UP and DOWN tokens, it merges them on-chain to recover USDC and free up capital.

Spread Capture (Arbitrage)

The spread capture strategy exploits a fundamental constraint: UP + DOWN tokens must resolve to exactly $1.00. When the combined bid prices sum to less than $1.00 (e.g., UP bid at $0.48 + DOWN bid at $0.49 = $0.97), the bot buys both sides at the bid for a guaranteed $0.03 profit at resolution, regardless of which direction the asset moves.

This is a risk-neutral strategy — the bot profits at resolution no matter the outcome. Each instance monitors one asset/window combination, checking every tick whether the combined price falls below the spread threshold. Run multiple instances to cover all markets.

$ cat ./architecture

The bot is a single Rust binary that runs as a systemd service on a Linux VPS. Event-driven architecture — the evaluation loop wakes on each Binance aggTrade, not on a fixed timer.

Binance WebSocket (aggTrade)
  │
  ├─→ Signal Engine (lookback, delta threshold)
  │     │
  │     ├─→ Momentum Strategy ──→ Polymarket CLOB
  │     ├─→ Market Making ──────→ Polymarket CLOB
  │     └─→ Spread Capture ─────→ Polymarket CLOB
  │
  └─→ Preemptive Cancel (adverse move detection)
        └─→ Cancel resting orders before toxic fill
Each asset (BTC, ETH, SOL, XRP) gets its own Binance feed and strategy instances
Vendored Polymarket SDK — full CLOB API integration, no external dependencies
GTC and FOK order types with configurable execution modes per strategy
On-chain merge via ProxyWallet Factory — recovers capital from matched UP/DOWN positions

$ cat ./risk-management

Stop-Loss
Configurable loss threshold per position with cooldown period and partial exit support. When a position's unrealized loss exceeds the threshold, the bot exits immediately and enters cooldown before re-entering.
Dry-Run Mode
Set dry_run: true to simulate every trade without placing real orders. All configs ship with dry-run enabled by default — flip one flag to go live.
Graceful Restarts
The bot handles SIGTERM cleanly — cancels all resting orders, flattens positions where possible, and saves state before shutdown. systemd auto-restarts on crash.
Position Merging
Accumulated UP + DOWN token pairs are merged on-chain to recover USDC. Prevents capital lockup from accumulating matched positions. Requires POL for gas.

$ cat ./differentiators

Full Source Code — ~44K lines of Rust. Not a hosted service, not an API wrapper. You own it, deploy it, modify it.
6.8 GB Historical Data — 11,201 market files across BTC, ETH, SOL, XRP at 100ms resolution with embedded Binance klines.
Parallel Backtester — 3 fill models (deterministic, probabilistic, latency). Tests thousands of markets in minutes. See examples.
Pre-Tuned Configs — 10 ready-to-trade configurations for every asset and time window combination. View config reference.
Real-Time Dashboard — local WebSocket dashboard showing live positions, P&L, order flow, and momentum signals.
Production Battle-Tested — the same codebase running on the developer's own VPS with $500K+ in verified profit.

$ cat ./deep-dives

Technical details behind each component. Click to expand.

How Binance data creates a timing edge

Polymarket's crypto bucket markets price UP/DOWN tokens based on whether an asset will be above or below a strike price at expiry. The bot connects to Binance's aggTrade WebSocket stream for BTC, ETH, SOL, and XRP, computing price deltas in real time. When a move occurs on Binance, there's a window — typically in the hundreds of milliseconds — before Polymarket's CLOB fully reprices.

This isn't because Polymarket's market makers are amateurs — the CLOB has sophisticated participants including designated market makers doing significant volume at low latency. The edge exists because even professional MMs have some requote latency on a prediction market CLOB versus a CEX spot feed. Backtester sweeps show the edge is meaningful at ~200ms of latency and marginal by ~550ms.

The bot uses configurable lookback windows (lookback_secs) and delta thresholds (entry_min_delta) to filter noise from signal. The price_delta(N) function computes the percentage move over N seconds, and the bot only fires when the absolute delta meets the threshold. Deployed configs typically use short lookback windows (2-3 seconds) with tight thresholds.

Worth noting: the edge exists in theory but is hard to capture profitably in practice. Fees and adverse selection eat into the raw signal. The backtester and dry_run mode exist precisely for this — to validate that parameter combinations produce positive expected value after costs before risking real capital.

How spread capture is risk-neutral

Every Polymarket bucket market has two tokens: UP and DOWN. At expiry, exactly one pays out $1.00 and the other pays $0.00. This means UP + DOWN must always equal $1.00 at resolution.

The arb strategy checks whether the combined bid prices of UP + DOWN fall below $1.00. When they do — say UP bid at $0.48 and DOWN bid at $0.49 — buying both sides at $0.97 total guarantees a $1.00 payout at resolution, a $0.03 risk-free profit per contract regardless of direction. The bot places both orders together as GTC limits at the bid via batch buy, acting as maker on both sides.

Each bot instance runs one symbol on one time window — it checks whether the combined price is below $1.00 and the spread meets the spread_threshold every tick. To cover multiple assets and windows, you run multiple instances.

The key risk is an adverse fill — only one side executing, leaving you with a directional position. If only one leg fills, the bot cancels remaining unfilled orders after the trade_cooldown_ms elapses and moves on. It doesn't actively unwind the position — instead, a price_bias mechanism biases future bids toward the underweight side, naturally rebalancing the imbalance over subsequent cycles.

The 3 backtesting fill models

Backtesting a trading strategy is only useful if the simulated fills are realistic. The bot includes three fill models, each with different assumptions about how orders get filled:

Deterministic — assumes every order fills instantly at the quoted price. Fast to run and useful for initial strategy screening, but overly optimistic. Real markets have slippage, partial fills, and queue priority. Use this to quickly eliminate bad parameter combinations before running slower models.

Probabilistic — assigns a fill probability based on historical fill rates at each price level. A limit order at the best bid might fill 80% of the time; one tick behind the best bid might fill 40%. This model uses the 6.8 GB historical dataset to calibrate these probabilities per asset and time window.

Latency — the most realistic model. Simulates network round-trip time, order queue position, and the delay between signal detection and order placement. A momentum signal detected at T+0ms might result in an order arriving at T+50ms, by which point the price has already moved. This model produces the most conservative (and accurate) PnL estimates.

You select one fill model per run. The backtester parallelizes across thousands of markets within each run — to compare all three models, run it three times. Strategies that look profitable under the latency model are the ones worth deploying with real capital.

Maker vs taker execution

Polymarket's CLOB charges different fees for makers (limit orders that add liquidity) and takers (market orders that remove liquidity). The bot has four execution modes, each optimizing for different market conditions:

single_taker — sends a Fill-Or-Kill order at the ask. Either fills immediately or cancels entirely. The default mode — prioritizes execution speed over fee optimization. Used when capturing a fast momentum signal where certainty of fill matters more than cost.

gtc_at_ask — posts a GTC limit order at the current ask price. If there's resting liquidity at the ask, this crosses the spread and fills as a taker. If not, it sits on the book as a maker until the next evaluation cycle cancels it. The key difference from FOK: if it doesn't fill instantly, it stays rather than cancelling — useful when you want the order to have a chance to fill passively.

single_maker — posts a GTC limit at the bid price (capped at ask - $0.01). Sits on the book as a resting order, only filling when someone crosses into it. Lowest fees but risks never filling, or filling after the price has moved against you (adverse selection).

dual_hybrid — fires both sides simultaneously: a FOK taker on the signal side and a GTC maker on the contra side (opposite direction). This hedges the position at entry rather than escalating from passive to aggressive. Both legs execute concurrently via async join, so latency on one doesn't delay the other.

Position sizing and capital

The bot uses fixed share sizes, not dollar-denominated allocation. Each config specifies momentum_size (shares per directional order, e.g. 10) and max_buy_order_size (max shares per buy, e.g. 20). The bot fires on every qualifying signal within a window — there's no concurrency limit or portfolio-level capital tracking.

This means your wallet balance determines how many orders can fill. With $300-500 in USDC, the pre-tuned share sizes work comfortably across all asset/window combinations. If your wallet runs low, orders will fail on-chain rather than being skipped proactively — the bot has a hardcoded 5-share minimum floor below which it won't submit orders, but it doesn't track remaining capital.

The pre-tuned configs ship with share sizes hand-tuned from backtester parameter sweeps across historical data. You can adjust momentum_size and max_buy_order_size to match your capital — larger sizes for bigger wallets, smaller for conservative starts.

Use dry_run: true to observe order frequency and sizing without risking real capital. This lets you estimate how much USDC the bot would consume per hour before going live.

When strategies underperform

No strategy works in all market conditions. Transparency about when the bot underperforms is as important as understanding when it excels.

Low volatility — momentum trading needs price moves to generate signals. If the price delta over the lookback window stays below the configured entry_min_delta threshold, the bot skips. During flat markets (common on weekends or between macro events), it may go hours without firing a trade. This isn't a bug — it's the bot correctly waiting for conditions that match its edge.

Tight spreads (arb mode) — the arb strategy profits when UP + DOWN tokens are priced below $1.00 combined. When markets are efficient with tight spreads and active market makers, these dislocations disappear. Note that arb is a separate strategy mode you configure per instance — the bot doesn't dynamically switch between momentum and arb.

Binance feed staleness — if the Binance WebSocket disconnects, the signal goes stale after ~5 seconds. The momentum loop continues running but won't fire new entries since there's no fresh signal — any resting GTC orders stay in place. Binance reconnects automatically via its built-in reconnect loop. SIGTERM sets a shutdown flag and the bot exits cleanly after the current market window.

Regime changes — Polymarket occasionally changes fee structures, adds new assets, or modifies market mechanics. The bot's parameters may need re-tuning when this happens. Re-run the backtester against recent data to find new optimal parameters before deploying updated configs.

Full strategy docs, deployment guides, and parameter tuningRead the docs →

$ ./serve.sh

Full source code, data, and configs. Yours for $249$199.
17 copies in stock