nautechsystems/nautilus_trader · error

Polymarket collateral-sized limit BUY amount {} pUSD truncat

Error message

Polymarket collateral-sized limit BUY amount {} pUSD truncates to zero at {LOT_SIZE_SCALE} decimal places

What it means

Polymarket order amounts are expressed in pUSD collateral and quantized to LOT_SIZE_SCALE decimal places. When a collateral-sized limit BUY is converted into maker/taker amounts via compute_quote_buy_maker_taker_amounts, a very small collateral amount truncates to a maker_amount of zero. The builder rejects it up front because a zero-size order is meaningless on the venue.

Source

Thrown at crates/adapters/polymarket/src/execution/order_builder.rs:163

    /// venue-required cent quantization, and the taker amount is the share quantity derived from
    /// that exact signed amount.
    pub(crate) fn build_limit_order_from_collateral(
        &self,
        token_id: &str,
        price: Decimal,
        amount: Decimal,
        expiration: &str,
        neg_risk: bool,
        tick_decimals: u32,
    ) -> anyhow::Result<PolymarketOrder> {
        anyhow::ensure!(
            price > Decimal::ZERO,
            "Polymarket collateral-sized limit BUY price must be positive"
        );

        let (maker_amount, taker_amount) =
            compute_quote_buy_maker_taker_amounts(price, amount, tick_decimals);
        anyhow::ensure!(
            maker_amount > Decimal::ZERO,
            "Polymarket collateral-sized limit BUY amount {} pUSD truncates to zero at {LOT_SIZE_SCALE} decimal places",
            amount.normalize(),
        );
        anyhow::ensure!(
            taker_amount > Decimal::ZERO,
            "Polymarket collateral-sized limit BUY derives a zero share quantity"
        );
        anyhow::ensure!(
            taker_amount * price == maker_amount,
            "Polymarket collateral-sized limit BUY amount {} pUSD cannot preserve limit price {} after venue quantization",
            amount.normalize(),
            price.normalize(),
        );

        self.build_and_sign(
            token_id,
            PolymarketOrderSide::Buy,

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Increase the BUY collateral amount so it survives truncation at LOT_SIZE_SCALE decimal places (>= 1 unit at that scale after applying the price).
  2. Check where the amount is produced (sizer/risk module) and raise its minimum notional floor to at least the venue lot size.
  3. If truly tiny orders are needed, accumulate capital and submit fewer, larger orders instead of per-signal micro orders.

Example fix

// before
builder.build_limit_order_from_collateral(&order, price, Decimal::new(1, 4) /* 0.0001 pUSD */, ...)
// after
let amount = Decimal::new(1, 0); // >= smallest pUSD amount that survives LOT_SIZE_SCALE truncation
builder.build_limit_order_from_collateral(&order, price, amount, ...)
Defensive patterns

Strategy: validation

Validate before calling

let min_amount = Decimal::ONE / LOT_SIZE_SCALE.powu(TICK_SCALE) /* one quantized unit in pUSD */;
if amount < min_amount { return Err(format!("amount {amount} below min {min_amount} pUSD")); }

Type guard

fn is_tradeable_collateral(amount: Decimal, lot_size_scale: u32) -> bool {
    amount > Decimal::ZERO && amount.round_dp(lot_size_scale as u32) > Decimal::ZERO
}

Prevention

When it happens

Trigger: Calling build_limit_order_from_collateral with a BUY amount so small that, scaled by the limit price and truncated to LOT_SIZE_SCALE decimals, maker_amount <= 0 (e.g. amounts in the sub-cent range at typical LOT_SIZE_SCALE).

Common situations: Position-sizing or risk code computing a collateral budget that rounds down to a tiny value; converting a notional from another unit (e.g. USD cents) without accounting for pUSD precision; test fixtures using amount values like 0.0001 pUSD.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/372a81408abaf1eb. Report an issue: GitHub.