This project is a CLI-based Python application that places BUY/SELL futures orders (MARKET and LIMIT) on Binance USDT-M Futures Testnet.
The goal of the project is to demonstrate:
- Correct usage of Binance Futures Testnet APIs
- Clean CLI design
- Proper input validation
- Robust logging and error handling
- Production-style project structure
This bot is intentionally simple and does not include any trading strategy, indicators, or automation loop.
- Futures trading only (USDT-M)
- Order types supported:
- MARKET
- LIMIT
- Order sides:
- BUY
- SELL
- CLI-based input using Typer
- Input validation before API calls
- File-based rotating logs
- Clear, readable console output
- Python 3.12
- python-binance
- typer
- python-dotenv
- logging (standard library)
- Python 3.9+ (tested on Python 3.12)
- Binance Futures Testnet account
- Binance Futures Testnet API Key & Secret
git clone <your-repo-url>
cd CryptoTradingBotpython -m venv venv
source venv/bin/activate # Linux / macOS
# OR
venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the project root:
BINANCE_API_KEY=your_testnet_api_key
BINANCE_API_SECRET=your_testnet_secret_key
⚠️ Never commit your.envfile. Use.env.examplefor reference.
- Go to Binance Futures Testnet
- Create / login to your testnet account
- Generate Futures API Key and Secret
- Enable Futures permissions
python cli.py --helppython cli.py \
--symbol BTCUSDT \
--side BUY \
--order-type MARKET \
--quantity 0.002Expected output:
Order placed successfully
Order ID: <id>
Status: FILLED
Executed Qty: 0.002
Avg Price: <price>
python cli.py \
--symbol BTCUSDT \
--side BUY \
--order-type LIMIT \
--quantity 0.002 \
--price 30000Expected output:
Order placed successfully
Order ID: <id>
Status: NEW
Executed Qty: 0
Avg Price: N/A
- Logs are written to
logs/bot.log - Uses RotatingFileHandler
- Max size: ~1MB
- Keeps last 3 log files
Logged information includes:
- Order request parameters
- Order responses
- API errors
- Network errors
Sensitive data (API secrets) are never logged.
CryptoTradingBot/
│
├── services/
│ ├── client.py # Binance Futures client wrapper
│ ├── orders.py # Order placement logic
│ ├── validators.py # Input validation
│ └── logging_config.py # Logging configuration
│
├── cli.py # CLI entry point
├── requirements.txt
├── README.md
├── .env.example
└── logs/
└── logging.log
- Futures trading only (no spot trading)
- Testnet environment only
- No position management (close/cancel not implemented)
- No trading strategy or automation loop
- No leverage configuration
- Binance Futures enforces a minimum notional value (e.g. 100 USDT)
- Orders below this threshold will be rejected by Binance
- Such errors are expected and handled gracefully
This project is for educational and evaluation purposes only.