A Python-based CLI application to place MARKET and LIMIT orders on the Binance Futures Testnet (USDT-M).
- Place Orders: Supports MARKET and LIMIT orders for both BUY and SELL sides.
- Validation: Ensures valid symbols, positive quantities/prices, and correct order types.
- Enhanced CLI: Uses
richfor colorful and structured output. - Logging: detailed logs are saved to
trading_bot.log. - Modular Design: Separated API client, order logic, and CLI interface.
- Python 3.x
- A Binance Futures Testnet account.
- API Key and Secret from the Testnet.
- Clone/Download the repository.
- Install dependencies:
pip install -r requirements.txt
- Environment Variables (Optional but recommended):
Create a
.envfile or set them in your shell:export BINANCE_API_KEY="your_api_key" export BINANCE_API_SECRET="your_api_secret"
Run the bot from the command line using python trading_bot/cli.py.
| Argument | Type | Description | Required | Options |
|---|---|---|---|---|
--symbol |
str | Trading Pair | Yes | e.g. BTCUSDT |
--side |
str | Order Side | Yes | BUY, SELL |
--type |
str | Order Type | Yes | MARKET, LIMIT |
--quantity |
float | Amount to trade | Yes | > 0 |
--price |
float | Limit Price | No* | > 0 (*Req for LIMIT) |
--api-key |
str | API Key | No* | (*If not in env) |
--api-secret |
str | API Secret | No* | (*If not in env) |
1. Place a MARKET BUY Order:
python trading_bot/cli.py --symbol BTCUSDT --side BUY --type MARKET --quantity 0.0012. Place a LIMIT SELL Order:
python trading_bot/cli.py --symbol BTCUSDT --side SELL --type LIMIT --quantity 0.001 --price 500003. Providing Keys Inline:
python trading_bot/cli.py --symbol ETHUSDT --side BUY --type MARKET --quantity 0.01 --api-key "YOUR_KEY" --api-secret "YOUR_SECRET"You can run the bot in "Mock Mode" to test the CLI and logic without needing API keys or placing real orders.
python trading_bot/cli.py --symbol BTCUSDT --side BUY --type MARKET --quantity 0.001 --mocktrading_bot/
bot/
__init__.py
client.py # Binance Client Wrapper
orders.py # Order Logic & Validation
validators.py # Input Validators
logging_config.py# Logging Setup
cli.py # CLI Entry Point
requirements.txt
README.md
All activities are logged to trading_bot.log in the root directory.