Rust does not allow ordering of f32/f64s as part of std. This prevents using f64 as a key in BTreeMap<f64, OrderbookLevel>.
For now, we should just use this (https://crates.io/crates/ordered-float), but I'm curious on the performance difference between.
- Implementing
PartialOrd for floats as above
- Having serde deserialise 'float-like' data straight to
Decimal
- Having serde deserialise to
f64, but converting to Decimal when returning MarketDataKind:L2Update/Snapshot
- Storing prices as
u64 with a mantissa on the number of floating points as a separate piece of metadata (like smart contracts)
This is definitely a low-priority premature micro-optimisation!
Rust does not allow ordering of
f32/f64s as part of std. This prevents usingf64as a key inBTreeMap<f64, OrderbookLevel>.For now, we should just use this (https://crates.io/crates/ordered-float), but I'm curious on the performance difference between.
PartialOrdfor floats as aboveDecimalf64, but converting toDecimalwhen returningMarketDataKind:L2Update/Snapshotu64with a mantissa on the number of floating points as a separate piece of metadata (like smart contracts)This is definitely a low-priority premature micro-optimisation!