quantity_to_u32

Function quantity_to_u32 

Source
pub fn quantity_to_u32(quantity: &Quantity, instrument: &InstrumentAny) -> u32
Expand description

Safely converts a Quantity into the integer units expected by the BitMEX REST API.

The API expects whole-number “contract” counts which vary per instrument. We always use the instrument size increment (sourced from BitMEX underlyingToPositionMultiplier) to translate Nautilus quantities back to venue units, so each instrument can have its own contract multiplier. Values are rounded to the nearest whole contract (midpoint rounds away from zero) and clamped to u32::MAX when necessary.