{"record":{"id":"5b738ae2a3c97672","repo":"nautechsystems/nautilus_trader","slug":"signed-limit-order-share-quantity-signed-base-qty-5b738a","errorCode":null,"errorMessage":"Signed limit order share quantity {signed_base_qty} cannot be represented exactly at instrument size precision {}","messagePattern":"Signed limit order share quantity (.+?) cannot be represented exactly at instrument size precision (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/submitter.rs","lineNumber":480,"sourceCode":"                request.price.as_decimal(),\n                request.quantity.as_decimal(),\n                order_type,\n                &expiration,\n                request.neg_risk,\n                request.tick_decimals,\n            )\n        }\n        .map_err(|e| anyhow::anyhow!(\"{e}\"))?;\n\n        let signed_base_qty = signed_base_quantity(order.maker_amount, order.taker_amount, side);\n        let expected_base_qty =\n            Quantity::from_decimal_dp(signed_base_qty, request.size_precision).map_err(|e| {\n                anyhow::anyhow!(\n                    \"Signed limit order share quantity {signed_base_qty} is invalid at instrument size precision {}: {e}\",\n                    request.size_precision,\n                )\n            })?;\n        anyhow::ensure!(\n            expected_base_qty.as_decimal() == signed_base_qty,\n            \"Signed limit order share quantity {signed_base_qty} cannot be represented exactly at instrument size precision {}\",\n            request.size_precision,\n        );\n\n        let expected_venue_order_id = self\n            .order_builder\n            .expected_order_id(&order, request.neg_risk)?;\n\n        Ok(SignedLimitOrderSubmission {\n            order,\n            order_type,\n            post_only: request.post_only,\n            expected_venue_order_id,\n            expected_base_qty,\n        })\n    }\n","sourceCodeStart":462,"sourceCodeEnd":498,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/submitter.rs#L462-L498","documentation":"Raised via anyhow::ensure! in `prepare_limit_order_submission` when the signed share quantity decoded from the venue amounts is not exactly representable at the instrument's size_precision — i.e. `Quantity::from_decimal_dp` produced a value that differs from the raw signed decimal. The adapter refuses to submit an order whose reported fill quantity could differ from what was signed, preventing silent rounding drift between the venue amounts and Nautilus quantity tracking.","triggerScenarios":"Builder rounding leaves the signed base quantity with more decimal places than size_precision (e.g. signed qty 0.123 shares on an instrument with size_precision 2); size precision misconfigured relative to the builder's rounding step.","commonSituations":"Trading instruments whose size_precision in config doesn't match the venue's real tick/size granularity; custom sizing engines producing odd share amounts; tick-size changes on Polymarket markets altering rounding behavior.","solutions":["Align size_precision in the instrument definition with the decimals the builder rounds shares to","Round the requested order size to size_precision before submission","Re-fetch current market metadata if the venue changed its tick/size granularity"],"exampleFix":"// before\nlet qty = Quantity::from_decimal_dp(dec!(0.123), 2); // 0.123 != 0.12 -> error\n// after: round the order size first\nlet qty = Quantity::from_decimal_dp(dec!(0.12), 2);","handlingStrategy":"validation","validationCode":"if Quantity::from_decimal_dp(signed_qty, size_precision).map(|q| q.as_decimal()) != Ok(signed_qty) {\n    return Err(anyhow!(\"qty {signed_qty} not exact at precision {size_precision}\"));\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = prepare_limit_order_submission(&req).await {\n    if e.to_string().contains(\"cannot be represented exactly\") {\n        // round the requested size to size_precision and retry once\n    }\n}","preventionTips":["Round order sizes to size_precision before submission","Keep builder rounding step and instrument size_precision in sync","Re-check metadata when the venue changes tick/size granularity"],"tags":["polymarket","precision","rounding","limit-order"],"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"}