The Problem
Standardf64 floating-point causes rounding errors:
- Incorrect P&L
- Failed reconciliation
- Checksum mismatches
- Audit failures
The Solution
Havklo usesrust_decimal throughout:
rust_decimal provides 96-bit decimal representation with up to 28 significant digits - the same precision as .NET’s decimal type.Where It Matters
Every price and quantity in Havklo isDecimal:
Scientific Notation
Kraken sometimes sends very small numbers in scientific notation:Performance
Decimal is slower than f64, but still fast:
Best Practices
1
Use the dec! macro
2
Keep calculations in Decimal
3
Format for display, don't convert