Skip to main content

protection_price_calculate

Function protection_price_calculate 

Source
pub fn protection_price_calculate(
    price_increment: Price,
    order: &OrderAny,
    protection_points: u32,
    bid: Option<Price>,
    ask: Option<Price>,
) -> Result<Price>
Expand description

Calculates the protection price for stop limit and stop market orders using best bid or ask price.

Uses checked fixed-point arithmetic to preserve all stored price units.

§Returns

A calculated protection price.

§Errors

Returns an error if:

  • the order type is invalid.
  • best bid/ask is not provided when required for the order side.
  • the calculated price is outside the representable range.