A CLI trading bot for placing MARKET and LIMIT orders on Binance Futures Testnet (USDT-M).
- Python 3.11+
- uv installed
- A Binance Futures Testnet account with API credentials
git clone cd trading_bot
uv sync
cp .env.example .env
BINANCE_TESTNET_API_KEY=your_testnet_API_Key BINANCE_TESTNET_SECRET_KEY=your_Testnet_Secret_Key BINANCE_TESTNET_BASE_URL=https://testnet.binancefuture.com
source .venv/bin/activate # macOS/Linux
uv run python cli.py order --symbol BTCUSDT --side BUY --type MARKET --quantity 0.01
uv run python cli.py order --symbol BTCUSDT --side SELL --type LIMIT --quantity 0.01 --price 95000
uv run python cli.py order --help
trade order --symbol ETHUSDT --side BUY --type MARKET --quantity 0.1
uv run python cli.py order -s BTCUSDT --side BUY -t MARKET -q 0.01
uv run python cli.py order --symbol BTCUSDT --side BUY --type MARKET --quantity 0.04
uv run python cli.py order -s BTCUSDT --side SELL -t LIMIT -q 0.01 -p 95000
uv run python cli.py order -s BTCUSDT --side SELL -t STOP_MARKET -q 0.01 --stop-price 90000
uv run python cli.py interactive
All API activity is logged to logs/trading_bot.log. This includes:
- Full request parameters (excluding signature)
- Full response bodies
- All errors with stack traces
- The Binance Futures Testnet API is used exclusively (no real funds)
- Quantity precision must match the symbol's LOT_SIZE filter (e.g., 0.001 for BTCUSDT)
- LIMIT orders use GTC (Good Till Cancelled) time-in-force by default
- The user has already funded their testnet account via the testnet faucet
trading_bot/ ├── bot/ │ ├── client.py # HTTP client with HMAC signing │ ├── orders.py # Order placement logic │ ├── validators.py # Input validation │ └── logging_config.py # Rotating file + console logging ├── cli.py # CLI entry point (Typer + Rich) ├── logs/ # Generated at runtime ├── .env.example # Credential template ├── pyproject.toml # Dependencies └── README.md