CLI tool for Hyperliquid DEX
npm install hyperliquid-cliA command-line interface for Hyperliquid DEX built with the @nktkas/hyperliquid TypeScript SDK.
Features a beautiful terminal UI with real-time watch modes powered by Ink.
``bash`
npm install -g hyperliquid-cli
- Multi-Account Management - Store and manage multiple trading accounts locally with SQLite
- Real-Time Monitoring - WebSocket-powered live updates for positions, orders, balances, and prices
- Beautiful Terminal UI - Color-coded PnL, depth visualization, and interactive tables
- Trading Support - Place limit, market, stop-loss, and take-profit orders
- Scripting Friendly - JSON output mode for automation and scripting
- Testnet Support - Seamless switching between mainnet and testnet
| Option | Description |
|--------|-------------|
| --json | Output in JSON format |--testnet
| | Use testnet instead of mainnet |-V, --version
| | Show version number |-h, --help
| | Show help |
---
Manage multiple trading accounts locally. Accounts are stored in a SQLite database at ~/.hyperliquid/accounts.db.
Interactive wizard to add a new account:
`bash`
hl account add
- Import API wallets from Hyperliquid for trading
- Add read-only accounts for monitoring only
- Set account aliases for easy identification
- Choose default account for commands
`bash`
hl account ls
Shows all configured accounts with alias, address, type, and default status.
`bash`
hl account set-default
Interactively select which account to use by default.
`bash`
hl account remove
Interactively remove an account from local storage.
---
View account balances and portfolio with optional real-time watch mode.
`bashSpot + perpetuals balances
hl account balances
Shows spot token balances (total, hold, available) and perpetuals USD balance.
$3
`bash
Positions + spot balances combined
hl account portfolioWatch mode
hl account portfolio -w
`Combined view of all positions and spot balances in a single display.
---
Position Monitoring
View and monitor perpetual positions.
$3
`bash
One-time fetch
hl account positionsWatch mode - real-time updates with colored PnL
hl account positions -wSpecific address
hl account positions --user 0x...
`Displays: coin, size, entry price, position value, unrealized PnL, leverage, and liquidation price.
---
Order Management
View, place, and cancel orders.
$3
`bash
hl account ordersWatch mode - real-time order updates
hl account orders -wSpecific address
hl account orders --user 0x...
`Or use the trade command:
`bash
hl trade order ls
`$3
`bash
hl trade order limit Examples
hl trade order limit buy 0.001 BTC 50000
hl trade order limit sell 0.1 ETH 3500 --tif Gtc
hl trade order limit long 1 SOL 100 --reduce-only
`| Option | Description |
|--------|-------------|
|
--tif | Time-in-force: Gtc (default), Ioc, Alo |
| --reduce-only | Reduce-only order |$3
`bash
hl trade order market Examples
hl trade order market buy 0.001 BTC
hl trade order market sell 0.1 ETH --slippage 0.5
`| Option | Description |
|--------|-------------|
|
--slippage | Slippage percentage (default: 1%) |
| --reduce-only | Reduce-only order |$3
`bash
hl trade order stop-loss Examples
hl trade order stop-loss sell 0.001 BTC 48000 49000
hl trade order stop-loss sell 0.001 BTC 48000 49000 --tpsl
`$3
`bash
hl trade order take-profit Examples
hl trade order take-profit sell 0.001 BTC 55000 54000
hl trade order take-profit sell 0.001 BTC 55000 54000 --tpsl
`$3
`bash
View current configuration
hl trade order configureSet default slippage for market orders
hl trade order configure --slippage 0.5
`$3
`bash
Cancel specific order
hl trade cancel Interactive selection from open orders
hl trade cancel
`$3
`bash
Cancel all open orders
hl trade cancel-allCancel all orders for a specific coin
hl trade cancel-all --coin BTCSkip confirmation
hl trade cancel-all -y
`$3
`bash
Cross margin (default)
hl trade set-leverage
hl trade set-leverage BTC 10Isolated margin
hl trade set-leverage BTC 10 --isolatedExplicit cross margin
hl trade set-leverage ETH 5 --cross
`---
Market Information
View market data without authentication.
$3
`bash
List all perpetual and spot markets
hl markets ls
`Shows market metadata including leverage info, price decimals, and trading pairs.
$3
`bash
hl markets prices
`Returns mid prices for all available assets.
---
Asset Information
View asset-specific data with optional watch mode.
$3
`bash
One-time fetch
hl asset price BTCWatch mode - real-time price updates
hl asset price BTC -w
`$3
`bash
One-time fetch with depth visualization
hl asset book BTCWatch mode - real-time order book
hl asset book ETH -w
`Shows top bid/ask levels with cumulative depth bars and spread calculation.
---
Referral System
$3
`bash
hl referral set
`$3
`bash
hl referral status
`---
Background Server
Optional background server for caching market data and faster queries.
$3
`bash
hl server start
`Runs a detached WebSocket server that caches market data.
$3
`bash
hl server stop
`$3
`bash
hl server status
`Shows server status, WebSocket connection state, uptime, and cache status.
---
Examples
$3
`bash
Check positions on testnet
hl --testnet account positionsPlace a testnet order
hl --testnet trade order limit buy 0.001 BTC 50000
`$3
`bash
Watch positions with live PnL
hl account positions -wWatch order book with depth visualization
hl asset book BTC -wWatch specific asset price
hl asset price ETH -w
`$3
`bash
Get BTC price
BTC_PRICE=$(hl asset price BTC --json | jq -r '.price')
echo "BTC: $BTC_PRICE"Get all positions as JSON
hl account positions --json | jq '.positions[] | {coin, size, pnl: .unrealizedPnl}'Check open orders
hl account orders --json | jq '.[] | select(.coin == "BTC")'
`$3
`bash
#!/bin/bash
Simple limit order script
COIN="BTC"
SIDE="buy"
SIZE="0.001"
PRICE="85000"
echo "Placing $SIDE order for $SIZE $COIN @ $PRICE"
hl trade order limit $SIDE $SIZE $COIN $PRICE --json
`---
Configuration
$3
`bash
Required for trading commands (if not using account management)
export HYPERLIQUID_PRIVATE_KEY=0x...Optional: explicitly set wallet address (derived from key if not provided)
export HYPERLIQUID_WALLET_ADDRESS=0x...
`$3
| Path | Description |
|------|-------------|
|
~/.hyperliquid/accounts.db | SQLite database for account management |
| ~/.hyperliquid/order-config.json | Order configuration (default slippage, etc.) |---
Development
$3
`bash
Clone and install
git clone https://github.com/chrisling-dev/hyperliquid-cli.git
cd hyperliquid-cli
pnpm installBuild and link globally
pnpm build
pnpm link --globalNow 'hl' command is available globally
hl --help
`$3
`bash
Run without building
pnpm dev -- account positionsType check
pnpm typecheckBuild
pnpm buildRun tests
pnpm testLint
pnpm lint
`Project Structure
`
hyperliquid-cli/
├── src/
│ ├── index.ts # Entry point
│ ├── cli/
│ │ ├── program.ts # Commander program setup
│ │ ├── context.ts # CLI context (clients, config)
│ │ ├── output.ts # Output formatting (JSON/text)
│ │ ├── watch.ts # Watch mode utilities
│ │ └── ink/ # Ink TUI components
│ │ ├── theme.ts # Color theme
│ │ ├── render.tsx # Render utilities
│ │ └── components/ # React components
│ ├── commands/
│ │ ├── account/ # add, ls, remove, set-default, positions, orders, balances, portfolio
│ │ ├── order/ # limit, market, stop-loss, take-profit, cancel, cancel-all, set-leverage
│ │ ├── markets/ # ls, prices
│ │ ├── asset/ # price, book
│ │ ├── referral/ # set, status
│ │ └── server.ts # start, stop, status
│ ├── lib/
│ │ ├── config.ts # Environment config
│ │ ├── validation.ts # Input validation
│ │ ├── db/ # SQLite database for accounts
│ │ ├── *-watcher.ts # WebSocket watchers (positions, orders, balances, prices, book)
│ │ └── ...
│ ├── client/ # Server client
│ └── server/ # Background server
``License
MIT