Skip to main content

parse_ws_user_event_to_fill_report

Function parse_ws_user_event_to_fill_report 

Source
pub fn parse_ws_user_event_to_fill_report(
    update: &WsOrderUpdate,
    last_qty: Quantity,
    last_px: Price,
    commission: Money,
    trade_id: TradeId,
    instrument: &InstrumentAny,
    account_id: AccountId,
    liquidity_side: LiquiditySide,
    ts_event: UnixNanos,
    ts_init: UnixNanos,
) -> Result<FillReport>
Expand description

Parses a Coinbase user channel WsOrderUpdate into a [FillReport].

Coinbase’s user channel reports cumulative totals rather than per-trade fills, so the caller must supply:

  • last_qty: the quantity delta since the previous cumulative state
  • last_px: the price of the new fill, derived by the caller from the cumulative notional delta (Coinbase’s avg_price is the cumulative weighted average and is not safe to use as the new fill’s price for multi-fill orders)
  • commission: the commission delta since the previous cumulative state
  • trade_id: synthesized from the order ID plus the new cumulative total