{"record":{"id":"811e9feff2b6ad5f","repo":"nautechsystems/nautilus_trader","slug":"last-required","errorCode":null,"errorMessage":"Last required","messagePattern":"Last required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/execution/src/trailing.rs","lineNumber":155,"sourceCode":"                ask.ok_or_else(|| anyhow::anyhow!(\"Ask required\"))?,\n            );\n            let basis = match order_side {\n                OrderSide::Buy => ask,\n                OrderSide::Sell => bid,\n            };\n            let cand_trigger = compute(trailing_offset, basis)?;\n            new_trigger_price = maybe_move(&mut trigger_price, cand_trigger, better_trigger);\n\n            if order_type == OrderType::TrailingStopLimit {\n                let limit_offset = order.limit_offset().ok_or_else(|| {\n                    anyhow::anyhow!(\"Missing `limit_offset` for trailing stop limit calculation\")\n                })?;\n                let cand_limit = compute(limit_offset, basis)?;\n                new_limit_price = maybe_move(&mut limit_price, cand_limit, better_limit);\n            }\n\n            if trigger_type == TriggerType::LastOrBidAsk {\n                let last = last.ok_or_else(|| anyhow::anyhow!(\"Last required\"))?;\n                let cand_trigger = compute(trailing_offset, last)?;\n                let updated = maybe_move(&mut trigger_price, cand_trigger, better_trigger);\n                if updated.is_some() {\n                    new_trigger_price = updated;\n                }\n\n                if order_type == OrderType::TrailingStopLimit {\n                    let limit_offset = order.limit_offset().ok_or_else(|| {\n                        anyhow::anyhow!(\n                            \"Missing `limit_offset` for trailing stop limit calculation\"\n                        )\n                    })?;\n                    let cand_limit = compute(limit_offset, last)?;\n                    let updated = maybe_move(&mut limit_price, cand_limit, better_limit);\n                    if updated.is_some() {\n                        new_limit_price = updated;\n                    }\n                }","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/execution/src/trailing.rs#L137-L173","documentation":"Raised by trailing_stop_calculate in crates/execution/src/trailing.rs when a trailing stop order uses TriggerType::LastOrBidAsk but no last traded price was supplied. In this mode the trigger price must be computed from the last price, so a None value makes the calculation impossible and the function fails fast with anyhow. It protects against silently computing a trigger from wrong data.","triggerScenarios":"Calling trailing_stop_calculate (directly or via update_trailing_stop_order) with order_type TrailingStop/TrailingStopLimit, trigger_type TriggerType::LastOrBidAsk, and last: None in the calculation inputs.","commonSituations":"Feeding market data that has no trade ticks (quote-only instruments), wiring only bid/ask into the calculator while the order expects last-price triggers, or leaving the last price field unset after a data gap at the start of a session.","solutions":["Supply the last traded price in the calculation inputs when trigger_type is LastOrBidAsk","Switch the order's trigger type to a bid/ask-based trigger (e.g. BidOrLast/Crossing) if only quotes are available","Guard the call site: fetch the latest trade tick and skip/error before calling if none exists","Verify the data feed actually emits trade ticks for the instrument"],"exampleFix":"// before\nlet calc = trailing_stop_calculate(&order, bid, ask, None, ...)?;\n// after\nlet last = last_trade_price.ok_or_else(|| anyhow::anyhow!(\"no last price for LastOrBidAsk trigger\"))?;\nlet calc = trailing_stop_calculate(&order, bid, ask, Some(last), ...)?;","handlingStrategy":"validation","validationCode":"if order.trigger_type() == TriggerType::LastOrBidAsk && last.is_none() {\n    return Err(anyhow::anyhow!(\"LastOrBidAsk trigger requires a last traded price\"));\n}","typeGuard":"fn has_last_price(last: Option<Price>) -> bool { last.is_some() }","tryCatchPattern":null,"preventionTips":["Always populate the last trade price for LastOrBidAsk trigger orders","Choose trigger types matching the available market data feed","Add construction-time checks tying trigger_type to provided inputs"],"tags":["trailing-stop","missing-price","execution"],"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-14T00:17:10.932Z"}