Skip to content

Pantane1/binance_bot-main

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance Trading Bot - Connection & Setup Guide

A professional automated cryptocurrency trading bot that connects to Binance for strategy-based trading using real-time market data. This guide will walk you through the complete setup process.

📋 Prerequisites

Before you begin, ensure you have:

  • Python 3.8 or higher installed on your system
  • A Binance account (Sign up here)
  • Basic familiarity with command line/terminal
  • At least 2GB of free RAM for smooth operation

🔧 Step-by-Step Connection Guide

Step 1: Clone the Repository

git clone https://github.com/Pantane1/binance_bot-main.git
cd binance_bot-main

Step 2: Set Up Python Virtual Environment

# Create virtual environment
python -m venv venv

# Activate it:
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

Step 3: Install Dependencies

pip install --upgrade pip
pip install -r requirements.txt
# For optional features (machine learning, advanced analytics):
pip install -r requirements-optional.txt

Step 4: Get Your Binance API Keys

For TESTING (Recommended First):

  1. Log in to your Binance account
  2. Go to Binance Test Network
  3. Click "Register Application" to get test API keys
  4. Save your API Key and Secret Key safely

For LIVE Trading (Only after testing):

  1. Log in to Binance.com
  2. Go to API Management (Dashboard → API Management)
  3. Click "Create API"
  4. Set appropriate security restrictions:
    • ✅ Enable "Spot & Margin Trading"
    • ❌ Disable "Withdrawals" for security
    • Set IP access restrictions if possible
  5. Save your keys securely

Step 5: Configure Environment Variables

Create your .env file:

cp .env.sample .env

Edit the .env file with your preferred text editor:

# Binance API Configuration
BINANCE_API_KEY=your_api_key_here
BINANCE_SECRET_KEY=your_secret_key_here

# Trading Configuration
TRADING_SYMBOLS=BTCUSDT,ETHUSDT
QUOTE_ASSET=USDT
TIMEFRAME=1h

# Risk Management
MAX_TRADE_SIZE=0.001
STOP_LOSS_PERCENTAGE=2
TAKE_PROFIT_PERCENTAGE=4

# Logging
LOG_LEVEL=INFO
LOG_FILE=trading_bot.log

Step 6: Test Your Connection

Run the connection test:

python test_setup.py

Expected output:

✓ Binance API connection successful
✓ Account balance retrieved
✓ Market data accessible
✓ WebSocket connection established
✓ All systems ready for trading

If you see any errors, check:

  • Your API keys are correctly copied (no extra spaces)
  • Your system time is synchronized (sudo ntpdate -u pool.ntp.org on Linux)
  • Firewall isn't blocking the connection

Step 7: Configure Trading Parameters

Review and adjust these configuration files:

  1. Trading Strategy (config/strategy_config.json):
{
    "strategy": "momentum",
    "indicators": ["RSI", "MACD", "EMA"],
    "rsi_period": 14,
    "rsi_overbought": 70,
    "rsi_oversold": 30
}
  1. Risk Management (config/risk_config.json):
{
    "max_daily_trades": 10,
    "max_position_size": 0.01,
    "max_drawdown": 5,
    "cooldown_period": 300
}

Step 8: Run the Bot

Dry Run Mode (No real trades):

python main.py --dry-run

Paper Trading Mode (Simulated with real data):

python main.py --paper-trading

Live Mode (Only when ready!):

python main.py

🎯 Quick Start Checklist

  • Repository cloned successfully
  • Virtual environment created and activated
  • Dependencies installed
  • Binance testnet API keys obtained
  • .env file configured
  • Test setup passed successfully
  • Trading parameters reviewed
  • Dry run completed without errors
  • Paper trading validated

🚨 Important Safety Precautions

DO's:

✅ Always start with testnet first ✅ Begin with small amounts in paper trading ✅ Monitor the bot closely for the first 24 hours ✅ Keep your API keys secret (never commit .env to GitHub) ✅ Set up 2FA on your Binance account ✅ Use IP whitelisting for API keys

DON'Ts:

❌ Never share your secret keys ❌ Don't start with maximum trade sizes ❌ Avoid running multiple bot instances ❌ Never leave the bot unattended for long periods initially ❌ Don't ignore error messages or warnings

🔍 Troubleshooting Common Issues

Issue Solution
"API key format invalid" Regenerate API keys, ensure no spaces
"Connection timeout" Check internet, increase timeout in config
"Insufficient balance" Fund your account or reduce trade size
"Rate limit exceeded" Reduce trade frequency, add delays
"Symbol not trading" Verify symbol pair exists on Binance

📊 Monitoring Your Bot

Check logs in real-time:

tail -f trading_bot.log

View performance metrics:

python scripts/show_performance.py

Stop the bot safely:

Press Ctrl+C and wait for graceful shutdown

🔄 Updating the Bot

git pull origin main
pip install -r requirements.txt --upgrade
python scripts/migrate_config.py  # If needed

📚 Additional Resources

🆘 Getting Help

If you encounter issues:

  1. Check the troubleshooting section above
  2. Review the logs in trading_bot.log
  3. Search existing GitHub Issues
  4. Create a new issue with:
    • Your configuration (remove secrets)
    • Error messages
    • Steps to reproduce

⚠️ Disclaimer

This bot is for educational and research purposes only.

  • Cryptocurrency trading carries significant risk
  • Past performance doesn't guarantee future results
  • You are solely responsible for your trading decisions
  • Always test thoroughly before using real funds
  • Start small and scale gradually

Ready to start? Complete the checklist above and run your first test! 🚀

Happy Trading! 📈

ph-logo

pantane

About

Automated Binance cryptocurrency trading bot that executes strategy-based trades using real-time market data. Built for research, algorithmic trading experiments, and crypto automation.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors