Tutorial · Build with Claude

Build a trading bot on Hyperliquid with Claude.

A trading bot is a deterministic strategy that runs on its own schedule. Claude is your copilot for building it — composing the strategy graph, backtesting against real Hyperliquid history, iterating. Once compiled, the strategy runs without Claude in the loop.

By Keel Research Team · Updated May 20, 2026
What a trading bot actually is

Three definitions. One of them is what Keel ships.

The phrase 'trading bot' usually conjures an autonomous wallet bot or a one-off Python script. Both break under contact with a perp venue. The third meaning — a compiled, deterministic strategy — is what this tutorial walks you through.

Bot = LLM-in-the-loop

The autonomous-bot fantasy. An LLM watching the market, calling tools to enter and exit positions in real time. Problem: hallucinations show up at decision time, no deterministic backtest exists for "what the LLM might decide", and funding-aware sizing is not a thing an LLM does well at 1Hz.

With Keel

Use Claude where LLMs are actually good — proposing a thesis, composing a typed graph, summarizing results. Not at the trade-decision boundary.

Bot = throwaway script

A Python file that calls the Hyperliquid REST API and places orders on a cron. One-off, no engine, no backtest, drift between the research and the live code, no funding model. Common amateur path; rarely survives a full month.

With Keel

Keel's compiled artifact is the same in backtest and live. No drift, no separate paths, no manual reconciliation between what you tested and what trades.

Bot = compiled strategy

The framing we mean by "bot": a typed component graph that has been validated, backtested, and shipped as a versioned artifact. Claude is the build-time copilot; the runtime is deterministic.

With Keel

This is the surface this tutorial walks you through. The artifact is yours, the runtime is deterministic, the agent doesn't sit in the trade loop.

The tutorial

Five steps from thesis to a deployable artifact.

Each step is a single prompt or a single command. Claude does the composition and the backtest plumbing; you stay at the thesis-and-review level.

01

Define the thesis

Before Claude composes anything, name what you want the bot to do. Two examples that ship cleanly through the Keel DSL:

  • Funding-receivers vs payers, vol-targeted. Long the perps with negative funding (you collect to be long), short the perps with positive funding, rebalance daily, size by realised volatility.
  • Cross-sectional momentum on 4h bars. Rank top-30 HL perps by an 8-bar rate-of-change, hold the top quintile long and the bottom quintile short.

The thesis is what Claude turns into a typed component graph. A clear thesis produces a clean graph; hand-waving produces sprawl.

02

Have Claude compose the strategy

Hand the thesis to Claude as a single prompt:

“Build me a funding-carry strategy on Hyperliquid using a carry signal and a funding-level regime. Universe: top 30 perps. Timeframe: 1d. Vol-target 0.15.”

Claude calls keel_components_search to find the carry signal and funding-level regime in the 182-component library, then calls keel_strategy_compose to author the typed DSL. The compose tool validates the graph at author time — wrong-shape connections fail here, not at backtest.

# In Claude Code, plain English:
"Build me a funding-carry strategy on Hyperliquid using
 a carry signal + a funding-level regime. Universe: top
 30 perps. Timeframe: 1d. Vol-target 0.15."

# Claude calls (via MCP):
#   keel_components_search(query="funding carry")
#   keel_components_search(query="funding regime")
#   keel_strategy_compose(name="hl_carry_v1", dsl=...)
03

Backtest against real Hyperliquid history

Ask Claude to run the strategy. The deterministic engine reads Hyperliquid 15-minute bars and 1-hour funding, applies the live HL fee schedule and per-asset slippage, and decomposes P&L so you can see what came from price versus what came from carry.

The worked example for this tutorial — a funding-carry strategy composed via the same MCP flow — produced a Sharpe of 2.17 and +79.6% total return over 2024-08-15 → 2026-04-30 with a -9.7% max drawdown. Open the share URL for the full tearsheet: verified Keel backtest.

# In Claude Code:
"Backtest hl_carry_v1 from 2024-08-15 to 2026-04-30
 and summarize."

# Claude calls:
#   keel_backtest_run(strategy_id="...", start=..., end=..., wait=true)
#   keel_backtest_summarize(run_id="...")
# → returns metrics + share URL
04

Iterate

A first backtest is rarely the final bot. Forking is the fast loop: change a parameter, rerun, compare. Claude handles the forking and the comparison if you ask.

# In Claude Code:
"Fork hl_carry_v1 with vol target 0.10 and a shorter
 ROC window. Compare Sharpe and max DD against the
 original."

# Claude calls:
#   keel_strategy_fork(source_id="...", patch=...)
#   keel_backtest_run(...)
#   keel_strategy_diff(a="...", b="...")
05

Deploy (when ready)

Deployment is explicit and gated. Both locks must be set before the executor will accept the strategy against your account:

  1. Live OAuth scope. Run keel auth login --scope live from the shell to request the live-trading scope through the same browser consent flow.
  2. Local arming. Run keel arm live set --account <id> to arm the local CLI against the specific Hyperliquid sub-account.
  3. Deploy. keel live deploy <strategy-id> hands the compiled artifact off to the executor. The same compiled graph that backtested is what trades — no port from research to production.

After deploy, Claude is no longer in the runtime. The strategy runs on its own schedule against your account until you pause or stop it.

FAQ

Common questions

Can Claude trade my Hyperliquid account autonomously?

No. Claude is in the loop while you build the strategy — composing the typed DSL, running backtests, helping you iterate. Once you deploy, the compiled strategy runs on its own schedule against your Hyperliquid account; the agent is not in the trade loop. Live trading is non-custodial via Hyperliquid native delegation, gated by an OAuth live scope plus a local arming step. Two locks, both required.

What kind of strategies can I build this way?

Anything expressible in the 182-component Keel DSL — which today covers funding-carry, cross-sectional momentum, regime-gated portfolios, volatility-targeted multi-asset systems, mean-reversion baskets, and combinations of all of the above. The DSL is typed; if you can describe the strategy as a signal pipeline plus a sizing rule plus a rebalancer, it composes. What it does not yet cover: sub-15-minute strategies, options strategies (HL is perp-focused), strategies that need a custom data source we have not ingested.

How long does the build-backtest-iterate loop take?

A first backtest of a simple composed strategy is typically minutes — most of the time is Claude reasoning through component selection and the backtest job running on the engine. A typical iteration cycle (change a parameter, rerun, compare) takes a couple of minutes. Wall-clock varies with prompt complexity, agent latency, and backtest window length. Long-window backtests (multi-year, full universe) are the slowest piece; the engine is fast but not instant.

Do I need to know Python to build a bot this way?

Recommended for review; not strictly required for the compose step. Claude writes the typed DSL — your job in the loop is to read it, sanity-check the components and parameters, and decide whether the structure matches your thesis. The DSL reads like a Python pipeline (it is a Python pipeline) but the surface area is constrained — typed components, validated connections, a fixed set of primitives. People without Python backgrounds work with it; people with Python backgrounds modify the strategy.py directly through the CLI when Claude misses something.

How do I share my bot with someone else?

Ask Claude to call keel_share_create on the strategy. The tool returns a public share URL that renders the full tearsheet (metrics, equity curve, decomposed P&L, parameter dump). The recipient can fork the strategy into their own account from the share page — the same Claude-composable artifact, ready for them to iterate on. Sharing does not give the recipient access to your account; it gives them access to the strategy definition.

What will you build?

Live on Hyperliquid in minutes.

Get started
Non-custodial
Your keys never leave your wallet. Your strategies run on your account — Keel never holds funds.
Same code, backtest to live
The strategy that passed your backtest is the strategy that trades. Same pipeline, no surprises.
Full visibility
See every position, trade, and decision in real time. Pause anytime. Your account, your control.