Skip to content

Kenta00710/BinanceVolumeTrader-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance Volume Trader Bot

A high-performance real-time trading bot that monitors Binance futures markets for volume imbalances and records price movements.

Features

  • Real-time WebSocket streaming from Binance futures markets
  • 100ms time window aggregation for ultra-short-term analysis
  • Volume skew detection to identify buying/selling pressure
  • Forward price measurement at multiple time horizons (50ms, 100ms, 250ms, 500ms)
  • CSV data recording with automatic file rotation
  • Prometheus metrics for monitoring
  • Health check endpoints for service monitoring
  • Automatic reconnection with exponential backoff
  • Server time synchronization with Binance

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure the bot by editing config/config.yaml

  2. Run the bot:

python -m src.main --config config/config.yaml

Usage

Command Line Options

python -m src.main [OPTIONS]

Options:
  -c, --config PATH        Configuration file path [default: config/config.yaml]
  -l, --log-level LEVEL    Logging level (DEBUG/INFO/WARNING/ERROR) [default: INFO]
  -f, --log-format FORMAT  Log format (json/console) [default: console]
  --dry-run               Run without writing output files
  --help                  Show this message and exit

Configuration

Edit config/config.yaml to configure:

  • Symbols: Trading pairs to monitor (e.g., BTCUSDT, ETHUSDT)
  • Trigger conditions: Volume thresholds and skew ratios
  • Time windows: Aggregation window size and horizons
  • Storage: Output directory and file rotation settings

Output Data

The bot writes CSV files to data/records/ with the following columns:

  • Timestamp and symbol information
  • Volume data (buy/sell quantities and counts)
  • Skew indicators (dominant side, skew ratio)
  • Price data (baseline, min, max, first, last)
  • Forward price changes at each horizon
  • Metadata (measure type, latency)

Monitoring

Prometheus Metrics

Access metrics at http://localhost:9108/metrics

Key metrics include:

  • Event processing rates
  • Trigger detection counts
  • Processing latency histograms
  • Connection status
  • Queue utilization

Health Check

Access health status at http://localhost:9109/health

The health check monitors:

  • WebSocket connection status
  • Processing performance
  • Queue utilization
  • Event rates

Architecture

The bot consists of several modules:

  • WebSocket Manager: Handles Binance stream connections
  • Window Aggregator: Aggregates trades into 100ms windows
  • Trigger Detector: Identifies volume imbalance conditions
  • Price Measurement: Tracks prices at future time points
  • Data Recorder: Writes trigger events to CSV files
  • Metrics Collector: Exposes Prometheus metrics
  • Health Check: Provides service health endpoints

Development

Running Tests

pytest tests/

Code Formatting

black src/
flake8 src/

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors