Skip to main content

Module normalization

Module normalization 

Source
Expand description

Canonical event normalization — typed conversion from raw exchange events to a strict shape suitable for indicators/storage/backtest.

§Invariants

  • price / quantity fields are rust_decimal::Decimal — no f64 rounding.
  • timestamp_ms is always UTC milliseconds regardless of source unit (s / ms / µs / ns).
  • side uses TradeSide (Buy/Sell) for trades.
  • symbol is raw exchange-native (from Phase α — no internal normalization here).

§Usage

use digdigdig3::core::normalization::{Canonicalize, CanonicalEvent};

// Given a StreamEvent from any exchange WebSocket:
// if let Some(canonical) = event.canonicalize() {
//     match canonical {
//         CanonicalEvent::Trade(t) => println!("price={} qty={}", t.price, t.quantity),
//         _ => {}
//     }
// }

Structs§

CanonicalKline
Canonical OHLCV kline.
CanonicalLevel
A single canonical price level (bid or ask).
CanonicalOrderbook
Canonical orderbook snapshot.
CanonicalOrderbookDelta
Canonical incremental orderbook update.
CanonicalTicker
Canonical 24-hour ticker snapshot.
CanonicalTrade
Canonical trade — every field strict, no nulls, no f64.

Enums§

CanonicalEvent
Unified canonical event — output of Canonicalize on StreamEvent.

Traits§

Canonicalize
Conversion to a canonical typed form.

Functions§

normalize_ts_to_ms
Normalize a raw exchange timestamp to UTC milliseconds.