{"record":{"id":"a2043ed4fd2849a2","repo":"nautechsystems/nautilus_trader","slug":"polymarket-collateral-sized-limit-buy-derives-a-ze","errorCode":null,"errorMessage":"Polymarket collateral-sized limit BUY derives a zero share quantity","messagePattern":"Polymarket collateral-sized limit BUY derives a zero share quantity","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/order_builder.rs","lineNumber":168,"sourceCode":"        price: Decimal,\n        amount: Decimal,\n        expiration: &str,\n        neg_risk: bool,\n        tick_decimals: u32,\n    ) -> anyhow::Result<PolymarketOrder> {\n        anyhow::ensure!(\n            price > Decimal::ZERO,\n            \"Polymarket collateral-sized limit BUY price must be positive\"\n        );\n\n        let (maker_amount, taker_amount) =\n            compute_quote_buy_maker_taker_amounts(price, amount, tick_decimals);\n        anyhow::ensure!(\n            maker_amount > Decimal::ZERO,\n            \"Polymarket collateral-sized limit BUY amount {} pUSD truncates to zero at {LOT_SIZE_SCALE} decimal places\",\n            amount.normalize(),\n        );\n        anyhow::ensure!(\n            taker_amount > Decimal::ZERO,\n            \"Polymarket collateral-sized limit BUY derives a zero share quantity\"\n        );\n        anyhow::ensure!(\n            taker_amount * price == maker_amount,\n            \"Polymarket collateral-sized limit BUY amount {} pUSD cannot preserve limit price {} after venue quantization\",\n            amount.normalize(),\n            price.normalize(),\n        );\n\n        self.build_and_sign(\n            token_id,\n            PolymarketOrderSide::Buy,\n            maker_amount,\n            taker_amount,\n            expiration,\n            neg_risk,\n        )","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/order_builder.rs#L150-L186","documentation":"For a collateral-sized limit BUY, the share quantity is derived as the collateral divided by the price, quantized at LOT_SIZE_SCALE. If that quotient truncates to zero (taker_amount <= 0), the builder throws: it cannot express an order that buys at least one tick-sized share unit with the given collateral.","triggerScenarios":"build_limit_order_from_collateral with an amount/price ratio below one LOT_SIZE_SCALE unit — e.g. 0.05 pUSD at price 0.99 when quantities are quantized to fine decimals, or any amount smaller than price * minimum share increment.","commonSituations":"Very small capital allocations per order; a price close to 1.0 (high-probability markets) shrinking the derived share quantity; a misconfigured LOT_SIZE_SCALE/tick_decimals making the minimum tradable quantity larger than expected.","solutions":["Raise the BUY collateral amount so amount/price is at least one quantized share unit at LOT_SIZE_SCALE.","Verify tick_decimals/LOT_SIZE_SCALE passed to compute_quote_buy_maker_taker_amounts match the venue market's actual tick size.","Skip submitting the order when the derived quantity is below the venue minimum and log it instead of erroring."],"exampleFix":"// before\nlet amount = Decimal::new(1, 2); // 0.01 pUSD, yields zero shares at price 0.99\nbuilder.build_limit_order_from_collateral(&order, price, amount, tick_decimals)?;\n// after\nlet amount = price * min_share_quantity; // ensure amount/price >= 1 quantized unit\nbuilder.build_limit_order_from_collateral(&order, price, amount, tick_decimals)?;","handlingStrategy":"validation","validationCode":"let derived_shares = (amount / price).round_dp(lot_size_scale);\nif derived_shares <= Decimal::ZERO { return Err(\"collateral too small for one share unit at this price\".into()); }","typeGuard":"fn yields_positive_shares(amount: Decimal, price: Decimal, dp: u32) -> bool {\n    price > Decimal::ZERO && (amount / price).round_dp(dp) > Decimal::ZERO\n}","tryCatchPattern":null,"preventionTips":["Check amount/price against the minimum share quantity before submission.","Validate price is in (0,1) and tick_decimals matches the market definition.","Add a pre-trade checklist that skips (not errors) sub-minimum orders."],"tags":["polymarket","decimal-precision","order-building","quantization"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}