Prerequisites
- Python 3.8 or higher
hyperliquid-python-sdk
installed (pip install hyperliquid-python-sdk
)- Chainstack Hyperliquid node endpoint (sign up for free)
The precision problem
This order gets rejected:"Tick size violation"
or "Invalid order size"
This works:
0.00100
breaks when you switch to another asset. You need dynamic precision.
Tick size vs lot size
Hyperliquid enforces precision on both price and quantity: Tick size — price precision:- Prices limited to 5 significant figures
- Max decimals: 6 for perps, 8 for spot
- Examples:
1234.5
✓,1234.56
✗ (too many sig figs)
- Determined by
szDecimals
in asset metadata - Varies per asset (BTC: 5 decimals, some memecoins: 2 decimals)
- Must query from API—cannot hardcode
Querying asset metadata
Understanding Hyperliquid asset formats
Hyperliquid uses multiple formats to identify assets: Spot assets:@{index}
— direct index reference (for example,@0
= BTC/USDC){TOKEN}/USDC
— pair name (for example,PURR/USDC
)
{SYMBOL}
— direct symbol (for example,BTC
,ETH
,SOL
)
Getting spot asset metadata
QueryspotMetaAndAssetCtxs
for comprehensive spot data including precision requirements:
Getting perpetual asset metadata
Perps use a simpler structure viametaAndAssetCtxs
:
Working with order precision
Calculating valid order sizes (lot size)
Order sizes must be rounded to theszDecimals
specified in asset metadata. This is also known as the lot size—the minimum increment for order quantities.
- Target value: $15 USDC
- BTC spot price: $65,000
- Size decimals (
szDecimals
): 5 - Raw size: 15 / 65000 = 0.000230769…
- Valid size:
round(0.000230769, 5)
=0.00023
(5 decimals)
szDecimals
field in metadata determines lot size precision. Query this value from spot_meta_and_asset_ctxs()
for spot or meta_and_asset_ctxs()
for perps.
Minimum notional value
Hyperliquid enforces minimum order values (typically ~$10). Check before placing:Price precision (tick size)
Price precision on Hyperliquid follows specific rules: Significant figures rule — prices can have up to 5 significant figures Maximum decimal places:- Perpetuals — max 6 decimal places
- Spot — max 8 decimal places
1234.5
✓ (5 significant figures)1234.56
✗ (6 significant figures—too many)0.001234
✓ (4 significant figures)0.0012345
✗ (5 sig figs but more precision than needed)
When signing orders, trailing zeros should be removed from price strings.
Implementation examples
Complete order placement flow
Putting it together for dynamic multi-asset trading:Handling unknown assets
When trading new or obscure assets:Caching metadata
Query metadata once, reuse for multiple orders:Troubleshooting
Common rejection reasons
“Invalid order size” (lot size violation) — wrong size decimals. QueryszDecimals
from metadata and round order size accordingly.
“Tick size violation” (price precision) — price has too many significant figures (>5) or exceeds max decimals (6 for perps, 8 for spot). Format with up to 5 significant figures.
“Order too small” — below minimum notional value (~$10 USDC). Increase order size.
“Asset not found” — wrong coin field format (@index
for spot, SYMBOL
for perps) or delisted asset.
“Insufficient balance” — not a precision issue, but verify wallet has enough collateral before placing orders.
Summary
QueryszDecimals
from asset metadata to calculate valid order sizes dynamically—never hardcode precision. Prices must have ≤5 significant figures with max 6 decimals (perps) or 8 decimals (spot). Support all asset formats (@index
, PAIR/USDC
, SYMBOL
), validate minimum notional (~$10 USDC), and cache metadata to reduce API calls.
The complete implementation is available in the Chainstack Hyperliquid trading bot repository.
Related resources
- Copy trading with spot orders — Build a copy trading bot that mirrors spot trades
- TWAP order execution — Place and monitor TWAP orders on Hyperliquid
- Authentication guide — Authenticate with Hyperliquid exchange API
- API reference — Explore the complete Hyperliquid API reference