Skip to content

TechCodinz/LeanTrader-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Professional Trading Bot

Advanced ML-powered trading bot with real-time learning, risk management, and comprehensive monitoring.

🚀 Features

🧠 Machine Learning Engine

  • LSTM Neural Networks for price prediction
  • Random Forest and Gradient Boosting ensemble models
  • Real-time feature engineering with technical indicators
  • Automated model retraining with performance monitoring
  • Ensemble predictions combining multiple models

📊 Data Collection

  • Multi-exchange support (Bybit, Coinbase Pro, Yahoo Finance)
  • Real-time WebSocket data feeds
  • Historical data collection and storage
  • Technical indicators (RSI, MACD, Bollinger Bands, etc.)
  • Volume and momentum analysis

🛡️ Risk Management

  • Advanced risk metrics (VaR, Sharpe ratio, drawdown)
  • Position sizing using Kelly Criterion
  • Stop-loss and take-profit automation
  • Portfolio exposure limits
  • Correlation and concentration risk monitoring
  • Emergency stop functionality

📱 Notifications

  • Telegram bot integration
  • Email alerts
  • SMS notifications (Twilio)
  • Webhook support
  • Rate limiting and smart filtering

📈 Dashboard

  • Real-time monitoring with Streamlit
  • Portfolio visualization and performance tracking
  • ML model performance metrics
  • Risk monitoring and alerts
  • Trade history and analysis

🛠️ Installation

Prerequisites

  • Ubuntu 24.04 VPS
  • Python 3.11+
  • 2GB+ RAM
  • 20GB+ SSD storage

Quick Setup (Automated)

Option 1: Complete Automated Setup

# Run the complete setup script (recommended)
./setup_bybit_bot.sh

Option 2: Manual Setup

  1. Upload the bot to your VPS:
# On your local machine
./upload_to_vps.sh
  1. SSH into your VPS:
ssh root@75.119.149.117
  1. Run the deployment script:
cd /home/root/trading-bot
./deploy.sh
  1. Configure your Bybit API keys:
nano .env
# Add your Bybit API keys and notification settings
  1. Start the bot:
sudo systemctl start trading-bot
  1. Access the dashboard: Open your browser and go to: http://75.119.149.117:8501

⚙️ Configuration

Environment Variables (.env file)

# Bot Configuration
BOT_NAME=ProfessionalTradingBot
VERSION=1.0.0
TRADING_ENABLED=true

# Exchange APIs
BYBIT_API_KEY=your_bybit_api_key
BYBIT_SECRET_KEY=your_bybit_secret_key
BYBIT_SANDBOX=false

COINBASE_API_KEY=your_coinbase_api_key
COINBASE_SECRET_KEY=your_coinbase_secret_key
COINBASE_PASSPHRASE=your_passphrase

# Trading Parameters
INITIAL_CAPITAL=10000
MAX_POSITION_SIZE=0.1
MAX_POSITIONS=10
STOP_LOSS_PCT=0.05
TAKE_PROFIT_PCT=0.1
MIN_CONFIDENCE=0.7

# Risk Management
MAX_TOTAL_EXPOSURE=0.8
MAX_DRAWDOWN=0.15
MAX_VAR=0.05
MAX_CORRELATION=0.7
MAX_CONCENTRATION=0.3

# ML Configuration
MODEL_RETRAIN_HOURS=24
LOOKBACK_PERIOD=1000
FEATURE_WINDOW=50
PREDICTION_HORIZON=5

# Notifications
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_telegram_chat_id

EMAIL_SMTP_SERVER=smtp.gmail.com
EMAIL_PORT=587
EMAIL_USER=your_email@gmail.com
EMAIL_PASSWORD=your_email_password

TWILIO_ACCOUNT_SID=your_twilio_account_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_FROM_NUMBER=+1234567890
TWILIO_TO_NUMBER=+1234567890

# Dashboard
DASHBOARD_PORT=8501
DASHBOARD_HOST=0.0.0.0

# Logging
LOG_LEVEL=INFO

🎯 Usage

Starting the Bot

# Start the trading bot service
sudo systemctl start trading-bot

# Check status
sudo systemctl status trading-bot

# View logs
journalctl -u trading-bot -f

Dashboard Access

  • URL: http://75.119.149.117:8501
  • Features: Real-time monitoring, portfolio tracking, risk metrics
  • Controls: Start/stop bot, view trades, monitor performance

Manual Controls

# Start bot manually
cd /home/user/trading-bot
source venv/bin/activate
python main.py

# Start dashboard only
./start_dashboard.sh

# Monitor system
./monitor.sh

📊 Monitoring

Bot Status

# Check if bot is running
sudo systemctl status trading-bot

# View recent logs
journalctl -u trading-bot --since "1 hour ago"

# Monitor system resources
./monitor.sh

Performance Metrics

  • Win Rate: Percentage of profitable trades
  • Sharpe Ratio: Risk-adjusted returns
  • Maximum Drawdown: Largest peak-to-trough decline
  • Value at Risk (VaR): Potential loss at 95% confidence
  • Total Return: Overall portfolio performance

🛡️ Security

API Key Security

  • Store API keys in .env file (never commit to git)
  • Use read-only keys when possible
  • Enable IP whitelisting on exchanges
  • Regularly rotate API keys

VPS Security

  • Keep system updated: sudo apt update && sudo apt upgrade
  • Configure firewall: sudo ufw enable
  • Use SSH keys instead of passwords
  • Monitor system logs regularly

Trading Safety

  • Start with small amounts in simulation mode
  • Set conservative risk limits
  • Monitor drawdown closely
  • Use stop-losses on all positions

🔧 Troubleshooting

Common Issues

  1. Bot won't start:
# Check logs
journalctl -u trading-bot -f

# Check Python environment
cd /home/user/trading-bot
source venv/bin/activate
python -c "import ccxt; print('CCXT OK')"
  1. No data collection:
# Check exchange connections
python -c "
import ccxt
exchange = ccxt.bybit()
print(exchange.fetch_ticker('BTC/USDT'))
"
  1. Dashboard not accessible:
# Check if port is open
sudo ufw status
sudo ufw allow 8501

# Check if dashboard is running
ps aux | grep streamlit
  1. High memory usage:
# Check memory usage
free -h
ps aux --sort=-%mem | head

# Restart bot if needed
sudo systemctl restart trading-bot

📈 Performance Optimization

VPS Optimization

# Increase file descriptor limits
echo "* soft nofile 65536" >> /etc/security/limits.conf
echo "* hard nofile 65536" >> /etc/security/limits.conf

# Optimize system settings
echo "vm.swappiness=10" >> /etc/sysctl.conf
echo "vm.vfs_cache_pressure=50" >> /etc/sysctl.conf

Bot Optimization

  • Reduce update intervals for faster response
  • Limit historical data to essential periods
  • Use feature selection to reduce model complexity
  • Optimize database queries with proper indexing

📞 Support

Getting Help

  1. Check the logs: journalctl -u trading-bot -f
  2. Review configuration in .env file
  3. Test individual components
  4. Monitor system resources

Useful Commands

# Restart bot
sudo systemctl restart trading-bot

# View full logs
journalctl -u trading-bot --no-pager

# Check disk space
df -h

# Check memory usage
free -h

# Monitor processes
htop

⚠️ Disclaimer

This trading bot is for educational and research purposes. Cryptocurrency trading involves significant risk of loss. Always:

  • Start with small amounts
  • Test thoroughly in simulation mode
  • Monitor performance closely
  • Set appropriate risk limits
  • Never invest more than you can afford to lose

The developers are not responsible for any financial losses incurred through the use of this software.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


Happy Trading! 🚀📈

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •