A comprehensive Hyperliquid trading system with both CLI and REST API interfaces. Execute smart orders, monitor positions, and manage your trading workflow with ease.
Requires Python 3.11 or newer.
# Clone the repository
git clone https://github.com/zydtiger/hyperliquid-cli.git
cd hyperliquid-cli
# Create virtual environment and install in development mode
uv venv
uv pip install -e .
# Activate the virtual environment
source .venv/bin/activate# Create a default configuration file (saved to ~/.hyperliquid-cli/config.yaml)
hyperliquid-cli create-config
# Edit the generated config.yaml with your credentials
# Add your Hyperliquid API credentials and trading preferences# Launch the interactive CLI
hyperliquid-cli run
# Or start the backend API server
hyperliquid-backend
# The backend will be available at http://localhost:8080Once you start hyperliquid-cli run, you'll enter an interactive session with these available commands:
hyperliquid> order # Launch order creation wizard
hyperliquid> positions # Show open positions
hyperliquid> balances # Display account balances
hyperliquid> watch BTC # Launch the live watch TUI for BTC perps
hyperliquid> open_orders # List all open orders
hyperliquid> cancel_order all # Cancel all open orders
hyperliquid> order_status 12345 # Get specific order details
hyperliquid> modify_order 12345 # Modify existing order
hyperliquid> status # Show account status
hyperliquid> help # Show available commands
hyperliquid> quit # Exit the CLI
- Interactive Trading Wizards: Step-by-step order creation with validation
- Real-time Market Data: Access current prices, funding rates, and market depth
- Live Watch TUI: Monitor mark price, open interest, and the top of book in one screen
- Portfolio Management: Monitor positions, balances, and PnL
- Order Operations: Create, modify, cancel, and track orders
- Smart Prompts: Context-aware input with tab completion
FastAPI-based REST server providing comprehensive trading endpoints:
Market Data:
GET /available_coins- List all tradable assetsGET /ticker/{coin}- Real-time price and funding dataGET /watch/{coin}- Live mark price history and order book snapshot for perpsGET /metadata/{coin}- Trading specifications
Order Management:
POST /market_order- Execute market ordersPOST /limit_order- Place limit orders with TIF optionsPOST /modify_order- Modify existing limit ordersPOST /cancel_order- Cancel single or all orders
Portfolio Operations:
GET /positions- All open positionsGET /balances- Comprehensive balance informationGET /order_status/{id}- Detailed order information
The configuration file is automatically created at ~/.hyperliquid-cli/config.yaml when you run hyperliquid-cli create-config.
You can also specify a custom configuration path using the --config option:
hyperliquid-cli --config /path/to/custom/config.yaml runHere's the configuration structure:
hyperliquid:
account_address: "your_ethereum_address"
private_key: "your_private_key"
network: "mainnet" # or "testnet"
trading:
default_slippage: 0.005
default_time_in_force: "GTC"
backend:
host: "localhost"
port: 8080
logging:
level: "INFO"- Python: 3.11 or higher
- Dependencies: Automatically installed with the package
- Hyperliquid Account: API credentials from the exchange
# Clone the repository
git clone https://github.com/zydtiger/hyperliquid-cli.git
cd hyperliquid-cli
# Set up development environment
uv sync --dev
uv run pre-commit install
# Run tests
uv run pytest -v .
# Format code
uv run ruff format .
# Type checking
uv run mypy srchyperliquid-cli/
├── src/
│ ├── backend/ # FastAPI REST API server
│ ├── cli/ # Command-line interface
│ └── models/ # Data models and types
├── tests/ # Comprehensive test suite
├── docs/ # Documentation
└── config.example.yaml # Configuration template
When running hyperliquid-backend, visit:
- Swagger UI:
http://localhost:8080/docs - ReDoc:
http://localhost:8080/redoc
- Private keys are encrypted in configuration
- API communication uses HTTPS
- No sensitive data is logged
- Supports testnet for safe testing
GNU Affero General Public License v3.0 - see LICENSE for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
pytest -v . - Install hooks once:
uv run pre-commit install - Hooks run
uv run ruff check --fixanduv run ruff formaton staged Python files at commit time - Submit a pull request
- Issues: GitHub Issues
- Documentation: Project Wiki
- Hyperliquid: Official Docs
