A small CLI-based Python application that places MARKET and LIMIT orders on Binance Futures Testnet (USDT-M).
The project focuses on clean structure, input validation, logging, and error handling.
- Place MARKET and LIMIT orders
- Supports BUY and SELL
- CLI input validation
- Structured logging of requests, responses, and errors
- Separation of client, validation, order logic, and CLI layers
trading_bot/
│
├── bot/
│ ├── init.py
│ ├── client.py
│ ├── orders.py
│ ├── validators.py
│ └── logging_config.py
│
├── cli.py
├── requirements.txt
├── logs/
└── README.md
- Python 3.9+
- Binance Futures Testnet account
https://testnet.binancefuture.com
Create API keys from Futures Testnet API management.
Clone repository:
git clone https://github.com/Vivek-DK/trading_bot.git
cd trading_botCreate virtual environment:
Linux / macOS:
python -m venv venv
source venv/bin/activateWindows:
python -m venv venv
venv\Scripts\activateInstall dependencies:
pip install -r requirements.txtCreate .env file in project root:
BINANCE_API_KEY="your_testnet_key"
BINANCE_API_SECRET="your_testnet_secret" Minimum position value must be above exchange requirement (~100 USDT).
python cli.py --symbol BTCUSDT --side BUY --type MARKET --quantity 0.002Example far price so order stays open:
python cli.py --symbol BTCUSDT --side SELL --type LIMIT --quantity 0.001 --price 100000python cli.py --symbol BTCUSDT --side BUY --type LIMIT --quantity 0.001Logs are written to:
logs/bot.logLog includes:
order intent
API request payload
API response
validation and runtime errors
order result summary
INFO Market order -> BTCUSDT BUY 0.002
DEBUG API REQUEST futures_create_order -> {...}
DEBUG API RESPONSE futures_create_order -> {...}
INFO Order result -> id=... status=...# Binance Futures Testnet keys are used
# Minimum order size rules enforced by exchange
# LIMIT order may remain NEW if price is far from marketrm -f logs/bot.log
python cli.py --symbol BTCUSDT --side BUY --type MARKET --quantity 0.002
python cli.py --symbol BTCUSDT --side SELL --type LIMIT --quantity 0.001 --price 100000Check logs:
cat logs/bot.logpip install -r requirements.txtVivek D K
Frontend Developer