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.
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.
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.
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.
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.
Build it in Python, or describe it in plain English
Python is a common choice for a first bot. Hyperliquid publishes an official Python SDK for placing orders and reading markets, and open-source frameworks such as Freqtrade give you a backtester and a live runner in Python. You still own the data, the cost model and the server, as the list above shows. The open-source bots compared covers Freqtrade and the others.
On Keel, a strategy is itself a short file in Python syntax, built only from Keel's blocks: load prices, compute a signal, size the positions. You can edit it in the Code view in the app, or write it in your own editor and use the keel-trade command-line tool to check it and run backtests on Keel against Hyperliquid history. No server of your own, and the file you tested is the one that runs live. The Python backtesting guide shows the setup.
If you'd rather not write code, describe the rules in plain English instead. Keel's AI builds the same blocks from your description, and you can read the result as a canvas or as that same file before you backtest it.
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
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
Build it from blocks
Build the rules from Keel's 262 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
Globalsconfigtarget_timeframe1dbar_offset12hUniverseassetsManual · HL Perps · 8 symbols8 resolvedExecutionordersrebalanceOn ChangePipeline6 stepsPriceDataLoaderData LoaderParallel2 branchesfastEWMAIndicatorwindow20slowEWMAIndicatorwindow50CrossoverSignal Composerfast_keyfastslow_keyslowAboveThresholdFilterSignal Transformthreshold0FixedWeightSizerPosition Sizerweight_per_position0.125LeverageCapRisk Managermax_leverage1Globals(target_timeframe="1d", bar_offset="12h") Universe(mode="manual", symbols=["BTC", "ETH", "SOL", "BNB", "XRP", "DOGE", "HYPE", "SUI"], market="perp", resolved=["BTC", "ETH", "SOL", "BNB", "XRP", "DOGE", "HYPE", "SUI"], resolved_at="2026-07-06T00:00:00Z") Execution(rebalance="on_change") Pipeline([ PriceDataLoader(), { "fast": [EWMA(window=20)], "slow": [EWMA(window=50)], }, Crossover(fast_key="fast", slow_key="slow"), AboveThresholdFilter(threshold=0.0), FixedWeightSizer(weight_per_position=0.125), LeverageCap(max_leverage=1.0), ], name="ma_crossover_crypto") - 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.
Sharpe1.05Total return+130.9%Worst drawdown−30.4%Trades54Hyperliquid, 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
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
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.
Automate it with n8n or Zapier
n8n and Zapier are workflow tools. A trigger starts a chain of steps that call other apps, and both can start a workflow from a webhook, a web address that another service calls. A common trading setup is a chart alert that calls the webhook, then a step that sends an order to your exchange's API.
That makes sense when you already have a signal you trust, such as an alert on one coin, and only need the plumbing to place the order. It suits small, simple rules, and it is quick to set up.
The gaps are the ones from the coding route. Nothing backtests the whole flow with fees and funding. A retried step can send an order twice. Your exchange key sits in another service. And when a step fails at night, you are the monitoring.
Keel takes no webhook alerts and sends no trades out to other tools. The strategy itself decides, on the schedule it was built with, and the strategy you backtested is the one that runs live. If your rules span many coins, depend on costs and funding, or need a backtest before you trust them, a tested strategy fits better than a chain of webhooks.
What n8n and Zapier do comes from their own docs, as of October 2026. n8n, Zapier.
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.
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.
Can I build a trading bot with n8n?
Yes, for simple rules. A webhook trigger in n8n, or in Zapier, can take a chart alert and send an order to an exchange's API. You test and monitor the flow yourself, and nothing backtests it with fees and funding. Keel doesn't take webhook alerts: the strategy you backtested decides and trades on its own schedule.
Can I build a trading bot in Python?
Yes. Hyperliquid has an official Python SDK, and frameworks like Freqtrade are written in Python. On Keel a strategy is a short file in Python syntax, built only from Keel's blocks, which you can edit in the app or check and backtest from your terminal with the keel-trade tool, or skip the code and describe the rules in plain English.
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 on a timeframe of 1 day or slower and run one live on a timeframe of 1 hour or slower, with a 5 basis point fee on live trades. Paid plans start at $49 a month and lower that fee. The pricing page has the full limits.
Build your first bot
Starting is free. You see the blocks, the backtest and a paper run before any real money trades.