pub fn trailing_stop_calculate(
price_increment: Price,
trigger_px: Option<Price>,
order: &OrderAny,
bid: Option<Price>,
ask: Option<Price>,
last: Option<Price>,
) -> Result<(Option<Price>, Option<Price>)>Expand description
Calculates the new trigger and limit prices for a trailing stop order.
trigger_px is an optional override for the trigger price already carried inside
order. If Some(_), it takes priority over the value on the order itself, otherwise
the function falls back to the value stored on the order.
§Returns
A tuple with the newly-set trigger-price and limit-price (if any).
None in either position means the respective price did not improve.
§Errors
Returns an error if:
- the order type, trigger type, or trailing offset type is invalid.
- the order lacks a required trigger, trailing offset, trailing offset type, or limit offset.
- the calculated price cannot be represented as a [
Price].