{"record":{"id":"9c96357888729fb6","repo":"nautechsystems/nautilus_trader","slug":"trailingstoplimit-order-price-not-set","errorCode":null,"errorMessage":"TrailingStopLimit order price not set","messagePattern":"TrailingStopLimit order price not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/orders/any.rs","lineNumber":319,"sourceCode":"    StopLimit(StopLimitOrder),\n    TrailingStopLimit(TrailingStopLimitOrder),\n    MarketOrderWithProtection(MarketOrder),\n}\n\nimpl LimitOrderAny {\n    /// Returns the limit price for this order.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the `MarketToLimit` order price is not set.\n    #[must_use]\n    pub fn limit_px(&self) -> Price {\n        match self {\n            Self::Limit(order) => order.price,\n            Self::MarketToLimit(order) => order.price.expect(\"MarketToLimit order price not set\"),\n            Self::StopLimit(order) => order.price,\n            Self::TrailingStopLimit(order) => {\n                order.price.expect(\"TrailingStopLimit order price not set\")\n            }\n            Self::MarketOrderWithProtection(order) => {\n                order.protection_price.expect(\"No price for order\")\n            }\n        }\n    }\n}\n\nimpl PartialEq for LimitOrderAny {\n    fn eq(&self, rhs: &Self) -> bool {\n        match self {\n            Self::Limit(order) => order.client_order_id == rhs.client_order_id(),\n            Self::MarketToLimit(order) => order.client_order_id == rhs.client_order_id(),\n            Self::StopLimit(order) => order.client_order_id == rhs.client_order_id(),\n            Self::TrailingStopLimit(order) => order.client_order_id == rhs.client_order_id(),\n            Self::MarketOrderWithProtection(order) => {\n                order.client_order_id == rhs.client_order_id()\n            }","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/orders/any.rs#L301-L337","documentation":"OrderAny::limit_px unwraps the Option<Price> on TrailingStopLimit orders; a trailing stop-limit only gets a concrete limit price once triggered/initialized with one, so calling limit_px while price is None panics with 'TrailingStopLimit order price not set'.","triggerScenarios":"Calling OrderAny::limit_px() on an OrderAny::TrailingStopLimit whose price field is None (constructed without an explicit price, or before activation/trigger).","commonSituations":"Portfolio or reconciliation code enumerating prices for all open orders including trailing stop-limits built with only activation/trailing offsets, assuming a limit price always exists.","solutions":["Ensure trailing stop-limit orders are created with a price (via builder .price(...)) when you intend to read limit_px later.","Branch on the order variant and treat trailing stop-limit price as optional.","Defer limit_px calls until the order has been activated and holds a price."],"exampleFix":"// before\nlet px = order.limit_px(); // panics for TrailingStopLimit without price\n// after\nlet px = if let OrderAny::TrailingStopLimit(o) = &order { o.price } else { Some(order.limit_px()) };","handlingStrategy":"type-guard","validationCode":"let px = if let OrderAny::TrailingStopLimit(o) = &order {\n    o.price\n} else {\n    Some(order.limit_px())\n};","typeGuard":"fn trailing_limit_price(order: &OrderAny) -> Option<Price> {\n    match order {\n        OrderAny::TrailingStopLimit(o) => o.price,\n        _ => None,\n    }\n}","tryCatchPattern":"// guard the variant; limit_px panics rather than returning Err\nif let OrderAny::TrailingStopLimit(o) = &order {\n    if let Some(px) = o.price { /* use px */ }\n}","preventionTips":["Supply a price when constructing TrailingStopLimit orders that will later be price-queried.","Treat trailing stop-limit price as optional until the order is activated.","Centralize price extraction in one helper instead of calling limit_px everywhere."],"tags":["rust","panic","optional-price","trailing-stop-limit"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}