Expand description
§atomr-money
Exact-decimal monetary primitives for the atomr substrate.
Financial consumers (NAV/GL, OMS fills, fees, PnL/Greeks) need exact money
arithmetic — f64 money is a regulatory and P&L-correctness defect. This
crate provides a Money type over rust_decimal::Decimal (128-bit)
behind a domain-safe API:
- No defaulted
f64constructor. Lossyf64ingestion exists only behind the off-by-defaultf64-lossyfeature. - String (de)serialization, never float.
Money/Price/Qtyserialize their amount as a decimal string so nothing is lost in transit or at rest. - Checked arithmetic. Currency mismatch and overflow return
MoneyError— never a panic or silent truncation.
use atomr_money::{Money, Currency};
let a = Money::from_str_amount("10.25", Currency::USD).unwrap();
let b = Money::from_minor(75, Currency::USD); // 0.75
assert_eq!(a.checked_add(&b).unwrap().to_minor(), 1100);Structs§
- Currency
- A currency identified by its ISO 4217 alphabetic code plus the number of minor units (decimal places) it conventionally uses.
- Decimal
- Re-export of the backing decimal type so consumers can construct exact
amounts without taking a direct
rust_decimaldependency.Decimalrepresents a 128 bit representation of a fixed-precision decimal number. The finite set of values of typeDecimalare of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive. - Money
- An exact monetary amount in a specific
Currency. - Price
- An instrument price. Serializes as a decimal string (never a float).
- Qty
- An order/position quantity. Serializes as a decimal string (never a float).
Enums§
- Money
Error - Failures from
Moneyoperations. Arithmetic is always checked: currency mismatch and overflow are errors, never panics or silent truncation. - Rounding
Mode - Rounding mode for
Money::round. Maps ontorust_decimal’s strategies.