BlogDeveloper

How to Build a Hyperliquid Copy Trading Bot

Build a copy trading bot on Hyperliquid: follow a trader's fills live, size each copy, re-check positions for missed trades, and know its limits.

HydromancerTeam
How to Build a Hyperliquid Copy Trading Bot

What if your account could trade alongside a Hyperliquid trader who keeps getting it right, automatically?

That's what a copy trading bot does. It follows the trader's wallet, the "leader", and mirrors each trade in your account at a smaller size.

The same build powers a full Hyperliquid copy trading app for other people, with a trader list, profiles and a copy button. We cover those parts after the mini example.

Hyperliquid copy trading compared with a CEX

Copy trading means something different on Hyperliquid than on a centralized exchange (CEX) such as Binance or Bybit:

On Hyperliquid On a centralized exchange
Who you can copyAny wallet: every
trade and position
is public on-chain
Usually only traders
in the exchange's
copy-trading program
Checking a leader firstPull their trades and
PnL history yourself
from the API
Usually the stats the
exchange chooses to show
Where your money sitsYour own account, under
your own sizing rules
Usually an account
the exchange holds
your funds in
Building it for othersBuilder codes earn up to
0.1% on the perp fills
you place for users
The exchange
runs the program

Hyperliquid also has a built-in way to follow a trader: vaults. In Hyperliquid's original user vaults, which its docs now label "legacy", you deposit into the leader's vault, they trade it, and they keep 10% of the profits. A copy bot works the other way around. Your money stays in your account, and you set the size, caps and leverage of every copy.

The hard part is keeping up with the leader: catching every trade fast, sizing it for your account, and noticing when you've missed one. Below, we look at why the usual ways fall short, then build a mini example step by step, with Hydromancer supplying the leader's data and Hyperliquid's SDK placing the orders.

It's a starting point to adapt, not a production template. Nothing here is financial advice: copying a trader copies their losses too. Prices shown are from our test runs.

How most people copy trade on Hyperliquid, and why it falls short

Approach How it works Where it breaks
Copy-trading apps and chat botsPaste a wallet
in, set a size
You often can't see
or change the sizing
and risk logic
Polling the public APIAsk for the leader's
positions or fills
every few seconds
Copies arrive up to
a polling interval
late, and polling
eats your rate limit
Copying positions, not fillsCompare snapshots and
trade the difference
Trades that open
and close between
snapshots are
never seen
One-to-one size and leverageMirror the
leader exactly
One large trade
can take over a
small account
No recoveryTrust the feed
to never drop
One missed fill
and your positions
drift from the
leader's for good

An effective copy bot does the opposite of each. It gets fills pushed to it as they happen. It sizes every copy with its own caps and leverage. And it re-checks the leader's real positions whenever it might have missed something.

The limits of Hyperliquid's API for copy trading

Hyperliquid's API can do all of this for one or two leaders. Past that, its limits bite. These are per IP address, from Hyperliquid's rate limits docs:

Limit What it means for copy trading
10 unique users across user-specific live subscriptionsThe docs say 10 leaders
per IP; in our test it
stopped at 15
10 live connectionsThe 10-user cap
applies across all of
them, so more
connections don't help
1,200 REST weight per minuteShared by every read and
every order you send
clearinghouseState costs 2Polling 20 leaders'
positions every 2 seconds
uses the whole 1,200
userFills costs 20, plus 1 per 20 fillsPolling one leader's
fills every 2
seconds uses half
the budget or more
userFills returns at most 2,000 recent fillsCatching up after a
gap means paging
userFillsByTime ,
which the docs limit
to the 10,000 most recent

Your own account has one more limit: an action budget. It starts at 10,000 requests and grows by one per USDC you trade. Small copies earn little budget, so don't waste it on needless cancels and retries.

How the mini example works

Job What it does
Watch the leadersHydromancer's userFills feed, pushed as fills happen
Decide what to copyNew opens and adds on perps you can trade
Size it10% of the leader's change, capped
at $25 per coin and $60 in total
Place ordersImmediate-or-cancel orders through
Hyperliquid's SDK, at your own leverage
Stay in stepRe-reads the leader's positions after a reconnect,
every 5 minutes, and when a fill doesn't add up
Stop safelyLimits and a kill file, then cancel, flatten and check
Diagram of a copy trading bot on Hyperliquid in four steps: watch the leader's fills, size your share with caps, place your order through Hyperliquid's exchange API, and resync against the leader's positions.

You need Python 3, pip install hyperliquid-python-sdk, a Hydromancer API key, and a Hyperliquid account with an API wallet.

Use an account that does nothing but copy.

Our trading bot guide covers order placement and the kill switch, and our whale tracker guide shows how to find active wallets.

Step 1: Stream the leader's trades as they happen

A copy bot reacts to the leader's fills. A fill is one executed trade, with its coin, side, size and price. Rather than asking for the leader's fills every few seconds, subscribe once and let the server push each new fill to you. On Hyperliquid's own live feed, wss://api.hyperliquid.xyz/ws, that's one subscribe message per leader:

json
{"method": "subscribe",
 "subscription": {"type": "userFills", "user": "0x…"}}
json
{"channel": "userFills", "data": {"user": "0xecb6…2b00", "fills": [
  {"coin": "DOGE", "px": "0.077232", "sz": "629.0", …,
   "startPosition": "-26636367.0", "dir": "Open Short", …}]}}

On Hyperliquid's feed, the first message is a snapshot of the leader's recent fills, marked isSnapshot. Skip it, and copy only the fills that come after. Hydromancer's feed sends no snapshot, so every fill it sends is new. Each fill carries the leader's position before it (startPosition), so one fill tells you both the trade and the new position. Each fill also has side (B for buy, A for sell), sz and px. That's what the bot copies: position changes, not orders. In a long-running bot, send {"method": "ping"} when the feed has been quiet for about 50 seconds; Hyperliquid closes connections that stay silent for 60.

Following many leaders: plug in Hydromancer. Hyperliquid's docs allow 10 users per IP on its live feed, and in our test it stopped at 15. Hydromancer's userFills takes a list of up to 1,000 addresses in one subscription, and fills arrive as [address, fill] pairs in the message's fills list. Connect to wss://api.hydromancer.xyz/ws?token= followed by your API key, then send:

json
{"type": "subscribe",
 "subscription": {"type": "userFills", "addresses": ["0x…", "0x…", …]}}

The fill fields are the same. The only change is that each fill comes with its address, so route it to the right leader before sizing the copy. The server sends {"type": "ping"} soon after you connect and then every 60 seconds; reply with {"type": "pong"} to stay connected.

Step 2: Decide how much to copy

Copying the leader's exact size rarely makes sense. Their account is likely far bigger than yours, and one large trade could take over your whole balance. So each copy is a fraction of the leader's change, with two limits: a cap per coin, and a skip when the order would be too small to trade.

With a 10% ratio, a $25 cap per coin and ETH at $2,300:

Leader adds You hold You copy Why
4 ETH0 ETH0.0108 ETH10% would be 0.4 ETH,
cut to the $25 cap
0.03 ETH0 ETHNothing10% is worth $6.90,
under Hyperliquid's
$10 minimum
2 ETH0.0102 ETHNothingToo little room left
under the cap for a
minimum-sized order

Closes are sized from your position: if the leader closes half, you close about half of what you hold, adjusted for size steps and the minimum. A flip closes what you hold, then opens the new side within the same limits. Set your own leverage per coin rather than mirroring the leader's.

Step 3: Re-check the leader's positions to catch missed trades

No feed is perfect. A dropped connection or a restart can make the bot miss a fill, and then its copy of the leader's positions is wrong for good. The fix is to check its view against the leader's real positions from time to time. On Hyperliquid, that's one clearinghouseState request per leader. It returns each open position with its coin and signed size (szi, negative for a short), which the bot compares with its own view.

Many leaders: plug in Hydromancer. At 2 weight per request, re-checking hundreds of leaders eats your 1,200-a-minute budget. Hydromancer's batchClearinghouseStates reads up to 1,000 wallets on one DEX in a single request. It covers the main DEX by default; add "dex": "ALL_DEXES" to include HIP-3 positions such as xyz: markets (up to 100 wallets per request). POST this body to https://api.hydromancer.xyz/info, with your API key as a Bearer token in the Authorization header:

json
{"type": "batchClearinghouseStates", "users": ["0x…", "0x…", …]}
json
{"successful_states": [["0x85ec…2052", {"assetPositions": […], …}], …],
 "failed_wallets": []}

batchClearinghouseStates is a Hydromancer endpoint, not part of Hyperliquid's own API. Orders still go to Hyperliquid.

The bot uses these checks in three ways:

  • Out-of-step check. If a fill's startPosition doesn't match what the bot thinks the leader holds, something is out of step, possibly a missed fill.
  • Resync. The bot then re-reads the leader's real positions and copies any difference.
  • Timer and reconnects. It also resyncs every 5 minutes and after each reconnect. The mini example reconnects with a fresh session and relies on this resync. A production bot can also reconnect with its session ID to replay short drops.

A change found by a resync is copied late, at the current price. It's a repair, not a good copy.

Copy many Hyperliquid wallets at once

The steps above already use Hydromancer for the leaders' fills. Here's the full picture of what changes when you follow many wallets. Hydromancer streams the same Hyperliquid data, with limits built for that job:

What the copy bot needs Without Hydromancer (Hyperliquid's API only) With Hydromancer's API
Follow leaders liveOne subscription
per leader; the
docs allow 10
users per IP
(15 in our test)
userFills takes
up to 1,000
addresses in one
subscription
Recover from a dropResubscribe, then
backfill over REST
Reconnect with
your session ID
to replay up to
30 seconds
Fill longer gapsuserFillsByTime ,
the 10,000 most
recent fills
userFillsByTime
with history from
28 July 2025
Re-check leaders' positionsclearinghouseState
, one leader
per request
batchClearinghouseStates
: up to 1,000
wallets on one
DEX per request
Copy leverage changes and resting ordersPer-user live
subscriptions
or REST reads,
within the same
10-user cap
userLeverageUpdates
and
userOrderUpdates
for many
addresses at once
Choose who to followThe undocumented
leaderboard file
userPnlLeaderboard
: ranked by
realized PnL,
with a bot filter
Place the copiesHyperliquid's
exchange API
The same: orders
always go to
Hyperliquid

Each followed address counts toward your plan's subscription total. That's 500 on Starter, 5,000 on Growth and 10,000 on Scale, per our streaming limits docs. Orders still go to Hyperliquid, through the SDK.

If you follow one or two wallets, Hyperliquid's own live feed is enough. Hydromancer is for when you follow more than about 15 leaders, or need to recover quickly when a connection drops.

What one live run did

We let the mini example follow an active leader for about 12 minutes, with orders on Hyperliquid's testnet:

Count
Leader fills seen23
Copied2 (BTC and SOL shorts,
each cut to the $25 cap)
Skipped: at or near the cap2
Skipped: too small after caps and rounding4
Skipped: leader reduced a position we didn't hold11
Skipped: market not available to the test account4

We then stopped it with the kill file. It closed both positions and confirmed the account was flat. Of the 21 skips, 6 came from the caps and the minimum order size. The other 15 were reductions of positions we never copied, or markets we couldn't trade.

How the live feeds compared over 15 tests

The live run above followed one leader. A bot that follows many has three ways to hear about their trades. We raced all three on the same 30 busy wallets, 15 times, 2 minutes each:

Hyperliquid userFills Hyperliquid trades workaround Hydromancer userFills
Wallets it could follow (of 30)153030
Fills delivered, all 15 tests72%90%99.7%
Tests where no fill was missed0 of 151 of 1514 of 15
Worst single test63%19%96%
Typical delay279 ms274 ms214 ms

The workaround subscribes to every market's trade feed and picks out the wallets by address. In its worst test, Hyperliquid accepted only 69 of the 901 market subscriptions, so most markets were never watched; check every subscription reply, not just the connection. Each test used the 30 wallets that had traded most in the 3 minutes before, and every delivered fill was checked against a trade record from Hydromancer's history API. Where Hyperliquid's every-market feed kept up, it matched that record fill for fill. Whichever feed you use, re-check the leader's positions after any reconnect, as in Step 3.

Choose which traders to copy

A bot needs a leader worth copying. For an app with many users, this is the first screen: a ranked list of traders.

Hyperliquid API. There's no documented request that ranks traders. The app's leaderboard page reads a public file, which you can download too:

code
import requests

URL = "https://api.hyperliquid.xyz/info"
LB = "https://stats-data.hyperliquid.xyz/Mainnet/leaderboard"
rows = requests.get(LB).json()["leaderboardRows"]        # one big file
pnl = lambda r: float(dict(r["windowPerformances"])["month"]["pnl"])
for r in sorted(rows, key=pnl, reverse=True)[:10]:
    st = requests.post(URL, json={"type": "clearinghouseState",
                                  "user": r["ethAddress"]}).json()
    pos = [p["position"]["coin"] for p in st["assetPositions"]]
    print(r["ethAddress"][:10], f"${pnl(r):,.0f}", len(pos), "positions")

The file was 39.8 MB and listed 48,200 accounts, so cache it rather than downloading it for every user. It ranks by account PnL with no bot flag: the top two accounts held 22 and 30 positions at once, which is what market-making programs look like.

Hydromancer API. userPnlLeaderboard ranks traders by realized PnL and can leave out bots (minHumanScore) and one-off accounts (minTrades). batchPortfolioStates returns their positions in one request:

code
import os, requests

URL = "https://api.hydromancer.xyz/info"
H = {"Authorization": "Bearer " + os.environ["HYDROMANCER_API_KEY"]}
top = requests.post(URL, headers=H, json={
    "type": "userPnlLeaderboard", "window": "30d", "limit": 10,
    "minTrades": 10, "minHumanScore": 60}).json()["users"]
pnl = {u["user"]: float(u["totalPnl"]) for u in top}
st = requests.post(URL, headers=H, json={"type": "batchPortfolioStates",
                                         "users": list(pnl)}).json()
for addr, s in st["successful_states"]:
    pos = s["clearinghouseState"]["assetPositions"]
    print(addr[:10], f"${pnl[addr]:,.0f}", len(pos), "positions")

window takes 1d, 7d, 30d, 90d or all. To find leaders who trade often, use "1d" with a higher minTrades.

Hyperliquid API Hydromancer API
Ranked byAccount PnL, bots includedRealized PnL, bots filtered by score
Time (median)24 s0.4 s
Requests112
Data received39.8 MBunder 0.1 MB

Both work. The free file is the cheaper start. The Hydromancer list saves you from building a bot filter and from refreshing a 40 MB download; it's a paid add-on (pricing). Our leaderboard guide covers the file in depth.

Show each trader's record

Before anyone copies a trader, they want to see the record.

  • Hyperliquid API: portfolio gives account value and PnL history for the day, week, month and all time, and userFillsByTime reaches a wallet's recent fills.
  • Hydromancer API: userCompletedTrades gives one row per closed trade, with fees and funding, and userPnlSummary adds win rate and hold time.

For a busy trader's last 90 days, Hyperliquid reached back 12 days (66 trades rebuilt from 15,414 fills) and Hydromancer returned all 90 (416 trades). Over the days both covered, the trades matched one for one. Our trading journal guide has the code.

Label which PnL you show. For one top trader over the same 30 days, account PnL was about -$2.9M, while realized PnL from closed trades was about +$7.3M. Account PnL includes positions still open; realized PnL counts trades closed in the window. Show the name next to the number.

Risk controls followers expect

Step 2's caps are the start. Followers also expect:

  • A maximum loss. Stop copying, and close copied positions, once the account is down a set amount.
  • A slippage guard. Skip a copy when the price has already moved too far from the leader's fill.
  • Market filters. Let followers skip coins they don't want, such as HIP-3 stock perps.
  • Exits on every copy. Stop-loss and take-profit orders are native on Hyperliquid (order types), so a copied position can carry its own exit the moment it opens.

Earning from a copy trading app

If you run the bot for other people, every copied order can carry your builder code: a fee of up to 0.1% on perps that each user approves once. Social apps already earn this way. fomo, a feed with trader profiles and follow alerts, had collected $2.07M in builder fees by 2 October 2026, according to Flowscan (top builders by revenue). Our Telegram bot guide shows the one-time approval.

Be honest about what copying can't do

  • You always trade after the leader, possibly at a different price.
  • Leverage differs. A large account can ride out a move that would liquidate a small copy.
  • Your results will differ from the leader's. Skipped fills, caps, and your own fees and funding all pull your account away from theirs, and most of that is beyond your control.

FAQ

Is copy trading on Hyperliquid profitable?

It can be, but not automatically. You trade after the leader, possibly at a different price, skip fills that are too small, and pay your own fees and funding. A leader's past results don't promise future ones, so size copies small and check the leader's history first.

Is copy trading allowed on Hyperliquid?

Every wallet's trades on Hyperliquid are public, so following a wallet means reading public data, and your copies are ordinary orders through Hyperliquid's API. Rules can differ by country, and this isn't legal advice.

What's a good copy trading strategy on Hyperliquid?

Pick leaders by their closed-trade results over months, not one big win, and follow several rather than one. Cap your size per coin and in total, skip copies too small to trade, and set your own leverage. Our leaderboard guide shows how to rank traders by realized PnL.

How many wallets can I copy on Hyperliquid?

With Hyperliquid's own live feed, its docs say 10 users per IP, and in our test it stopped at 15. Hydromancer's userFills takes up to 1,000 addresses in one subscription, within your plan's subscription total (500 on Starter, more on higher plans).

Why not just poll the leader's positions?

Polling makes every copy as late as your polling interval, and it uses the request weight you need for your own orders. It also misses trades that open and close between polls.

Should I copy the leader's existing positions?

The mini example doesn't. It records them at start and copies only changes from then on, so it never enters an old trade at a later price.

How do I stop bots from topping my copy trading leaderboard?

Filter on behavior, not account size: trades per day, fills per trade, and how many markets an account holds at once. Hydromancer's humanScore is a 0 to 100 score built from signals like these. With Hyperliquid's leaderboard file, you build the filter yourself.

Why do two PnL numbers for the same trader disagree?

They usually measure different things. Realized PnL counts closed trades only, while account PnL includes open positions and spot balances. Show the label with the number.

Next steps

Continue