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_perp_coin
Extract coin name from perp instrument (e.g., “BTC-USD-PERP” -> “BTC”).
instrument_to_spot_coin
Extract coin pair from spot instrument (e.g., “PURR-USDC-SPOT” -> “PURR/USDC”).
is_spot_coin
Check if a Hyperliquid coin name is a spot pair (contains ‘/’).
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.
perp_coin_to_instrument
Build perp instrument name from Hyperliquid coin name (e.g., “BTC” -> “BTC-USD-PERP”).
round_to_5_sig_figs
Round a price to 5 significant figures (Hyperliquid requirement).
spot_coin_to_instrument
Build spot instrument name from Hyperliquid coin pair (e.g., “PURR/USDC” -> “PURR-USDC-SPOT”).
user_fills
Fetch userFills for address, parsing it into UserFill rather than the SDK’s lossy type.