aboutsummaryrefslogtreecommitdiff
path: root/src/app/store
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/store')
-rw-r--r--src/app/store/records.rs15
1 files changed, 3 insertions, 12 deletions
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<Context> =
- std::sync::LazyLock::new(|| Context::default().with_rounding_mode(ROUNDING_MODE));
+use bigdecimal::BigDecimal;
type DateTime = chrono::DateTime<chrono::Utc>;
@@ -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]