This is a simple, open-source automated trading bot for Bitcoin (BTC), created as a project by a Computer Science major. The bot is designed to execute trades on the Binance exchange based on various technical analysis indicators.
- Connects to Binance API for live trading or paper trading (testnet).
- Implements a configurable trading strategy using indicators such as SMA, RSI, MACD, and Bollinger Bands.
- Manages trades with risk control measures like stop-loss and trailing stop.
- Logs and displays trade execution details and profit tracking.
- Python 3.8 or higher
- Binance account (for live trading)
- Download and install Python from the official Python website.
- Clone the repository:
git clone https://github.com/yourusername/trading-bot.git cd trading-bot
- Install the required Python packages:
pip install -r requirements.txt
- Install Python using Homebrew:
brew install python
- Clone the repository:
git clone https://github.com/yourusername/trading-bot.git cd trading-bot
- Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
- Install the required Python packages:
pip install -r requirements.txt
- Install Python:
sudo apt update sudo apt install python3 python3-venv python3-pip
- Clone the repository:
git clone https://github.com/yourusername/trading-bot.git cd trading-bot
- Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
- Install the required Python packages:
pip install -r requirements.txt
The bot requires a .env
file for configuration, which includes API keys and trading settings. Here is an example of how to set up your .env
file:
# Environment setting
ENVIRONMENT=paper
# Live environment API keys
LIVE_API_KEY=your_binance_api_key
LIVE_API_SECRET=your_binance_api_secret
# Paper environment API keys
PAPER_API_KEY=your_testnet_api_key
PAPER_API_SECRET=your_testnet_api_secret
# Trading symbol
TRADING_SYMBOL=BTCUSDT
- ENVIRONMENT: Set this to
paper
for testnet (paper trading) orlive
for real trading. - LIVE_API_KEY / LIVE_API_SECRET: Your Binance API key and secret for live trading.
- PAPER_API_KEY / PAPER_API_SECRET: Your Binance API key and secret for paper trading (testnet).
- TRADING_SYMBOL: The trading pair symbol, e.g.,
BTCUSDT
.
- Rename
.env.example
to.env
. - Replace
your_binance_api_key
andyour_binance_api_secret
with your actual Binance API credentials.
To start the trading bot, simply run the following command:
cd src/
python main.py
The bot will begin fetching market data, applying the trading strategy, and executing trades based on the signals generated.
This is an open-source project, and contributions are welcome! Please open issues or pull requests with any suggestions or improvements.
The current trading strategy uses a combination of Simple Moving Averages (SMA), Relative Strength Index (RSI), Moving Average Convergence Divergence (MACD), and Bollinger Bands. We are particularly interested in feedback on the following:
- Risk Management: Are there better ways to implement risk management to avoid significant losses?
- Technical Indicators: Are there more effective indicators or configurations to improve trade accuracy?
- Optimization: How can we optimize the execution of trades to reduce slippage and fees?
Feel free to reach out via GitHub issues or contribute directly through pull requests.