{"record":{"id":"481973eb97ac8eed","repo":"nautechsystems/nautilus_trader","slug":"client-bound-polymarket-reports-require-a-cached-b","errorCode":null,"errorMessage":"client-bound Polymarket reports require a cached base-denominated Limit order","messagePattern":"client-bound Polymarket reports require a cached base-denominated Limit order","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reports.rs","lineNumber":75,"sourceCode":"};\n\n#[derive(Clone)]\nstruct TargetOrderAuthority {\n    client_order_id: Option<ClientOrderId>,\n    cached_order: Option<OrderAny>,\n    instrument_id: Option<InstrumentId>,\n    order_side: Option<OrderSide>,\n}\n\nimpl TargetOrderAuthority {\n    fn require_cached_base_limit(&self, venue_order_id: VenueOrderId) -> anyhow::Result<&OrderAny> {\n        let client_order_id = self.client_order_id.with_context(|| {\n            format!(\"venue order {venue_order_id} has no known client association\")\n        })?;\n        let cached_order = self.cached_order.as_ref().with_context(|| {\n            format!(\"client-bound order report requires cached order {client_order_id}\")\n        })?;\n        anyhow::ensure!(\n            cached_order.order_type() == OrderType::Limit && !cached_order.is_quote_quantity(),\n            \"client-bound Polymarket reports require a cached base-denominated Limit order\",\n        );\n        Ok(cached_order)\n    }\n}\n\nimpl PolymarketExecutionClient {\n    pub(super) fn fill_context(&self) -> FillContext<'_> {\n        let user_address = self\n            .secrets\n            .funder\n            .as_deref()\n            .unwrap_or(&self.secrets.address);\n        FillContext {\n            account_id: self.core.account_id,\n            user_address,\n            api_key: self.secrets.credential.api_key_str(),","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reports.rs#L57-L93","documentation":"`require_cached_base_limit` resolves the cached Nautilus order backing a client-bound Polymarket report. Polymarket adapter accounting only supports base-denominated Limit orders for report processing, so if the cached order is missing, not a `Limit` order, or uses quote-quantity denomination, the adapter raises this error via `anyhow::ensure!`.","triggerScenarios":"Raised in `require_cached_base_limit` when generating client-bound order status or fill reports (e.g. generate_order_status_report / generate_fill_reports) where: (a) the order for the resolved client_order_id is not in the execution cache, (b) the order was submitted as Market, or (c) the Limit order was submitted with `quote_quantity=true`.","commonSituations":"Submitting Market orders to Polymarket and later querying their status/fills through report generation; creating Limit orders with quote-denominated quantities (wrong OrderFactory settings); cache lost after a node restart without reconciliation of persisted state; mixing adapters where the cached order type differs from the venue order.","solutions":["Submit only base-denominated Limit orders when the strategy relies on client-bound Polymarket reports: use OrderFactory.limit with default (base) quantity denomination and `quote_quantity=False`.","Ensure the execution cache is warm — restore persisted cache state or run reconciliation after restart before requesting order status/fill reports.","Verify the order type of the cached order for the given client_order_id; Market or other order types are unsupported here, so re-route those queries to venue-only (non client-bound) report generation.","Check adapter version: if a strategy legitimately needs quote-denominated orders, upgrade to a build that supports the required denomination or change strategy sizing to base units."],"exampleFix":"// before: quote-denominated limit order breaks report generation\norder = self.order_factory.limit(\n    instrument_id,\n    order_side=OrderSide.BUY,\n    quantity=self.instrument.make_qty(100.0),  # interpreted as quote qty via make_qty with quote_quantity=True\n    price=self.instrument.make_price(0.55),\n    quote_quantity=True,\n)\n// after: base-denominated limit order required by Polymarket reports\norder = self.order_factory.limit(\n    instrument_id,\n    order_side=OrderSide.BUY,\n    quantity=self.instrument.make_qty(100.0),\n    price=self.instrument.make_price(0.55),\n)","handlingStrategy":"type-guard","validationCode":"order = self.cache.order(client_order_id)\nif order is None:\n    raise ValueError(f\"order {client_order_id} not in cache; restore cache before report generation\")\nif order.order_type != OrderType.LIMIT or order.is_quote_quantity:\n    raise ValueError(\n        f\"order {client_order_id} must be a base-denominated Limit order \"\n        f\"(got {order.order_type}, quote_quantity={order.is_quote_quantity})\"\n    )","typeGuard":"def is_base_denominated_limit(order) -> bool:\n    return (\n        order is not None\n        and order.order_type == OrderType.LIMIT\n        and not order.is_quote_quantity\n    )","tryCatchPattern":"try:\n    report = client.generate_order_status_reports(...)\nexcept Exception as e:\n    if \"base-denominated Limit order\" in str(e):\n        log.error(\"Polymarket reports need cached base-denominated Limit orders; \"\n                  \"check OrderFactory settings and cache warm-up\")\n    raise","preventionTips":["Use OrderFactory.limit with quote_quantity=False (the default) for Polymarket orders","Do not submit Market orders to Polymarket if the strategy later queries client-bound reports","Warm the execution cache (persist/restore state) before generating reports after a restart","Unit-test order factories in the strategy so order type/denomination regressions surface early"],"tags":["polymarket","order-cache","order-type","report-generation"],"backgroundTag":"resource-not-found","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"}