Skip to main content

derive_trade_id

Function derive_trade_id 

Source
pub fn derive_trade_id(
    symbol: Ustr,
    ts_event_ns: u64,
    price: &str,
    amount: &str,
    side: &str,
) -> TradeId
Expand description

Derives a deterministic [TradeId] from trade fields.

Tardis records do not always carry a venue-provided trade ID (some venues publish empty strings or omit the field entirely). This hash combines the symbol, timestamp, price, amount, and side so replayed data yields the same identifier across runs. FNV-1a is stable across architectures and crate versions; the 0x1f delimiter keeps variable-length fields from colliding.

price and amount are plain decimal text without trailing zeros, such as the Display output of a normalized Decimal or of an f64, so equal values derive the same identifier from machine messages and CSV records.