DEV Community

BlueWhale-Quant-Lab
BlueWhale-Quant-Lab

Posted on

Fixing Polymarket's "invalid amounts" error on the CLOB (py-clob-client)

Fixing Polymarket's "invalid amounts" error on the CLOB (py-clob-client)

If you've posted an order to Polymarket's CLOB with py-clob-client and gotten
back a flat invalid amounts — even though your size looks fine and you
rounded it to two decimals — here's what's actually going on, and a one-line fix.

The undocumented rule

A CLOB order carries two integer amounts (scaled by 1e6). Both must be whole
multiples of 10000:

makerAmount = price * size * 1_000_000     # multiple of 10000
takerAmount =         size * 1_000_000     # multiple of 10000
Enter fullscreen mode Exit fullscreen mode

round(size, 2) isn't enough. Concrete example:

price = 0.82, size = 6.25
makerAmount = 0.82 * 6.25 * 1e6 = 5_125_000
5_125_000 % 10000 = 5000   ->  invalid amounts
Enter fullscreen mode Exit fullscreen mode

The catch: the valid step for size depends on the price.

The fix

import math

def size_step_units(price):           # in 1/10000-share units
    p_int = int(round(price * 10000))
    maker_step = 1_000_000 // math.gcd(p_int, 1_000_000)
    return maker_step * 100 // math.gcd(maker_step, 100)

def round_for_fok(price, size):
    p = max(0.01, min(0.99, round(price, 2)))
    step = size_step_units(p)
    units = (int(round(size * 10000)) // step) * step or step
    return p, round(units / 10000, 4)
Enter fullscreen mode Exit fullscreen mode

round_for_fok(0.82, 6.25)(0.82, 6.0), and now both amounts are valid. I
packaged this (plus a $1 / 5-share minimum-order check) as a tiny MIT tool:
https://github.com/BlueWhale-Quant-Lab/polymarket-clob-order-amount-tick-size

Two more traps on the daily markets

  • invalid tick size — the daily ("...on June 1") markets use a 0.001 tick, not 0.01. Hard-coding tick_size="0.01" gets them rejected.
  • The 10-share minimum step — at prices like 0.999, the smallest valid size step is 10 shares, so a sub-10-share order at that price is impossible. You either round up or move the price.

And if you rest GTC orders, flooring the size loses shares to the fee skim and
can leave your two legs unbalanced (No > Yes); you want nearest-rounding with a
±tick price search instead. Those are in the PRO build
here,
but the free tool above fixes the common invalid amounts case for everyone.

(This is order-amount math — not order placement, signing, or any profit claim.)

Top comments (0)