Skip to content
Request a review

Hyperliquid API & Python SDK · Advanced API Patterns · 7/8

Batch Operations & Rate Limits

Rate Limits

Hyperliquid enforces rate limits to ensure fair access. Understanding these is critical for building reliable trading systems. Figures below are as of October 2026 (rate limits).

IP-Based Limits

Address-Based Limits (actions only)

Nonces

Every signed action carries a nonce (the SDK uses the current time in ms). Hyperliquid keeps the 100 highest nonces per signer; a new nonce must be larger than the smallest of them, never reused, and within (now − 2 days, now + 1 day). Two processes sharing one API wallet can collide, so use one API wallet per process (nonces).

Batch Order Placement

Instead of placing orders one at a time, use batch operations (testnet only; these samples place and cancel real orders):

# Place multiple orders in a single request
orders = [
    {
        "coin": "BTC",
        "is_buy": True,
        "sz": 0.01,
        "limit_px": 90000.0,
        "order_type": {"limit": {"tif": "Gtc"}},
        "reduce_only": False,
    },
    {
        "coin": "BTC",
        "is_buy": True,
        "sz": 0.01,
        "limit_px": 89500.0,
        "order_type": {"limit": {"tif": "Gtc"}},
        "reduce_only": False,
    },
]

result = exchange.bulk_orders(orders)

Batch Cancellation

# Cancel multiple orders at once
cancels = [
    {"coin": "BTC", "oid": 12345},
    {"coin": "BTC", "oid": 12346},
    {"coin": "ETH", "oid": 12347},
]

result = exchange.bulk_cancel(cancels)

Cancel-and-Replace Pattern

A common pattern in market making: replace a resting order with a new price or size. Hyperliquid has native modify and batchModify actions, exposed in the SDK as modify_order and bulk_modify_orders_new:

# Modify an existing order in one action
result = exchange.modify_order(
    oid=12345,
    name="BTC",
    is_buy=True,
    sz=0.02,          # New size
    limit_px=90500.0,  # New price
    order_type={"limit": {"tif": "Gtc"}},
)

modify_order is preferred over a separate cancel + place because it is a single signed action: one request, one nonce, and no window in which your own code has cancelled but not yet re-sent. By default the new order is placed only if the cancel succeeds, so if the old order already filled you will not end up with an extra order. In that default mode the replacement must be a non-trigger order that rests on the book: Alo, or a Gtc price that would not match immediately (exchange endpoint).

Error Handling

Always handle API errors gracefully:

try:
    result = exchange.order(name="BTC", is_buy=True, sz=0.01,
                           limit_px=90000.0,
                           order_type={"limit": {"tif": "Gtc"}})

    if result["status"] == "ok":
        statuses = result["response"]["data"]["statuses"]
        for s in statuses:
            if "error" in s:
                print(f"Order rejected: {s['error']}")
            elif "resting" in s:
                print(f"Order placed: oid={s['resting']['oid']}")
            elif "filled" in s:
                print(f"Order filled immediately")
    else:
        print(f"Request failed: {result}")

except Exception as e:
    print(f"API error: {e}")