nautechsystems/nautilus_trader · error
Polymarket collateral-sized limit BUY price must be positive
Error message
Polymarket collateral-sized limit BUY price must be positive
What it means
`build_limit_order_from_collateral` builds a collateral-sized (quote-amount) limit BUY order for Polymarket. Polymarket CLOB orders are price*amount based, so a non-positive price would produce zero or negative maker/taker amounts. `anyhow::ensure!` rejects any price <= 0 with this message before computing order amounts.
Source
Thrown at crates/adapters/polymarket/src/execution/order_builder.rs:156
neg_risk,
)
}
/// Builds and signs a collateral-sized limit BUY for submission.
///
/// `amount` is the pUSD collateral to spend. The signed maker amount is the collateral after
/// 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",View on GitHub (pinned to 18893faf8b)
Solutions
- Ensure the order price is positive before submission; fetch/refresh market data so a real last/best price is available
- Validate the instrument's price precision/tick_decimals config so prices don't round to zero
- Guard the strategy to skip the order when no valid price exists
- Check Decimal scale/rounding upstream that could reduce a small price to 0
Example fix
// before
let order = client.build_limit_order_from_collateral(
OrderSide::Buy, price_from_stale_feed, amount, ...)?;
// after
anyhow::ensure!(price_from_stale_feed > Decimal::ZERO, "no valid price");
let order = client.build_limit_order_from_collateral(
OrderSide::Buy, price_from_stale_feed, amount, ...)?; Defensive patterns
Strategy: validation
Validate before calling
use rust_decimal::Decimal;
fn validate_buy_price(price: Decimal) -> Result<(), String> {
if price <= Decimal::ZERO { Err(format!("price must be positive, got {price}")) } else { Ok(()) }
} Try / catch
match adapter.submit_order(order).await {
Err(e) if e.to_string().contains("price must be positive") => {
tracing::warn!("skipping order with invalid price");
}
other => other?,
} Prevention
- Validate price > 0 in the strategy before submitting orders
- Keep market data fresh so derived prices never fall to zero
- Check price precision/tick_decimals config to avoid rounding to zero
When it happens
Trigger: Submitting a market BUY order that internally converts to a limit order when the computed/last price is 0 (e.g. no market data available); passing price=0 or a negative Decimal directly through the order path; a bug or division-by-zero upstream yielding 0 price.
Common situations: Trading a thin/illiquid market where best bid/ask is missing so derived price is 0; instrument configured with wrong tick/price precision causing rounded-to-zero prices; feeding a strategy unvalidated prices before adapter submission.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- fee rate must be non-negative
- fee price must be in [0, 1]
- market amount must be positive
- market-book size must be non-negative
- {field} {value} must be greater than zero and less than one
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/b759478629d219e3.
Report an issue: GitHub.