Production deployment options for your trading bot
python trading_bot.py
This single command handles everything:
# Start a detachable session
screen -S trading-bot
# Run the bot
source venv/bin/activate
python trading_bot.py
# Detach: Ctrl+A, then D
# Reattach: screen -r trading-bot
# Stop: screen -r trading-bot, then Ctrl+C
Create /etc/systemd/system/trading-bot.service
:
[Unit]
Description=Hyperliquid Trading Bot
After=network.target
[Service]
Type=simple
User=your_username
WorkingDirectory=/path/to/ManualTrader
Environment=PATH=/path/to/ManualTrader/venv/bin
ExecStart=/path/to/ManualTrader/venv/bin/python trading_bot.py
Restart=always
RestartSec=30
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
# Enable and start service
sudo systemctl enable trading-bot
sudo systemctl start trading-bot
# Check status
sudo systemctl status trading-bot
# View logs
sudo journalctl -u trading-bot -f
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["python", "trading_bot.py"]
# Build and run
docker build -t trading-bot .
docker run -d --name trading-bot \
--env-file .env \
--restart unless-stopped \
trading-bot
npm install -g pm2
# Start bot with PM2
pm2 start trading_bot.py --interpreter python3 --name "trading-bot"
# Save configuration
pm2 startup
pm2 save
# Monitor
pm2 status
pm2 logs trading-bot
# Check if bot is running
ps aux | grep "python.*trading_bot"
# Monitor logs in real-time
tail -f logs/trading_bot_$(date +%Y%m%d).log
# Check error log
tail -f logs/bot_errors.log
# View bot status via Telegram
# Send /start to your bot, it shows operational status
# Monitor system resources
htop
# Check disk space (logs can grow)
df -h
# Monitor bot memory usage
ps -p $(pgrep -f trading_bot.py) -o pid,vsz,rss,pcpu,pmem,comm
# Backup your configuration and data
cp .env .env.backup
cp trading_stats.json trading_stats.backup
# For screen/tmux: Ctrl+C
# For systemd:
sudo systemctl stop trading-bot
# For Docker:
docker stop trading-bot
# For PM2:
pm2 stop trading-bot
git pull origin main
# or download new version
# Validate configuration
python -c "import sys; sys.path.insert(0, 'src'); from config import Config; Config.validate()"
# Quick test (optional)
python utils/simple_bot.py
# Screen/tmux: screen -S trading-bot, then python trading_bot.py
# Systemd: sudo systemctl start trading-bot
# Docker: docker start trading-bot
# PM2: pm2 start trading-bot
HYPERLIQUID_TESTNET=true
LOG_LEVEL=DEBUG
HYPERLIQUID_TESTNET=true
LOG_LEVEL=INFO
HYPERLIQUID_TESTNET=false # REAL MONEY!
LOG_LEVEL=INFO
# Rotate logs (optional - bot creates daily files)
find logs/ -name "*.log" -mtime +30 -delete
# Compress old logs
gzip logs/trading_bot_$(date -d '1 day ago' +%Y%m%d).log
The bot is lightweight but you can set limits:
# Systemd service limits
[Service]
MemoryLimit=512M
CPUQuota=50%
# Check configuration
python -c "import sys; sys.path.insert(0, 'src'); from config import Config; Config.validate()"
# Check dependencies
pip list | grep -E "hyperliquid|telegram"
# Check permissions
ls -la trading_bot.py
# Check error log
tail -20 logs/bot_errors.log
# Check system logs (systemd)
sudo journalctl -u trading-bot --since "1 hour ago"
# Test in foreground
python trading_bot.py
# Test bot token
curl "https://api.telegram.org/bot<YOUR_TOKEN>/getMe"
# Re-verify Chat ID
python utils/get_telegram_chat_id.py
.env
file permissions restricted: chmod 600 .env
/stats
trading_stats.json
regularly# Check bot status
ps aux | grep trading_bot
# View real-time logs
tail -f logs/trading_bot_$(date +%Y%m%d).log
# Stop bot safely (screen/tmux)
screen -r trading-bot
# Then Ctrl+C
# Restart bot
python trading_bot.py
# Check bot health via Telegram
# Send /start to your bot
Your bot is now production-ready with professional deployment! 🚀🛡️