Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Binance Data Downloader

This project provides a Python script to download historical kline (candle) data from Binance for various symbols and timeframes. It is designed for use in backtesting strategies.

Features

  • Incremental Fetching: Only downloads new data points since the last run.
  • 4-Year History: Automatically retrieves the last 4 years of data on the first run.
  • JSON Output: Saves data in a structured JSON format, perfect for JavaScript/React backtesting modules.
  • Multiple Timeframes: Supports 5m, 15m, 1h, 4h, and 1d timeframes (configurable).
  • Multiple Symbols: Supports a configurable list of USDT pairs.

Installation

  1. Clone or navigate to the project directory.
  2. Create a virtual environment:
    python3 -m venv venv
  3. Activate the virtual environment:
    • On macOS/Linux: source venv/bin/activate
    • On Windows: venv\Scripts\activate
  4. Install dependencies:
    pip install -r requirements.txt

Configuration

You can customize the symbols, timeframes, and historical depth in config.py:

SYMBOLS = ['BNBUSDT', 'BTCUSDT', 'ETHUSDT', 'XRPUSDT', 'LINKUSDT', 'ADAUSDT']
TIMEFRAMES = ['5m', '15m', '1h', '4h', '1d']
HISTORICAL_YEARS = 4

(Optional) If you hit rate limits, you can add your API_KEY and API_SECRET to config.py.

Usage

Run the main script to start syncing data:

python3 get_binance_data.py

The data will be saved in data/json/{SYMBOL}/{SYMBOL}_{TIMEFRAME}.json.

Output Format

The output JSON follows this structure:

[
  {
    "date": "2021-01-28T14:00:00+00:00",
    "timestamp": 1611842400000,
    "open": 32145.5,
    "high": 32500.0,
    "low": 32000.0,
    "close": 32300.2,
    "volume": 120.5
  },
  ...
]

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages