A comprehensive Python trading bot for Binance Futures Testnet with both CLI and web interfaces.
- Market Orders: Instant buy/sell at current market price
- Limit Orders: Buy/sell at specific price levels
- Stop-Market Orders: Stop-loss and take-profit orders
- TWAP Orders: Time-Weighted Average Price execution
- WebSocket Integration: Live order updates and market data
- User Data Stream: Real-time account and order status updates
- Market Data Stream: Live price feeds and ticker updates
- CLI Interface: Command-line trading with full argument support
- Web UI: Streamlit-based dashboard for user-friendly trading
- Comprehensive Logging: All API calls and responses logged
- Precision Validation: Automatic price/quantity rounding per exchange rules
- Exchange Filters: Respects min/max quantities and tick sizes
- Error Handling: Robust error handling and recovery
- Testnet Environment: Safe testing with no real money
- Install Python Dependencies:
pip install -r requirements.txt- Get Binance Testnet API Keys:
- Go to Binance Testnet
- Create account and generate API keys
- Note: These are testnet keys - no real money involved
# Get server time
python advanced_binance_futures_bot.py --api-key YOUR_API_KEY --secret-key YOUR_SECRET_KEY time
# Place market order
python advanced_binance_futures_bot.py --api-key YOUR_API_KEY --secret-key YOUR_SECRET_KEY market --symbol BTCUSDT --side BUY --quantity 0.001
# Place limit order
python advanced_binance_futures_bot.py --api-key YOUR_API_KEY --secret-key YOUR_SECRET_KEY limit --symbol BTCUSDT --side BUY --quantity 0.001 --price 30000
# Place stop order
python advanced_binance_futures_bot.py --api-key YOUR_API_KEY --secret-key YOUR_SECRET_KEY stop --symbol BTCUSDT --side SELL --quantity 0.001 --price 32000 --stop-price 31000
# Execute TWAP order
python advanced_binance_futures_bot.py --api-key YOUR_API_KEY --secret-key YOUR_SECRET_KEY twap --symbol BTCUSDT --side BUY --quantity 0.01 --slices 5 --interval 30Launch the Streamlit dashboard:
streamlit run bot_ui.pyThen open your browser to http://localhost:8501
- API Configuration: Secure credential input
- Order Placement: Visual interface for all order types
- TWAP Execution: Progress tracking for multi-slice orders
- Order History: Real-time display of executed orders
- Market Data: Live price feeds (when WebSocket connected)
BinanceFuturesREST: Handles all REST API operations
- HMAC SHA256 signature generation
- Automatic precision adjustment
- Exchange info caching
- Error handling and retry logic
BinanceFuturesWS: Manages WebSocket connections
- User data stream for order updates
- Market data stream for price feeds
- Automatic reconnection handling
- Thread-safe message processing
TWAPOrder: Implements time-weighted average price execution
- Intelligent order splitting
- Configurable timing intervals
- Progress tracking and reporting
- Error recovery between slices
├── advanced_binance_futures_bot.py # Main CLI application
├── bot_ui.py # Streamlit web interface
├── requirements.txt # Python dependencies
├── README.md # Documentation
└── binance_futures_bot.log # Application logs
- API Key Protection: Keys never logged or exposed
- HMAC Signature: All requests cryptographically signed
- Testnet Environment: No real funds at risk
- Input Validation: All parameters validated before submission
- Rate Limiting: Respects Binance API limits
All operations are logged to binance_futures_bot.log:
- API request/response details
- Order execution summaries
- WebSocket connection status
- Error messages and stack traces
- TWAP execution progress
- Testnet Only: This bot is configured for Binance Futures Testnet
- No Real Trading: All operations use test funds only
- API Limits: Respect Binance rate limits to avoid restrictions
- Error Handling: Always check logs for detailed error information
- Precision: Orders automatically adjusted to meet exchange requirements
This software is for educational and testing purposes only. Always test thoroughly in testnet before any real trading. The authors are not responsible for any financial losses.
For issues and questions:
- Check the logs in
binance_futures_bot.log - Verify API credentials and permissions
- Ensure stable internet connection for WebSocket streams
- Review Binance API documentation for specific error codes