Skip to content

varshithkumar55/trading_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Binance Futures Testnet Trading Bot

Overview

This project is a Python-based trading bot that interacts with the Binance Futures Testnet (USDT-M). It supports placing both MARKET and LIMIT orders through a command-line interface (CLI) while providing validation, logging, and error handling.

Features

  • Place MARKET orders
  • Place LIMIT orders
  • Support BUY and SELL sides
  • Command-line interface using argparse
  • Input validation
  • Structured project architecture
  • Logging of requests, responses, and errors
  • Exception handling
  • Binance Futures Testnet integration

Project Structure

trading_bot/
│
├── .env
├── .gitignore
├── README.md
├── requirements.txt
│
├── bot/
│   ├── __init__.py
│   ├── client.py
│   ├── cli.py
│   ├── logging_config.py
│   ├── orders.py
│   └── validators.py
│
└── logs/

Installation

  1. Clone the repository:
git clone <repository-url>
cd trading_bot
  1. Install dependencies:
pip install -r requirements.txt
  1. Create a .env file:
API_KEY=your_api_key
API_SECRET=your_api_secret

Usage

MARKET Order

python -m bot.cli --symbol BTCUSDT --side BUY --type MARKET --quantity 0.001

LIMIT Order

python -m bot.cli --symbol BTCUSDT --side BUY --type LIMIT --quantity 0.001 --price 50000

Logging

Logs are stored in:

logs/trading_bot.log

The log file contains:

  • Order requests
  • Order responses
  • Errors and exceptions

Assumptions

  • User has a Binance Futures Testnet account.
  • Valid API credentials are configured in .env.
  • Internet access is available.
  • Symbols provided are valid Binance Futures symbols.

Dependencies

  • python-binance
  • python-dotenv

Sample Log Output

MARKET Order

2026-06-01 22:46:31,936 - INFO - MARKET ORDER REQUEST | Symbol=BTCUSDT, Side=BUY, Qty=0.001

2026-06-01 22:46:32,383 - INFO - MARKET ORDER RESPONSE | {'orderId': 13714957968, 'symbol': 'BTCUSDT', 'status': 'NEW'}

LIMIT Order

2026-06-01 22:47:31,527 - INFO - LIMIT ORDER REQUEST | Symbol=BTCUSDT, Side=BUY, Qty=0.001, Price=50000.0

2026-06-01 22:47:31,916 - INFO - LIMIT ORDER RESPONSE | {'orderId': 13715029082, 'symbol': 'BTCUSDT', 'status': 'NEW'}

These examples demonstrate successful logging of order requests and responses.

About

Binance Futures Testnet Trading Bot built with Python. Supports MARKET and LIMIT orders, CLI-based input, logging, validation, and error handling.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages