How to build a Hyperliquid trading bot
If you’re building a bot, you need two things: reliable infra and a trading loop. We’ll cover both: from choosing the right Hyperliquid node to wiring a trading bot repo and testing strategies safely on the Hyperliquid blockchain.
Bots drive a big share of flow on Hyperliquid. With native order books, sub-second confirms, and an API surface that works well with JSON-RPC and WebSockets, it’s a natural choice for automation.
But speed on paper doesn’t guarantee your bot keeps up in practice. Your loop depends on three choices: the RPC node you connect to, how you consume WebSocket feeds, and how you budget requests under rate limits. Those constraints come from Hyperliquid’s architecture itself, a unified chain with two execution layers (HyperCore for trading and HyperEVM for smart contracts), each exposing different RPC and API capabilities.
This guide walks those decisions and links to a minimal repo you can clone, configure, and use as a baseline Hyperliquid trading bot.
Why build a Hyperliquid trading bot?
Hyperliquid puts its order book on-chain. You can query state, stream updates, and submit orders through public endpoints. For builders, that means you can observe the same feed your logic depends on and validate each step in the loop.
Perpetuals trade at scale here, so you will feel real contention for block space and see whether your loop keeps up under pressure. If your goal is to react to live order flow, a Hyperliquid bot is a direct way to test and operate those strategies with feedback on a decentralized exchange.
What you need for a Hyperliquid trading bot
Before you wire anything, have these ready:
- A Hyperliquid RPC endpoint. You’ll need HTTPS and WSS URLs to read the book and send orders. (Create a Hyperliquid node if you don’t have one yet)
- Hyperliquid testnet account with testnet funds (claim through the Chainstack Hyperliquid faucet and Hyperliquid DEX faucet for USDC https://app.hyperliquid-testnet.xyz/drip)
- uv package manager
- Your testnet API key
Choosing the right Hyperliquid RPC node
You can self-host a Hyperliquid RPC node. That gives you full control, but it also means owning the ops work: provisioning servers, monitoring uptime, scaling with demand, and keeping up with updates.
For many builders — especially if you’re running trading bots that can’t afford downtime — those resources are better spent on the strategy. That’s why most teams turn to providers.
With Chainstack, you get two options:
- Global Nodes — shared, elastic capacity. Good for getting started, testing on testnet, or running lighter strategies that don’t push request-per-second limits. You can also set Access rules (IP or Origin allowlists) for extra control.
- Dedicated Nodes — single-tenant capacity with predictable latency under load and higher request ceilings. Suited for high-performance like production bots, continuous operation, or bursty strategies. Archive is available if you need deeper historical reads.
Once you’ve picked what fits your loop, creating a Hyperliquid node in the console is simple:
- In the Chainstack console, open your project and click Add node.
- Choose Global Nodes or Dedicated Nodes, then pick mainnet or testnet.
- Deploy the node.
- Copy the HTTPS and WSS RPC URLs into your bot config.
Set up your environment
Instead of setting up everything yourself, we’ve open-sourced a Hyperliquid trading bot you can use as a reference.
Inside you’ll find:
- A working grid trading bot wired for Hyperliquid testnet.
- Configs (like a conservative BTC grid) you can adjust to your own parameters.
- Environment examples to drop in your testnet key and toggle testnet mode.
- Learning scripts for market data, orders, and realtime WebSockets.
Clone the repo, install with uv, and explore it. From there, you can validate, run the default config, or start cutting your own.
Take five minutes to watch the setup video below to see how the pieces fit together.
How a Hyperliquid trading bot works
Please note that the bot is in active development and its state may be slightly different.
A trading bot is a loop. It keeps local state, reacts to feeds, and reconciles with chain state on every tick.
- Ingest live data — Open a price stream over WebSockets. Keep a small cache: best bid/ask, mid, recent trades. Pull account state when needed for balance, positions, and open orders.
- Plan the next tick — Read your YAML config. For a grid, derive the band and levels from current price. Build the target set of orders.
- Act — Submit signed limit orders via the Hyperliquid exchange API. Include a client identifier if supported so you can track, amend, or cancel. Log intent with timestamps.
- Observe — Watch acks and order updates from the stream. Track partial fills and status changes. Note gaps or drops in the feed.
- Reconcile — Compare intended orders to the current open orders from the API. If price exits the band, cancel and rebuild the grid. If an ack is missing, query status and resolve before proceeding.
- Recover — Handle disconnects with backoff. On reconnect, replay state by querying open orders and positions, then resume from the reconciled view.
- Persist and measure — Write compact logs for decisions, acks, rejects, and reconnects. These logs drive tuning and the evidence you will show later.
Wrapping up
You now have a baseline loop to test against Hyperliquid. The repo covers the bot, configs, and learning scripts, extend it to other DEXes and strategies as you go.
- Hyperliquid trading bot on GitHub
- Create a Hyperliquid node on Chainstack
- Claim test tokens through Chainstack Hyperliquid faucet
- Check out the Hyperliquid API method availability table, which lists 100+ methods with live support status per endpoint.
- Archive nodes and WebSockets are now live on Hyperliquid HyperEVM mainnet — use them for historical queries and realtime streams.
- Check out the Hyperliquid API reference.
Power-boost your project on Chainstack
- Discover how you can save thousands in infra costs every month with our unbeatable pricing on the most complete Web3 development platform.
- Input your workload and see how affordable Chainstack is compared to other RPC providers.
- Connect to Ethereum, Solana, BNB Smart Chain, Polygon, Arbitrum, Base, Optimism, Avalanche, TON, Ronin, Plasma, Hyperliquid, Scroll, Aptos, Fantom, Cronos, Gnosis Chain, Klaytn, Moonbeam, Celo, Aurora, Oasis Sapphire, Polygon zkEVM, and Bitcoin mainnet or testnets through an interface designed to help you get the job done.
- Fast access to blockchain archive data and gRPC streaming on Solana.
- To learn more about Chainstack, visit our Developer Portal or join our Telegram group.
- Are you in need of testnet tokens? Request some from our faucets. Sepolia faucet, Hoodi faucet, BNB faucet, zkSync faucet, Scroll faucet, Hyperliquid faucet.
Have you already explored what you can achieve with Chainstack? Get started for free today.
FAQ
An endpoint that exposes Hyperliquid’s HyperEVM over JSON-RPC and HyperCore. You use it to query state, stream data, and send signed orders. Please note that some API methods are supported by public nodes only.
Use the Chainstack Hyperliquid faucet to fund your testnet account before running a trading bot and Hyperliquid DEX faucet for USDC (https://app.hyperliquid-testnet.xyz/drip).
Spin up a Hyperliquid node in the Chainstack console. Once the node status is “running,” open Access & credentials to copy an info endpoint.
Run a Hyperliquid Global or Dedicated Node on Chainstack. Grab the info endpoint and drop them into your environment variables, that’s how it pulls order book data and pushes transactions. Please note that some API methods are supported by public nodes only.
Yes, you can. Since Hyperliquid keeps the order book on-chain, a smart contract can watch state through RPC and trigger trading logic when conditions hit.




