{"record":{"id":"b1cac01c9844fe05","repo":"nautechsystems/nautilus_trader","slug":"trailing-offset-type-not-set","errorCode":null,"errorMessage":"Trailing offset type not set","messagePattern":"Trailing offset type not set","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/orders/builder.rs","lineNumber":257,"sourceCode":"    // ----------- TrailingOffset ----------\n    pub fn trailing_offset(&mut self, trailing_offset: Decimal) -> &mut Self {\n        self.trailing_offset = Some(trailing_offset);\n        self\n    }\n\n    fn get_trailing_offset(&self) -> Decimal {\n        self.trailing_offset.expect(\"Trailing offset not set\")\n    }\n\n    // ----------- TrailingOffsetType ----------\n    pub fn trailing_offset_type(&mut self, trailing_offset_type: TrailingOffsetType) -> &mut Self {\n        self.trailing_offset_type = Some(trailing_offset_type);\n        self\n    }\n\n    fn get_trailing_offset_type(&self) -> TrailingOffsetType {\n        self.trailing_offset_type\n            .expect(\"Trailing offset type not set\")\n    }\n\n    // ----------- TimeInForce ----------\n    pub fn time_in_force(&mut self, time_in_force: TimeInForce) -> &mut Self {\n        self.time_in_force = Some(time_in_force);\n        self\n    }\n\n    fn get_time_in_force(&self) -> TimeInForce {\n        self.time_in_force.unwrap_or(TimeInForce::Gtc)\n    }\n\n    // ----------- ExpireTime ----------\n    pub fn expire_time(&mut self, expire_time: UnixNanos) -> &mut Self {\n        self.expire_time = Some(expire_time);\n        self\n    }\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/orders/builder.rs#L239-L275","documentation":"OrderBuilder accumulates optional fields via fluent setters and unwraps them in getters during build(). get_trailing_offset_type() panics because trailing_offset_type was never set with .trailing_offset_type(...) before build() was called. It is a programmer-error guard ensuring trailing-stop orders always carry a defined TrailingOffsetType.","triggerScenarios":"Calling OrderBuilder::build() for an order configured as a trailing-stop / trailing-stop-market (or otherwise relying on trailing offset) without first invoking builder.trailing_offset_type(TrailingOffsetType::...).","commonSituations":"Copying builder setup code between order types and dropping the trailing_offset_type line; wiring builder fields from config where the trailing-offset enum is missing from strategy config; refactoring that renamed the setter but left the call site unset.","solutions":["Call .trailing_offset_type(TrailingOffsetType::BasisPoints /* or Price, Ticks, etc. */) on the builder before build()","If the order is not a trailing order, verify build() is only reached with a trailing_offset_type set when the order type requires one (e.g. OrderType::TrailingStopMarket)","Source the value from strategy config and fail fast at config-load time if absent"],"exampleFix":"// before\nlet order = OrderBuilder::new(...)\n    .order_type(OrderType::TrailingStopMarket)\n    .build();\n// after\nlet order = OrderBuilder::new(...)\n    .order_type(OrderType::TrailingStopMarket)\n    .trailing_offset_type(TrailingOffsetType::BasisPoints)\n    .build();","handlingStrategy":"validation","validationCode":"// Rust: before build()\nassert!(order_type != OrderType::TrailingStopMarket || builder_has_trailing_offset_type(&builder),\n    \"trailing offset type required for trailing orders\");","typeGuard":"fn has_trailing_offset(b: &OrderBuilder) -> bool { /* expose/peek trailing_offset_type.is_some() */ }","tryCatchPattern":null,"preventionTips":["Always chain .trailing_offset_type(...) whenever .trailing_stop_* or trailing order types are used","Build orders through one helper that takes a typed config struct containing TrailingOffsetType","Fail at config-load time when trailing offset config is missing for trailing strategies"],"tags":["rust","builder-pattern","panic","orders"],"backgroundTag":"missing-required-argument","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"}