From bdd5748b41a6e85c1e8a3cd991c55c0890e39e24 Mon Sep 17 00:00:00 2001 From: Kevin Hoerr Date: Tue, 21 Apr 2026 18:17:31 -0400 Subject: records.rs: Remove unnecessary use of bigdecimal Context --- src/app/store/records.rs | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/app/store/records.rs b/src/app/store/records.rs index fd7fec6..4e85fc1 100644 --- a/src/app/store/records.rs +++ b/src/app/store/records.rs @@ -1,10 +1,4 @@ -use bigdecimal::{BigDecimal, Context, RoundingMode}; -use std::sync::LazyLock; - -pub static ROUNDING_MODE: RoundingMode = RoundingMode::HalfEven; -/// Will use default precision (either 100 or ${RUST_BIGDECIMAL_DEFAULT_PRECISION}) -pub static DECIMAL_CONTEXT: LazyLock = - std::sync::LazyLock::new(|| Context::default().with_rounding_mode(ROUNDING_MODE)); +use bigdecimal::BigDecimal; type DateTime = chrono::DateTime; @@ -111,10 +105,7 @@ impl EquityChangeEvent { /// Provides an estimate of the numerated change based on the cost basis /// of the equity and the quantity pub fn estimated_price(&self) -> BigDecimal { - DECIMAL_CONTEXT.multiply( - &self.equity_change_cost_basis, - &DECIMAL_CONTEXT.invert(&self.equity_change_quantity), - ) + self.equity_change_cost_basis.clone() / self.equity_change_quantity.clone() } /// Provides the quantity of the event relativized by the event type's score @@ -133,7 +124,7 @@ mod tests { use std::str::FromStr; fn nat(num: BigDecimal) -> BigDecimal { - num.with_scale_round(2_i64, ROUNDING_MODE) + num.with_scale_round(2_i64, bigdecimal::RoundingMode::HalfEven) } #[test] -- cgit v1.3