A copy trading bot for Hyperliquid that automatically mirrors positions from a leader wallet.
- Python 3.8 or higher
- A Hyperliquid account with a funded wallet
- The wallet address of the trader you want to copy
pip install -r requirements.txtOr install individually:
pip install ccxt requests python-dotenvCreate a .env file in the project directory with your credentials:
# Your account credentials (required for LIVE mode, optional for DRY mode)
HYPERLIQUID_WALLET_ADDRESS=0xYourWalletAddress
HYPERLIQUID_PRIVATE_KEY=0xYourPrivateKey
# Who to copy trade from
LEADER_WALLET_ADDRESS=0xLeaderWalletAddress
# Mode settings
DRY_MODE=true # Set to "false" to enable live trading
# Trading settings
POSITION_SIZE_MULTIPLIER=1.0
LEVERAGE=1
MARGIN_MODE=isolatedImportant: Never commit your .env file to git! It contains sensitive information.
python hyperliquid-trading-live-bot.pyYou can run it in a loop or schedule it with cron/task scheduler:
Windows (PowerShell):
while ($true) { python hyperliquid-trading-live-bot.py; Start-Sleep -Seconds 10 }Linux/Mac:
while true; do python hyperliquid-trading-live-bot.py; sleep 10; doneOr use cron (Linux/Mac) to run every minute:
* * * * * cd /path/to/bot && /usr/bin/python3 hyperliquid-trading-live-bot.pyLEADER_WALLET_ADDRESS- Wallet address to copy from
HYPERLIQUID_WALLET_ADDRESS- Your wallet addressHYPERLIQUID_PRIVATE_KEY- Your wallet's private key
DRY_MODE- If "true", only tracks leader positions without executing trades (default: true)POSITION_SIZE_MULTIPLIER- Position size multiplier (default: 1.0)LEVERAGE- Leverage to use (default: 1)MARGIN_MODE- "isolated" or "cross" (default: isolated)POLL_INTERVAL- Seconds between checks (default: 10)MIN_POSITION_SIZE- Minimum position size in USDC (default: 10.0)USE_TP_SL- Copy take profit/stop loss (default: false)
- Fetches Leader Positions: Queries the leader wallet's open positions via Hyperliquid API
- Compares Positions: Checks your current positions against the leader's (in LIVE mode)
- Closes Mismatched Positions: Closes any positions you have that the leader doesn't (LIVE mode only)
- Opens New Positions: Opens positions to match the leader proportionally (LIVE mode only)
- Adjusts Sizes: Adjusts position sizes when they differ from the leader (LIVE mode only)
- DRY_MODE=true (default): Only tracks and displays what trades would be executed. No actual trades are placed. Perfect for testing and monitoring.
- DRY_MODE=false: Executes actual trades to mirror the leader's positions. Requires valid wallet credentials.
- Minimum position size filter (avoids dust positions)
- Symbol blocking capability
- Proportional position sizing
- Error handling and logging
-
"LEADER_WALLET_ADDRESS must be set"
- Make sure your
.envfile exists and containsLEADER_WALLET_ADDRESS
- Make sure your
-
"Failed to initialize exchange"
- Check that your
HYPERLIQUID_WALLET_ADDRESSandHYPERLIQUID_PRIVATE_KEYare correct - Ensure your wallet has funds
- Check that your
-
"Failed to fetch wallet positions"
- Check that
LEADER_WALLET_ADDRESSis a valid Hyperliquid wallet - Verify your internet connection
- Check that
-
Module not found errors
- Run
pip install -r requirements.txtto install dependencies
- Run
- Test with small amounts first
- Understand the risks of copy trading
- Monitor the bot regularly
- The leader trader may lose money, and you will copy those losses
This code is provided as-is for educational purposes.