Skip to main content

parse_trade_tick_from_rest

Function parse_trade_tick_from_rest 

Source
pub fn parse_trade_tick_from_rest(
    trade: &DerivePublicTrade,
    price_precision: u8,
    size_precision: u8,
    ts_init: UnixNanos,
) -> Result<TradeTick>
Expand description

Parses a REST public/get_trade_history row into a Nautilus trade tick.

The endpoint returns one maker row and one taker row per trade under the same trade_id, and each row’s direction is that participant’s own side: the aggressor side is the taker row’s direction and the inverse of the maker row’s. A missing role keeps the public WS contract where direction already denotes the taker; an unknown role degrades the same way so the trade is still emitted.

Pass price and size precision from the instrument definition rather than inferring them from the wire values, since Derive may trim trailing zeroes.

§Errors

Returns an error when price, size, or timestamp conversion fails.