This project is a Python-based trading bot that interacts with the Binance Futures Testnet (USDT-M). It supports placing both MARKET and LIMIT orders through a command-line interface (CLI) while providing validation, logging, and error handling.
- Place MARKET orders
- Place LIMIT orders
- Support BUY and SELL sides
- Command-line interface using argparse
- Input validation
- Structured project architecture
- Logging of requests, responses, and errors
- Exception handling
- Binance Futures Testnet integration
trading_bot/
│
├── .env
├── .gitignore
├── README.md
├── requirements.txt
│
├── bot/
│ ├── __init__.py
│ ├── client.py
│ ├── cli.py
│ ├── logging_config.py
│ ├── orders.py
│ └── validators.py
│
└── logs/
- Clone the repository:
git clone <repository-url>
cd trading_bot- Install dependencies:
pip install -r requirements.txt- Create a
.envfile:
API_KEY=your_api_key
API_SECRET=your_api_secretpython -m bot.cli --symbol BTCUSDT --side BUY --type MARKET --quantity 0.001python -m bot.cli --symbol BTCUSDT --side BUY --type LIMIT --quantity 0.001 --price 50000Logs are stored in:
logs/trading_bot.log
The log file contains:
- Order requests
- Order responses
- Errors and exceptions
- User has a Binance Futures Testnet account.
- Valid API credentials are configured in
.env. - Internet access is available.
- Symbols provided are valid Binance Futures symbols.
- python-binance
- python-dotenv
2026-06-01 22:46:31,936 - INFO - MARKET ORDER REQUEST | Symbol=BTCUSDT, Side=BUY, Qty=0.001
2026-06-01 22:46:32,383 - INFO - MARKET ORDER RESPONSE | {'orderId': 13714957968, 'symbol': 'BTCUSDT', 'status': 'NEW'}
2026-06-01 22:47:31,527 - INFO - LIMIT ORDER REQUEST | Symbol=BTCUSDT, Side=BUY, Qty=0.001, Price=50000.0
2026-06-01 22:47:31,916 - INFO - LIMIT ORDER RESPONSE | {'orderId': 13715029082, 'symbol': 'BTCUSDT', 'status': 'NEW'}
These examples demonstrate successful logging of order requests and responses.