protection_price_calculate

Function protection_price_calculate 

Source
pub fn protection_price_calculate(
    price_increment: Price,
    order: &OrderAny,
    protection_points: Option<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..

§Returns

A calculated protection price.

§Errors

Returns an error if:

  • the order type is invalid.
  • protection points or best bid/ask are provided but not valid

§Panics

Panics if the values required for calculation cannot be converted to a float.