pub fn precise_down(
value: Decimal,
step: Decimal,
) -> Result<Decimal, PrecisionError>Expand description
Rounds a value down to the step grid.
Typical for a buy price: never pay more than the computed value.
§Errors
The same as value_to_steps_nearest.
§Examples
use brokapi_bcs_protocol::utils::precision::precise_down;
use rust_decimal::Decimal;
assert_eq!(precise_down(Decimal::new(10103, 2), Decimal::new(5, 2))?, Decimal::new(10100, 2));
// a whole-number step works too
assert_eq!(precise_down(Decimal::new(143, 1), Decimal::from(5))?, Decimal::from(10));