Skip to main content

Module common

Module common 

Source
Expand description

Shared utilities for Hyperliquid execution clients (perps and spot).

Contains parsing helpers and stream wrappers used by both HyperliquidClient (perps) and HyperliquidSpotClient.

Error mapping is in the error module.

Structs§

CancelOnDropStream
Stream wrapper that cancels background tasks when dropped.
OpenOrder
One order from the openOrders info endpoint, as the venue actually returns it.
UserFill
Parse a decimal string from SDK response, logging warnings on failure. One fill from the userFills info endpoint, as the venue actually returns it.

Functions§

cid_to_cloid
The cloid to place an order under cid with, or None if cid cannot be one.
cloid_to_cid
The client id an order placed with cloid was placed under: the inverse of cid_to_cloid.
instrument_to_spot_coin
Extract coin pair from spot instrument (e.g., “PURR-USDC-SPOT” -> “PURR/USDC”).
map_tif
Map rustrade TimeInForce to Hyperliquid TIF string.
millis_to_datetime
Convert milliseconds timestamp to DateTime<Utc>.
open_orders
Fetch every open order for address, parsed into OpenOrder rather than the SDK’s lossy type, which drops the cloid.
parse_decimal
parse_side
Parse SDK side string to rustrade Side.
spot_pair_to_instrument
Build the spot instrument name for pair, from its tokens: BASE-QUOTE-SPOT (e.g. HYPE-USDC-SPOT for the pair Hyperliquid names @107).
user_fills_by_time
Read every fill address made from start_ms to end_ms, both inclusive, in epoch milliseconds, parsed into UserFill rather than the SDK’s lossy type.