This guide explains the different ways to run your Hyperliquid trading bot and best practices for each approach.
You have three different bot types:
Bot Type | File | Purpose | Running Time |
---|---|---|---|
Telegram Bot | telegram_bot.py |
Remote control interface | Continuous |
Strategy Bot | strategy_bot.py |
Automated trading strategies | Continuous |
Terminal Bot | simple_bot.py |
Interactive terminal interface | On-demand |
Goal: Monitor and control manually via Telegram
# Run only the Telegram bot
source venv/bin/activate
python telegram_bot.py
Goal: Fully automated trading with monitoring
# Terminal 1: Run strategy bot
source venv/bin/activate
python strategy_bot.py
# Terminal 2: Run Telegram bot for monitoring
source venv/bin/activate
python telegram_bot.py
Goal: Test strategies and debug
# Use terminal bot for quick testing
source venv/bin/activate
python simple_bot.py
# These run forever until you stop them
python telegram_bot.py # Listens for Telegram commands 24/7
python strategy_bot.py # Executes strategies every 60 seconds
# Example: Daily log rotation (optional)
0 0 * * * /path/to/your/log_rotation_script.sh
# Start a screen session
screen -S trading_bot
# Run your bot
source venv/bin/activate
python telegram_bot.py
# Detach: Ctrl+A, then D
# Reattach: screen -r trading_bot
Create /etc/systemd/system/trading-bot.service
:
[Unit]
Description=Hyperliquid Trading Bot
After=network.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/path/to/trader_hyperliquid
Environment=PATH=/path/to/trader_hyperliquid/venv/bin
ExecStart=/path/to/trader_hyperliquid/venv/bin/python telegram_bot.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl enable trading-bot
sudo systemctl start trading-bot
sudo systemctl status trading-bot
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "telegram_bot.py"]
npm install -g pm2
pm2 start telegram_bot.py --interpreter python3
pm2 startup
pm2 save
Start with manual control:
python telegram_bot.py
Test strategies separately:
python strategy_bot.py # Watch logs, don't let it trade yet
Run both bots in separate processes:
# Terminal 1 (or systemd service)
python telegram_bot.py
# Terminal 2 (or systemd service)
python strategy_bot.py
Use process monitoring:
# Check if bots are running
ps aux | grep python
# Check logs
tail -f ~/.local/share/hyperliquid-bot/logs/
# In strategy_bot.py
self.loop_interval = 60 # Run every 60 seconds
Why 60 seconds?
Adjust based on strategy:
# Scalping: More frequent (careful of API limits)
self.loop_interval = 30 # 30 seconds
# Swing trading: Less frequent
self.loop_interval = 300 # 5 minutes
# Long-term: Much less frequent
self.loop_interval = 3600 # 1 hour
HYPERLIQUID_TESTNET=true
# Check bot status via Telegram
/status
# Check logs
tail -f logs/trading_bot.log
# Check system resources
htop
# Add to your strategy bot
if large_loss_detected:
await send_telegram_alert("⚠️ Large loss detected!")
# In your strategy
if daily_loss > max_daily_loss:
logger.error("Daily loss limit reached. Stopping trading.")
self.trading_enabled = False
Stop bots gracefully:
# Ctrl+C or
sudo systemctl stop trading-bot
Backup configuration:
cp .env .env.backup
Update code:
git pull # or download new version
Test in terminal:
python simple_bot.py
Restart production bots:
python telegram_bot.py
# Check configuration
python -c "from config import Config; Config.validate()"
# Check dependencies
pip list | grep hyperliquid
# Test token
curl https://api.telegram.org/bot<YOUR_TOKEN>/getMe
# Check chat ID
python get_telegram_chat_id.py
# Check if trading is enabled in code
grep -n "Uncomment to enable" strategy_bot.py
# Check balance and positions
python simple_bot.py
# Start manual control bot
python telegram_bot.py
# Start automated trading bot
python strategy_bot.py
# Start both (recommended for production)
python telegram_bot.py &
python strategy_bot.py
# Test configuration
python simple_bot.py
# Get Telegram Chat ID
python get_telegram_chat_id.py
# Check if running
ps aux | grep "python.*bot"
# Stop all bots
pkill -f "python.*bot"
Remember: Start simple, test thoroughly, and scale gradually! 🚀