Guide

How to build a crypto trading bot

A trading bot is a set of written rules that a computer checks on a schedule and turns into orders. You can code one yourself, switch on a template bot, or use a strategy builder. Keel is a strategy builder for Hyperliquid's crypto perpetuals: describe your rules to the AI or build them from blocks, backtest them with fees, slippage and funding, then run the same strategy live from your own account.

By Keel Research Team
Updated October 14, 2026
The bot this guide builds
MA Crossover (Golden Cross) Strategy
EquityDrawdown
Total return
+130.9%
Worst drawdown
−30.4%

Backtest on Hyperliquid after fees, slippage and funding.

Three ways to build a trading bot

Every bot has the same parts: rules, data, a test, an exchange connection and a machine that runs it. The routes differ in how many of those parts you build yourself.

Route 1

Code it yourself

You write the strategy, the backtester and the order logic in a language like Python, and run it on a server you look after. You can build anything, and you are responsible for every part of it.

Fits if you program, enjoy the plumbing and want full control.

Route 2

Switch on a template bot

Exchanges and bot platforms offer ready-made grid and DCA bots. A grid bot places buy orders below the price and sell orders above it and profits while the price swings inside the range. A DCA bot buys a fixed amount on a schedule or after each drop. You pick a coin and a few settings and it starts.

Fits if you want something running today and accept the template's logic. A grid bot keeps buying into a falling market, and a DCA bot never decides when to stop.

Route 3

Use a strategy builder

You set the rules from ready-made blocks, or describe them to an AI that builds them for you, and the builder handles the data, the backtest and the live run. You decide what the bot does without writing the plumbing.

Fits if you have your own idea and want to test it properly before money goes in. This is the route the step-by-step below follows.

What coding one yourself takes

Plenty of traders build their first bot in Python, and it is a good way to learn how markets and exchanges work. Expect the strategy itself to be the smallest part of the code. These are the other parts.

An exchange connection

Most exchanges have an API and a client library. On Hyperliquid you sign orders with an API wallet and talk to its public API, for example through its Python SDK. You handle order types, minimum sizes, rejected orders and rate limits.

Data

You need candles and, for perpetual futures, funding history, going back far enough to cover a bull market, a crash and a sideways stretch. You download it, store it and keep it up to date, and check for gaps.

A backtester

This is where most home-made bots go wrong. The backtest has to charge trading fees, slippage and funding, and it must only use data that was available at each moment. One line that peeks at the next candle can make a losing idea look great.

Somewhere to run it

A bot on your laptop stops when the laptop sleeps. Most people rent a small cloud server, then add restarts after crashes, logs and a way to check on it from a phone.

Risk controls

Limits on position size and leverage, a stop when losses pass a level, and a switch that closes everything if something looks wrong. These are the parts people skip when the backtest looks good, and the parts that matter most on a bad day.

If you take this route, test the backtester before you trust it. Run a strategy whose result you already know and check the numbers match. Then paper trade before you go live, the same as on any other route.

How to build a trading bot with Keel

The worked example is the MA Crossover (Golden Cross) Strategy from the Keel library. It is a classic first bot: simple rules, few trades, and simple to check by eye.

  1. 1

    Write the idea down as rules

    Write what to trade, when to get in, when to get out and how big to go, in plain sentences. If you can't say when the bot sells, it isn't ready to build yet. You can also start from a strategy in the Keel library and change it.

    “Once a day, check eight big coins: BTC, ETH, SOL, BNB, XRP, DOGE, HYPE and SUI. Hold a coin long while its 20-day moving average is above its 50-day average. When it drops below, sell and sit in cash. Give every coin the same slice of the account, and never borrow.”

    That covers what to trade, when to buy, when to sell and how big to go. Nothing is left for the bot to guess.

  2. 2

    Build it from blocks

    Build the rules from Keel's 251 building blocks, or describe them and let the AI pick the blocks. Each block is one job: load prices, compute an average, compare two lines, size the position, cap the risk. The strategy sits on a canvas with every setting showing, and every change is saved as a new version.

    Here is the example as the Keel editor shows it. Price data comes in and splits into a fast and a slow moving average. A crossover block compares them, a filter keeps only the coins where the fast line is on top, and the last blocks give each one the same slice of the account and cap leverage at one times, so the bot never borrows. Switch to Code to see the same strategy as text.

    Configuration

    Globalsconfig
    target_timeframe1dbar_offset12h
    UniverseassetsManual · HL Perps · 8 symbols8 resolved
    Executionorders
    rebalanceOn Change
    Pipeline6 steps
    PriceDataLoaderData Loader
    Parallel2 branches
    fast
    EWMAIndicator
    window20
    slow
    EWMAIndicator
    window50
    CrossoverSignal Composer
    fast_keyfastslow_keyslow
    AboveThresholdFilterSignal Transform
    threshold0
    FixedWeightSizerPosition Sizer
    weight_per_position0.125
    LeverageCapRisk Manager
    max_leverage1
  3. 3

    Backtest it with real costs

    Run the strategy over Hyperliquid price and funding history. Keel charges trading fees and slippage on every trade and applies real funding to every open position. Look at the worst drawdown and the bad months before the total return.

    Sharpe
    1.05
    Total return
    +130.9%
    Worst drawdown
    −30.4%
    Trades
    54

    Hyperliquid, Aug 2024 to Sep 2026, after fees, slippage and funding, on the default settings rather than the best run. Two things to read here. The worst drawdown is the loss you would have sat through, and with no stop the bot rides every sell-off down until the averages cross. And 54 trades is a small sample, so the result says more about the trend in this window than about the rules.

    See the full backtest and every setting tested
  4. 4

    Paper trade it on live prices

    Start a paper run. It runs the saved strategy forward on live Hyperliquid prices with simulated fills, on the strategy's own schedule, with no wallet or exchange account. The run's page shows how closely it tracks its backtest.

    Give it a few weeks. A daily bot like this one may not trade at all in that time, which is normal. You are checking that it behaves the way the backtest says it should. How paper trading works.

  5. 5

    Run it live from your own account

    Connect the wallet you use on Hyperliquid and sign once to let Keel trade. Your money stays in your own Hyperliquid account. Keel can place trades there but can never withdraw, and you can pause the strategy at any time.

    Start smaller than you plan to end up. The first weeks live tell you how real fills compare with the test.

What goes wrong with trading bots

Most bots that lose money do it for one of these reasons, whichever route built them. Read them before the first live trade.

Overfitting

Try enough settings and one of them will look brilliant on past data by luck. That setting usually does worse live than a plain one.

Change one thing at a time and prefer settings whose neighbours also work. Every library page shows the result for every setting tested, so you can see whether the default sits on a plateau or a lucky spike.

Fees and funding

A bot that trades often pays fees and slippage every time, and on perpetual futures an open position pays or earns funding every hour. A backtest that leaves these out can turn a loser into a winner.

Keel's backtests charge fees, slippage and funding as they go, and the paper run charges them too.

Leverage and liquidation

With leverage, a move against you can close the position at a loss before your stop ever fires. Crypto moves fast enough for this to happen overnight.

Start without leverage. Keel has blocks for a leverage cap, a stop loss and a trailing stop, and the worked example above never borrows.

Bugs

Most home-made bots have two programs: the one that was backtested and the one that trades. Small differences between them pile up, and a bug in the live one can send orders nobody tested.

In Keel the backtest, the paper run and the live run use the same strategy. The paper run shows how closely live behaviour tracks the backtest before real money is involved.

Running it unattended

Exchanges have outages, servers restart, and markets do things your backtest never saw. An API key that can withdraw is a risk sitting on a server.

Keel runs the strategy on its own servers on the schedule it was built with. The wallet permission lets Keel trade but never withdraw. Check on it regularly, and pause it if the market stops looking like your test.

Further reading: overfitting in crypto backtests, how funding rates work and how liquidation works on Hyperliquid. For how Keel's backtests and live runs fit together, see how Keel works.

Build it from Claude or ChatGPT

Asking a chatbot to write a bot script gets you code in seconds, and checking that it handles fees, funding and sizing is still your job. Connect Keel to Claude or ChatGPT instead and the assistant builds the strategy from Keel's blocks, runs the backtest and sends you a link to the result. The agent builds, tests and reads. When you want to run a strategy on your account, it hands it to the Keel app and you take it from there.

FAQ

Questions about building a trading bot

Ask AI about Keel
Can I build a trading bot without coding?

Yes. A template bot needs no code but only runs the template's logic. A strategy builder like Keel lets you set your own rules from blocks, or describe them to the AI, and handles the data, backtest and live run. There is a code view if you want it, but you never have to use it.

How do I create an AI trading bot?

Describe the rules to the AI in Keel and it builds them from blocks that exist, so it can't invent an indicator. You read the blocks, backtest the result and change what you don't like. The AI never places trades itself. The strategy you approved does, on the schedule it was built with.

Are trading bots profitable?

Some are and many aren't. A bot only follows its rules faster and more consistently than you would, so it can't fix an idea with no edge. Judge one by a backtest with fees and funding, then by a paper run on live prices, and expect live results to be worse than the backtest.

Do I need to keep my computer on?

Not with Keel. The strategy runs on Keel's servers on its own schedule, for paper runs and live runs alike. If you code your own bot, it needs a machine that stays on, which is why most people rent a cloud server.

Which exchange does it trade on, and who holds my money?

Keel trades Hyperliquid's crypto perpetual futures, such as BTC, ETH, SOL and HYPE. Stock and index perps are HIP-3 markets, and Keel doesn't support them yet. Support is coming soon. Your money stays in your own Hyperliquid account, and Keel can place trades there but can never withdraw.

How long does it take to build one?

Coding a bot with a proper backtester takes most people weeks. With a builder you can have a first version backtested the same day. The longer part is the testing that follows: trying a change, reading the backtest, then paper trading for a while before real money.

What does it cost?

Coding one yourself costs your time plus a server, usually a few dollars a month. On Keel, starting is free: the free plan lets you build and backtest strategies, paper trade one strategy and run one live, with a 5 basis point fee on live trades. Paid plans start at $29 a month and lower that fee. The pricing page has the full limits.