A structured Python application to interact with the Binance Futures Testnet (USDT-M). This project was built as part of the Python Developer Intern assessment for Primetrade.ai.
- Core Trading: Place MARKET and LIMIT orders for any USDT-M pair.
- Validation: Strict input validation for symbols, quantities, and prices before API calls.
- Logging: Full audit trail of API requests, responses, and errors saved to
trading_bot.log. - Dual Interface:
- CLI: Professional command-line interface using
argparse. - UI: Interactive web dashboard built with Streamlit.
- CLI: Professional command-line interface using
- Clone the Repository:
git clone https://github.com/Atharv012/TradingBot.git cd trading_bot - Environment Setup:
Create a virtual environment and install dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt
- API Credentials: Create a .env file and place the API_KEY and API_SECRET there for running the bot via cli or enter them directly in the Streamlit sidebar. Ensure you are using Binance Futures Testnet keys.
Market Order:
python cli.py --symbol BTCUSDT --side BUY --type MARKET --qty 0.001
Limit Order:
python cli.py --symbol BTCUSDT --side SELL --type LIMIT --qty 0.001 --price 75000
streamlit run UI.py
Lot Size: The bot assumes the user provides a quantity that meets the symbol's minimum lot size requirements on the Binance Testnet (e.g., 0.001 for BTC).
Testnet: The application is hardcoded to use the Binance Futures Testnet environment for safety.
Logging: Request logs are used for API requests and responses to ensure high readability and traceability.
-
bot/client.py: Handles connection and authentication.
-
bot/orders.py: Core logic for order placement and response handling.
-
bot/validators.py: Input scrubbing and error prevention.
-
bot/logging_config.py: Centralized logging configuration.
-
cli.py: The main entry point for command-line usage.
-
UI.py: The web UI wrapper.