A Python Terminal UI (TUI) trading bot for Binance Futures Testnet that allows you to place and manage futures orders with an interactive interface.
- Beautiful Terminal UI: Interactive terminal interface built with Textual
- Multiple Order Types: Support for MARKET, LIMIT, and STOP_LIMIT orders
- Real-time Feedback: Instant order validation and execution results
- Order History Log: Live order history and status updates in the interface
- Futures Trading: USDT-margined futures contracts on Binance testnet
- Input Validation: Robust parameter validation for symbols, quantities, and prices
- Logging: Comprehensive logging for debugging and monitoring
- Testnet Ready: Configured for Binance Futures Testnet environment
The TUI features:
- Split-panel layout with order form on the left and order log on the right
- Dropdown menus for side and order type selection
- Real-time input validation
- Color-coded success/error messages
- Keyboard shortcuts for quick navigation
- Python 3.12
- Binance Futures Testnet API credentials
- Clone the repository:
git clone <repository-url>
cd Milo- Create a virtual environment:
python -m venv .venv
source .venv/bin/activate # On Linux/Mac
# or
.venv\Scripts\activate # On Windows- Install dependencies:
pip install -e .- Create a
.envfile in the project root:
BINANCE_API_KEY=your_testnet_api_key
BINANCE_API_SECRET=your_testnet_api_secret- Visit Binance Futures Testnet
- Log in or create an account
- Generate API keys from the account settings
- Add the keys to your
.envfile
Launch the interactive terminal interface:
python main.py-
Fill in the Order Form (left panel):
- Enter the trading symbol (e.g., BTCUSDT)
- Select the side (BUY or SELL) from the dropdown
- Choose order type (MARKET, LIMIT, or STOP_LIMIT)
- Enter the quantity
- For LIMIT/STOP_LIMIT orders, enter the price
- For STOP_LIMIT orders, enter the stop price
-
Submit the Order:
- Click "Place Order" button or press Enter
- View the results in the Order History panel (right side)
-
Keyboard Shortcuts:
q- Quit the applicationc- Clear the formTab- Navigate between fieldsEnter- Submit when focused on a button
- Symbol:
BTCUSDT - Side:
BUY - Order Type:
MARKET - Quantity:
0.01 - Click "Place Order"
- Symbol:
BTCUSDT - Side:
SELL - Order Type:
LIMIT - Quantity:
0.01 - Price:
30000 - Click "Place Order"
- Symbol:
BTCUSDT - Side:
BUY - Order Type:
STOP_LIMIT - Quantity:
0.01 - Price:
31000 - Stop Price:
30500 - Click "Place Order"
Milo/
├── bot/
│ ├── __init__.py
│ ├── client.py # Binance API client wrapper
│ ├── orders.py # Order placement logic
│ └── logging_config.py # Logging configuration
├── tui/
│ ├── __init__.py
│ └── app.py # Textual TUI application
├── cli/ # Legacy CLI (kept for reference)
│ ├── cmd.py
│ └── validate.py
├── logs/
│ └── bot.log # Application logs
├── main.py # Application entry point
├── pyproject.toml # Project dependencies
├── .env # API credentials (not in repo)
└── README.md # This file
All operations are logged to logs/bot.log with the following information:
- Order placement attempts
- API requests and responses
- Errors and exceptions
View logs in real-time:
tail -f logs/bot.log- Update the order type dropdown in
tui/app.pyin theOrderFormclass - Add validation logic in the
place_ordermethod ofMiloTUIclass - Update order logic in
bot/client.pyin theplace_ordermethod - Update this README with usage examples
The TUI appearance can be customized by modifying the CSS in tui/app.py:
- Colors and themes
- Layout and spacing
- Widget styles
- Border styles
# Run the TUI
python main.py
# View logs in another terminal
tail -f logs/bot.log- Empty API Responses: The Binance Futures Testnet sometimes returns empty order responses (
{}), even when orders are successfully placed. This is a limitation of the testnet environment, not a bug in the code. - Testnet Stability: The testnet may have different behavior compared to production.
- Testnet Only: This bot is configured for testnet only. Do not use with production API keys.
- No Real Money: All trades on testnet use fake funds.
- API Security: Never commit your
.envfile or expose your API keys. - Limitations: Testnet may have limited liquidity and different order book behavior.
- Terminal Requirements: Works best in modern terminals with good Unicode support.
Ensure your .env file exists and contains valid testnet API credentials.
You're using mainnet API keys with testnet. Get proper testnet keys from https://testnet.binancefuture.com
This is normal for testnet. Check the logs to confirm the order was sent successfully. Verify orders in the testnet web interface.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is for educational purposes.
This software is for educational and testing purposes only. Cryptocurrency trading carries significant risk. Always practice with testnet before considering real trading. The authors are not responsible for any financial losses.