Building a Hyperliquid AI Agent Trader From Scratch
I had been sleeping on Hyperliquid. I assumed it was crypto-only and tuned out. Then I looked again yesterday and they have OpenAI perps, S&P 500, and Brent oil sitting next to BTC. That's interesting enough to point an AI agent at. This post walks through the whole stack I built in an afternoon — wallet setup, API agent, Claude Code skill pipeline for research, and the actual first programmatic trade.
Watch the video:
Why Hyperliquid this time
The pitch is simple: Hyperliquid is a perp DEX, but the markets that matter for an agent are the new long-tail ones — equity perps, commodities, macro events — deployed as independent perp markets. That gives an AI agent something to actually research. On a pure BTC/ETH book the edge is microstructure; on an NVDA earnings perp the edge is reading the news. The latter is where LLM agents are interesting.
This slots in next to what I've already built for prediction markets — see building the Polymarket bot from scratch and the 100x strategy hunt. Different platform, same shape: small wallet, programmatic execution, agent does the thinking.
Wallet + funding
Connection options on Hyperliquid are MetaMask, WalletConnect, or email. I went MetaMask. The key thing to internalize is that Hyperliquid runs on Arbitrum, so you need:
- USDC on Arbitrum — the trading balance
- A few dollars of ETH on Arbitrum — gas for the deposit transaction
I funded MetaMask directly with USDC via Revolut Pay, then swapped $2 of that to ETH on the same network. Hit deposit on Hyperliquid, signed, done — about $200 sitting in the account ready to trade.
The API agent
This is the part that took me a minute to find. On Hyperliquid: More → API → create wallet. Name it "AI agent", click generate, authorize. You get a private key — that's the credential the bot uses, separate from your main MetaMask key. Drop three things into a .env:
- API wallet name
- Wallet address
- Private key
One gotcha that cost me a few minutes: by default, deposits land in the spot account, and I want to trade perps. Fix: Settings → disable HIP 3 DEX abstraction. That unifies the account model and surfaces a "Perps ↔ Spot" toggle so you can shuffle balance between them. Without this, the API thinks your money lives somewhere the perp engine can't see, and every order silently does nothing.
I also dropped the Hyperliquid API docs URL into a docs/hyperliquid.md in the project. Standard pattern — gives Claude Code a single grounded reference instead of letting it guess endpoint shapes.
The trader personality
This is where I had fun. Instead of writing a sober quant prompt, I built an RPG-style profile for the agent: the Wall Street Bets Moderator. Stats sheet:
- Risk tolerance: 96/100
- Conviction: 94/100
- Pattern recognition: high
- Patience for slow trades: 3/100
- Weakness: FOMO aura — +10 risk when a ticker hits the WSB front page
- Ultimate move: 999x God Gen mode
The point isn't the joke (though it is funny). The point is the persona shapes every downstream decision the agent makes. When I later ask it to rate trade ideas, that profile is the rubric. Boring market-neutral spread? Low score. Three-legged earnings gamble with a hedge leg? High score. The persona is the strategy.
You could of course swap this for "conservative pension fund manager" with risk-aversion 95, patience 99, and end up with completely different trades from the same pipeline. That's the leverage point.
Two Claude Code skills
I broke the work into two skills, each invokable as /find-trades and /research-trade. This is the same skill + headless + tools pattern I described in the 3-part AI agent system — give the model a named capability with clear scope so the same workflow can be reproduced cleanly.
/find-trades
An idea-generation funnel. The skill explicitly:
- Runs a bash command first to ground the current date/time (critical — markets are time-sensitive)
- Spawns six parallel sub-agents to scan for intraday setups
- Aims for 3–5 setups for today only (this is high-frequency by design)
- Outputs to a Kanban-style board with the candidates
The persona from CLAUDE.md flows in here, so the ideas it surfaces are biased toward the high-conviction high-risk setups the WSB profile would want.
/research-trade
Takes a single idea and goes deep. Uses my Surfagent browser stack to actually log into Reddit (WSB), pull Polymarket prediction markets that touch the same ticker, hit X, and aggregate the context. Sub-agents in parallel — same shape as the Karpathy autoresearch on Polymarket work. Output is a final trade brief: direction, leverage, size, hedge legs, entry conditions.
Live run — Nvidia earnings day
I ran the full pipeline on May 20th. NVDA was reporting earnings. The flow:
/find-trades→ 5 ideas back, mostly directional. I asked the agent to rate them against the WSB persona. Scores came in flat — too boring.- Asked to exclude two of the boring ones and "leverage your 1000X brain — think hedge, special moves". Got back more interesting candidates: a three-legged "Nvidia Iron Triangle" (pre-position + bull reaction + bear reaction), a "long NVDA / short AMD / short MU" semi-desperation residual, and a cross-catalyst pincer (long VLD short BTC).
/research-tradeon all three. The agent went off to Reddit, Polymarket, X, gathering context. The pick: an Nvidia IV crush pin trap.- Constrained the position to $100 and roughly a third of the book at 20x leverage — small money, real trade.
- Told the agent "LFG, fire trade". It hit the API and opened a 10x short on NVDA. I exited immediately for the demo, planning to re-fire on the real timing later.
The point of the run wasn't the trade outcome. It was confirming the full loop closes — persona → idea → research → brief → execution — without me touching the keyboard except to type "fire". From here it's just tuning the persona and the research depth.
What this is and isn't
This isn't a get-rich pipeline. The persona is a meme, the position size is small, and a 20x perp on an earnings catalyst is exactly the kind of trade that vaporizes accounts. I'm running this because:
- You learn more about how financial markets actually work in an hour of real money than a week of paper trading. Latency is real, slippage is real, the spot/perp gotcha is real.
- It's a clean testbed for agentic harnesses. Same skill pipeline could ride my broader Claude Code passive-income setup — the loops compound across platforms.
- Hyperliquid teaches you actual market structure (perp funding, margin engine, deposit routing) more than Polymarket does. If you care about that, it's the better classroom.
I'll follow up if either persona variant (the meme one, or a sober opposite) starts producing interesting equity curves over a week of running.
Resources
- Hyperliquid — the perp DEX. Equity, crypto, commodity perps.
- Hyperliquid API docs — drop the URL into
docs/hyperliquid.mdat the start. - MetaMask — wallet I used for both funding and the main account connection.
- AI_automata Discord — my server for AI automation projects, where I post live updates.
- My GitHub — repos and skill examples.