A powerful, user-friendly trading bot for Hyperliquid with USDC-based trading, leverage support, and comprehensive risk management.
- π― USDC-based Trading: Trade with easy-to-understand USDC amounts
- β‘ Leverage Support: 1x to 10x leverage with automatic position sizing
- π₯οΈ Interactive Interface: User-friendly parameter configuration
- π‘οΈ Risk Management: Built-in stop loss, take profit, and position limits
- π Market Orders: Fast execution with market price orders
- π Position Management: Open, close, and monitor positions
- π Real-time Updates: Live position monitoring and PnL tracking
git clone https://github.com/your-username/hyperliquid_trader.git
cd hyperliquid_trader# Option 1: Use setup script (recommended)
python setup.py
# Option 2: Manual installation
pip install -r requirements.txt# Copy environment template
cp config.env.example .env
# Edit .env with your API keys
# Get API keys from: https://app.hyperliquid.xyz/API# Quick start (recommended)
python start_trading.py
# Direct trading interface
python trade_usdc.py- Python 3.8 or higher
- Hyperliquid account
- API Agent Wallet (get from Hyperliquid API)
- Minimum $10 in your API wallet
# Hyperliquid API Configuration
HYPERLIQUID_API_KEY=your_api_key_here
HYPERLIQUID_SECRET_KEY=your_secret_key_here
HYPERLIQUID_BASE_URL=https://api.hyperliquid.xyz
# Trading Configuration
DEFAULT_SYMBOL=ETH
DEFAULT_SIDE=long
DEFAULT_SIZE=0.1
DEFAULT_LEVERAGE=1.0
# Risk Management
MAX_POSITION_SIZE=1.0
STOP_LOSS_PERCENTAGE=5.0
TAKE_PROFIT_PERCENTAGE=10.0
# Monitoring
MONITORING_INTERVAL=5
ENABLE_WEBSOCKET=true
# Advanced Risk Management
MAX_DAILY_LOSS=100.0
MAX_POSITION_PERCENTAGE=0.1
MAX_LEVERAGE=10.0
EMERGENCY_STOP_LOSS=20.0The bot provides comprehensive API access:
Account Information:
get_account_value()- Get total account value in USDget_user_state()- Get complete user account stateget_position(coin)- Get position for specific coinget_available_balance()- Get available trading balance
Market Data:
get_l2_book(coin)- Get order book dataget_candles(coin, interval, start_time, end_time)- Historical price dataget_trades(coin)- Recent trades for a coinget_meta()- Exchange metadata and asset information
Trading Operations:
place_market_order(coin, is_buy, sz, leverage)- Execute market ordersplace_order(coin, is_buy, sz, limit_px, leverage)- Place limit ordersupdate_leverage(coin, leverage)- Update position leveragecancel_order(oid)- Cancel specific ordercancel_all_orders(coin)- Cancel all orders
Position Management:
buy(usdc_amount, use_usdc)- Buy with USDC amountsell(usdc_amount, use_usdc)- Sell with USDC amountclose_position()- Close specific positionclose_all_positions()- Emergency close all positions
# Interactive trading interface
python trade_usdc.py
# Show help and options
python trade_usdc.py help
# Quick start launcher
python start_trading.pyThe trading interface provides 4 main options:
-
Check Positions - View all open positions and PnL
- Shows account value and balance
- Displays position details (symbol, side, size, entry price, leverage)
- Shows unrealized PnL for each position
- Overall account status (profit/loss)
-
Place Trade - Execute new trades
- Interactive parameter configuration
- Symbol selection (ETH, BTC, SOL, AVAX)
- Position side (long/short/close)
- USDC amount input
- Leverage setting (1x-10x)
- Risk management parameters
-
Close All Positions - Emergency exit all positions
- Lists all open positions
- Confirmation prompt
- Closes all positions at market price
- Shows success/failure status
-
Exit - Close the interface
- Long ETH: $100 with 3x leverage = $300 position
- Short BTC: $50 with 2x leverage = $100 position
- Close Position: Market price exit
- Close All: Emergency exit all positions
| Parameter | Description | Example |
|---|---|---|
| Symbol | Trading pair | ETH, BTC, SOL, AVAX |
| Side | Position direction | long, short, close |
| USDC Amount | Investment amount | $100 |
| Leverage | Position multiplier | 3x = 3x position size |
| Stop Loss | Risk management | 5% below entry |
| Take Profit | Profit target | 10% above entry |
- Stop Loss: Automatic exit at specified loss percentage
- Take Profit: Automatic exit at specified profit percentage
- Position Limits: Maximum position size controls
- Daily Limits: Maximum daily loss protection
- Emergency Stop: Circuit breaker for extreme losses
- ETH (Ethereum)
- BTC (Bitcoin)
- SOL (Solana)
- AVAX (Avalanche)
- And more...
| Investment | Leverage | Position Value |
|---|---|---|
| $100 | 1x | $100 |
| $100 | 3x | $300 |
| $100 | 5x | $500 |
| $100 | 10x | $1,000 |
hyperliquid_trader/
βββ π .github/ # GitHub workflows and templates
βββ π trade_usdc.py # Main trading interface
βββ π hyperliquid_client.py # API client (hybrid SDK + direct API)
βββ π trading_bot.py # Trading logic and risk management
βββ π config.py # Configuration management
βββ π start_trading.py # Quick start launcher
βββ π setup.py # Setup and installation script
βββ π requirements.txt # Python dependencies
βββ π config.env.example # Environment template
βββ π .gitignore # Git ignore rules
βββ π LICENSE # MIT License
βββ π CONTRIBUTING.md # Contribution guidelines
βββ π QUICK_START.md # Quick start guide
βββ π hyperliquid_analysis.md # Technical analysis
βββ π README.md # This file
- β Input Validation: All parameters validated
- β Balance Checks: Prevents over-trading
- β Error Handling: Graceful error recovery
- β Position Limits: Maximum position controls
- β Risk Controls: Stop loss and take profit
- β Account Value Monitoring: Real-time account value tracking
- β Position Size Validation: Prevents oversized positions
- β Leverage Limits: Maximum leverage controls (1x-10x)
- β Emergency Stop: Circuit breaker for extreme losses
- β Confirmation Prompts: Trade confirmation before execution
-
"Insufficient margin" error
- Check your API Agent Wallet balance
- Ensure funds are transferred to API wallet
- Verify minimum order requirements ($10+)
-
"Account value $0.00"
- Fund your API Agent Wallet
- Check API key configuration
- Verify wallet address in .env
-
Leverage not working
- Fixed in latest version
- Position size now correctly calculated with leverage
- Check your
.envconfiguration - Verify API keys are correct
- Ensure sufficient account balance
- Check minimum order requirements
We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Trading cryptocurrencies involves substantial risk of loss. This software is provided as-is without warranty. Use responsibly and never risk more than you can afford to lose.
This bot uses a hybrid approach:
- Official Hyperliquid Python SDK for trading operations
- Direct API calls for market data and account information
- Comprehensive risk management with stop loss and take profit
- Real-time position monitoring and PnL tracking
- Hybrid API Client: Combines SDK and direct API calls
- Trading Bot: Handles trading logic and risk management
- Interactive Interface: User-friendly parameter configuration
- Configuration Management: Environment-based settings
- Setup Automation: Automated dependency installation
- HyperliquidClient: API client with hybrid approach
- TradingBot: Core trading logic and risk management
- TradingConfig: Configuration management
- Interactive Interface: User-friendly trading interface
- Setup Scripts: Automated installation and configuration
For detailed technical analysis, see hyperliquid_analysis.md.
β Star this repository if you find it helpful!