Building a Polymarket Bot, Part 6: YES Packages
📒Docs: https://zeit-1.gitbook.io/zeit Telegram: https://t.me/zeitfi X: https://x.com/ZEITFinance X2: https://x.com/autonomous_af ← Building a Polymarket Bot, Part 5: NegRisk Foundations In Part 5, we

📒Docs: https://zeit-1.gitbook.io/zeit
Telegram: https://t.me/zeitfi
X2: https://x.com/autonomous_af
← Building a Polymarket Bot, Part 5: NegRisk Foundations
In Part 5, we defined the "Laws of Motion" for NegRisk markets. Now, we turn them into code.
We begin with the most intuitive strategy: The YES Package (often called "Buying the Field"). The premise is simple: One of these candidates must win. If I can buy a YES share for every candidate and pay less than $1.00 total, I have locked in a guaranteed profit.
That instinct is correct. It is also where most bots die.
On Polymarket, "YES Arb" is not just an inequality equation (Price < 1.0). It is a multi-leg trade executed on a thin order book with strict venue rules. Once you enforce tick grids, minimum order sizes, and real depth, most "paper edges" disappear.
This article is the engineering playbook for YES Packages: how to price them, how to size them, and how to relax the constraints to build Bond Baskets.
1. The Theory: Pure YES Arb
A YES Package exploits mispricing across a set of mutually exclusive outcomes. In a winner-take-all event with outcomes 1 to N:
-
If you buy 1 YES share on every outcome, exactly one will resolve to $1.
-
The basket pays out exactly $1.00 at resolution.
The Paper Math:
-
Cost = Sum of Best Asks for all Outcomes
-
Edge = 1.00 - Cost
If Cost is less than 1.00, you have a positive edge. Crucially, this strategy is deterministic. You do not need to search for combinations. You simply buy the entire board.
2. The Reality: Venue Constraints
Most "arbs" you see on a spreadsheet vanish when you try to trade them. This is not due to latency; it is due to Venue Constraints.
The Polymarket CLOB enforces two hard rules on every order:
-
Minimum Shares: 5 shares.
-
Minimum Notional: $1.00 (USDC).
These rules create the Bottleneck Leg problem.
The Bottleneck Leg

To maintain a neutral hedge, you must buy an equal quantity of shares for every candidate. You cannot buy 100 shares of Trump and 5 shares of Harris; you must buy 100 of both.

The required size is dictated by the cheapest leg (the "Longshot").
-
Scenario: Candidate A costs 90¢. Candidate B costs 1¢.
-
Constraint: To buy Candidate B, you need a minimum order of $1.00.
-
The Math: 1.00 / 0.01 = 100 shares.
-
The Consequence: To hedge, you must also buy 100 shares of Candidate A.
Suddenly, a "dust" arb requires you to deploy $90 + $1 = $91 of capital just to execute the minimum trade. If the order book for Candidate A only has 50 shares of liquidity, the trade is impossible.
3. The Pricing Pipeline

To filter out ghosts, your bot needs a two-stage pricing engine.
Stage A: L1 "Spreadsheet Arb"
This is a fast, optimistic filter to discard noise.
-
Sum the Best Asks of all N outcomes.
-
If the Sum is < 1.00, proceed to Stage B.
-
Note: Ignore fees for L1; if the gross margin isn't there, the net margin certainly won't be.
Stage B: VWAP-at-Size Simulation
Now, reprice the basket using the Bottleneck Size.
-
Identify Min Size: Calculate the shares required to satisfy the $1 min-notional on the cheapest leg. Target_Size = max(5, ceil(1 / Min_Price))
-
Walk the Books: For every outcome, calculate the Volume Weighted Average Price (VWAP) to acquire Target_Size shares.
-
Check Liquidity: If any leg lacks sufficient depth to fill Target_Size, abort.
-
**Recalculate Edge: **Real_Edge = 1.00 - Sum(VWAP_Cost_Per_Leg)
This effectively simulates the trade before you send it. If Real_Edge is still positive, you have a tradable opportunity.
3.5 The Invisible Killer: Tick Rounding
Spreadsheets allow infinite precision. The order book does not. Polymarket prices are quantized to specific tick sizes (e.g., $0.01 or $0.001).
-
The Trap: Your L1 sum might be $0.996. Perfect arb, right?
-
The Reality: To hit the order book, you must round your limit prices UP to the nearest valid tick. Leg A: $0.332 → $0.34 Leg B: $0.332 → $0.34 Leg C: $0.332 → $0.34
-
The Result: Your execution cost is $1.02. The edge didn't just vanish; it inverted.
-
Code Rule: Always round your target limit prices UP to the venue’s tick size before calculating the final edge. Never assume the "mid" price is fillable.
4. The Evolution: Bond Baskets (99% Coverage)

Pure YES Arb is rigorous, but strict. It forces you to buy every single "dust" outcome (candidates trading at 0.1¢), which bloats your capital requirements and operational risk.
Enter the Bond Basket. Instead of buying 100% of the outcomes, you buy the top ~99% of probability mass and skip the "dust."
The Logic
-
Filter: Set a MIN_LEG_PRICE (e.g., 2¢).
-
Action: Buy YES on all candidates > 2¢. Skip the rest.
-
Result: You no longer hold a risk-free arb. You hold a "Bond" that pays $1.00 unless a massive longshot wins.
Handling the Math
Do not lie to your bot. If you skip legs, you must account for the Residual Risk.
- Risk = Sum(Ask_Price_of_Skipped_Legs)
Treat your payout not as $1.00, but as (1.00 - Risk). If the bundle costs 0.95 and you skipped 0.02 worth of probability, your "Bond Edge" is 0.03.
Use Case: Bond Baskets are the only executable way to trade large election markets with long tails (e.g., "Dem Nominee" with 20 candidates).
5. Execution: The FOK Policy

Even with perfect pricing, execution is non-atomic. You must send N separate orders.
-
The Risk: "Legging Risk." You fill the expensive leg (Trump), but the cheap leg (Harris) moves or vanishes before you fill it. You are now holding naked directional exposure.
-
The Tool: Fill-Or-Kill (FOK). Polymarket does not support "partial fill" limit orders in the way stock traders are used to. You should strictly use FOK (or market orders, which are implicitly FOK/FAK) to ensure binary outcomes: either you get your full size, or you get nothing. Never use standard "Good-Til-Cancelled" (GTC) orders for arb entry. GTC invites partial fills that leave you unhedged.
The Cleanup Routine
If you send 5 FOK orders and only 4 fill (because liquidity vanished on the 5th leg), you have a "broken basket."
-
Panic Unwind: Immediately sell the filled legs (taking the spread loss).
-
Accept Variance: If the missing leg is small, hold the basket as a partial Bond.
6. Why Your Bot Should Miss Trades
A mature YES package strategy will reject 90% of the "opportunities" it sees. You will see lines on a chart where the sum was $0.95, and your bot did nothing.
This is a feature, not a bug.
It likely "missed" the trade because:
-
The Bottleneck: The dust leg required $500 of capital to hedge $5 of profit.
-
The Depth: The top of the book showed 100 shares, but you needed 2,000 to validate the bottleneck leg.
-
The Tick: Rounding turned the $0.98 sum into $1.01.
If your logs say "Skipped: Insufficient Liquidity" rather than "Error: Partial Fill," you are winning. You are prioritizing survival over volume.
Summary: Engineering over Alpha
YES Packages are the "Hello World" of Polymarket bots. They are conceptually simple but operationally unforgiving.
-
Respect the Bottleneck: The cheapest leg dictates the package size.
-
Price at Size: L1 prices are fake. VWAP is real.
-
Quantize: Remember that prices move in ticks. A theoretical cost of 0.999 might round up to 1.001 on the grid.
-
Use FOK: Reject partial fills at the order level.
**Next Up:**Now that we can buy the field, how do we short it? Part 7 will cover Convert & NO Strategies: How to use the NegRisk convert function to turn "NO" shares into cash, and why "selling the winner" is often more profitable than buying the field.
Keep Building
-
Follow on X:https://x.com/ZEITFinance
-
Follow on X2:https://x.com/autonomous_af
-
Join Telegram:https://t.me/zeitfi
-
Read the Docs:https://zeit-1.gitbook.io/zeit
Continue the Series
-
→ Next (Part 6): No Arb and Convert