A command-line interface for interacting with the Hyperliquid exchange.
# Install from source
pip install -e .
# Or install dependencies manually
pip install hyperliquid-python-sdk click eth-account pydantic# Set your wallet
hl login <private_key>
# Set the network (mainnet or testnet)
hl chain testnet
# Place a buy order
hl buy --asset ETH --size 100
# View positions
hl view open positionsConfig is stored at ~/.hyperliquid/config.json by default.
Use --config / -c to specify a custom config file:
hl --config /path/to/config.json buy --asset ETH --size 100# Set wallet
hl login <private_key>
# Set network
hl chain <mainnet|testnet>
# Set defaults
hl set dl <leverage> # Set leverage (1-100)
hl set da <asset> # Set default asset
hl set ds <size> # Set default size
hl set dm <c|i> # Set margin type (cross/isolated)# Buy/Sell
hl buy --asset ETH --size 100 --price @1900 --tp 5% --sl 3%
hl sell --asset ETH --size 50%
# Take Profit / Stop Loss on existing position
hl tp 50% ETH 5% # TP 50% of ETH position at 5% profit
hl sl 100% BTC 3% # SL 100% of BTC position at 3% loss# TWAP (Time-Weighted Average Price)
hl twap buy 1000 ETH 5,10 # Buy $1000 ETH over 10 orders, 5 min apart
hl twap sell 500 SOL 2,5 # Sell $500 SOL over 5 orders, 2 min apart
# Scale Orders
hl scale buy 1000/10 ETH 1800 1900 # 10 buy orders from $1800-$1900
hl scale sell 500/5 BTC 45000 50000 # 5 sell orders from $45k-$50k
# Pair Trading
hl pair buy 1000 BTC/ETH --price 0.05 --tp 0.06 --sl 0.04
hl pair sell 500 SOL/ETHhl view upnl # Unrealized PNL
hl view wallet balance # Wallet balance
hl view unfilled orders # Open orders
hl view open positions # Open positionsExecute multiple orders from a JSON file:
hl execute orders.jsonExample orders.json:
{
"orders": [
{
"action": "buy",
"asset": "ETH",
"size": "100",
"tp": "5%",
"sl": "3%"
},
{
"action": "sell",
"asset": "BTC",
"size": "50",
"price": "@45000"
},
{
"action": "twap_buy",
"asset": "SOL",
"size": "500",
"interval": "5,10"
},
{
"action": "scale_buy",
"asset": "ETH",
"size": "1000/10",
"lower": 1800,
"upper": 1900
},
{
"action": "pair_buy",
"pair": "BTC/ETH",
"size": "1000",
"tp": "0.06",
"sl": "0.04"
}
]
}Supported actions: buy, sell, tp, sl, twap_buy, twap_sell, scale_buy, scale_sell, pair_buy, pair_sell
100or$100- Absolute USD amount10%- Percentage of account balance
1900or@1900- Limit price- Omit for market order (3% slippage)
5%- Percentage from entry+100or-50- Absolute dollar change1900- Fixed price
from hyperliquid_cli import HyperliquidClient, Config
# Load config
config = Config.load() # or Config.load("/path/to/config.json")
# Create client
client = HyperliquidClient(config)
# Place orders
import asyncio
async def main():
result = await client.buy(asset="ETH", size="100", tp="5%", sl="3%")
print(f"Order: {result.status}")
positions = client.get_positions()
for pos in positions:
print(f"{pos.coin}: {pos.size} @ {pos.entry_price}")
asyncio.run(main())MIT