Skip to main content

Module financial

Module financial 

Source
Expand description

Financial types with enhanced type safety (Price, Amount, Cost) Financial calculation type definitions.

Provides type-safe financial wrappers that prevent unit confusion and precision loss. Uses the newtype pattern to implement zero-cost abstractions with compile-time type checking.

§Examples

use ccxt_core::types::financial::{Price, Amount, Cost};
use rust_decimal_macros::dec;

let price = Price::new(dec!(50000.0));
let amount = Amount::new(dec!(0.1));
let cost = price * amount;  // Type-safe: Price × Amount = Cost

assert_eq!(cost.as_decimal(), dec!(5000.0));

Modules§

decimal_utils
Decimal parsing and formatting utilities.

Structs§

Amount
Amount type (zero-cost wrapper).
Cost
Cost type (zero-cost wrapper).
Price
Price type (zero-cost wrapper).