All Tools & Strategies

Hyperliquid Grid Bot

An open-source grid bot for Hyperliquid perpetuals. It places layered buy and sell orders around a center price, sizes in asset units, and leaves the grid shape fixed after launch.

Range TradingGrid

What This Grid Actually Is

This bot builds a two-sided limit-order grid around a center price. It places buy orders below the center, sell orders above it, and then replaces filled orders with the opposite side one grid step away.

Because this runs on perpetuals, the sell side is not just passive cash liquidation. Filled sell orders can create short exposure. That means the bot is carrying directional inventory in both breakout directions depending on what gets filled first.

So this is a perpetual grid bot, not a spot inventory balancer. The distinction matters for risk and for how you think about margin usage.

How The Current Implementation Works

The bot uses `--center`, `--levels`, and `--spacing` to build the grid. Before placing orders, it validates that the rounded levels stay distinct, stay on the correct side of the center, and do not collapse into non-positive prices.

After launch, it monitors fills on a loop. When a buy fills it places a replacement sell above; when a sell fills it places a replacement buy below. That keeps the grid cycling while price oscillates.

Once the grid is live, the center stays fixed. The implementation does not try to cancel and rebuild the grid automatically, which avoids quietly leaving stale orders behind during a reshape.

What The Parameters Mean

`--center` is the grid midpoint. If omitted, the bot uses the current market price on startup. `--spacing` is a percentage of the center price, and `--levels` is the number of buy and sell steps per side.

`--size` is the size of each individual order in asset units, not USD notional. If you set `--size 0.01`, every rung uses 0.01 units of the symbol.

`--interval` controls how often the bot checks for fills. If you want to reposition the grid later, you do that manually by stopping the bot and restarting it with a new center.

Where The Strategy Fails

The bot does best when price chops around a range and repeatedly fills both sides. It does badly when the market trends hard enough that inventory accumulates on one side and the replacement logic keeps leaning into a losing direction.

That breakout risk is real in both directions. In a strong rally, sell orders can leave you net short. In a strong selloff, buy orders can leave you with a heavy long inventory at poor average prices.

So again, the value here is a clean open-source baseline, not a promise that the grid is self-protecting in all market regimes.

Command-Line Arguments

FlagDescriptionDefault
--symbolPerp symbolETH
--centerGrid center price; auto-uses current market price when omittedauto
--levelsNumber of buy and sell levels per side10
--spacingGrid spacing as a percent of the center price0.5
--sizePer-order size in asset units, not USD notional50
--intervalFill-check cadence in seconds30

Risk Warnings

  • Filled sell orders can create short perp exposure; this is not a cash-only grid.
  • Asset-unit sizing can mislead you if you are thinking in USD notional.
  • A trend can leave the bot carrying large one-sided inventory.
  • The grid shape stays fixed after launch, so repositioning means stopping and restarting the bot manually.

Get Started

Run the linked repo from its root with the exact entrypoint this strategy exposes.

Setup
bash

1. Clone the repo

$ git clone https://github.com/atlasdetitan/hyperliquid-trading-bots.git

$ cd hyperliquid-trading-bots

2. Install dependencies

$ python3 -m pip install -r requirements.txt

3. Configure credentials

$ printf 'PRIVATE_KEY=0x...\\n' > .env

Generate an agent wallet at app.hyperliquid.xyz/API and set PRIVATE_KEY in .env. If you use an agent wallet, add ACCOUNT_ADDRESS for the authorizing main wallet.

4. Run the repo entrypoint

Live trading example

$ python3 strategies/grid_bot/bot.py --symbol ETH --levels 10 --spacing 0.5 --size 0.01 --interval 30

DEPLOY ON HYPERLIQUID

Run this bot on the fastest on-chain perpetuals exchange