Binance Public Data

repository·master·Indexed 25 days ago

https://github.com/binance/binance-public-data

Access aggregated historical market data for Spot and Futures in daily or monthly files. This repository provides Python and shell scripts to download kline, trade, and aggregated trade (aggTrade) data, as well as Futures-specific index, mark, and premium price klines. It supports programmatic downloads via HTTP clients and includes instructions for verifying data integrity using CHECKSUM files.

Tokens
2.6K
Snippets
6
Records
10
Agent score
32%

What's inside binance-public-data

  1. Verify data integrity using CHECKSUM files

    master

    Every .zip data file is accompanied by a .CHECKSUM file in the same directory. You should use these to verify that your downloaded data is not corrupted. Use the following commands based on your operating system:

    Linux

    sha256sum -c <FILENAME>.zip.CHECKSUM

    MacOS

    shasum -a 256 -c <FILENAME>.zip.CHECKSUM
    # Linux
    sha256sum -c BNBUSDT-1m-2021-01.zip.CHECKSUM
    
    # MacOS
    shasum -a 256 -c BNBUSDT-1m-2021-01.zip.CHECKSUM
  2. Download Futures-only price kline data

    master

    The following scripts are specifically for downloading Futures kline data (indexPrice, markPrice, or premiumPrice) for all symbols starting from 2020-01-01.

    Available Scripts:

    • download-futures-indexPriceKlines.py
    • download-futures-markPriceKlines.py
    • download-futures-premiumPriceKlines.py

    Mandatory Arguments:

    • -t: Market type. Options: um (USD-M Futures), cm (COIN-M Futures).

    Common Optional Arguments:

    • -s: Single symbol or multiple symbols separated by space.
    • -i: Single kline interval or multiple intervals separated by space.
    • -y: Single year or multiple years separated by space.
    • -m: Single month or multiple months separated by space.
    • -startDate: Starting date in [YYYY-MM-DD] format.
    • -endDate: Ending date in [YYYY-MM-DD] format.
    • -skip-monthly: Set to 1 to skip monthly data.
    • -skip-daily: Set to 1 to skip daily data.
    • -c: Set to 1 to download the checksum file.
    • -folder: Directory to store the downloaded data.
  3. Download kline data

    master

    Use download-kline.py to download monthly and daily kline data for all symbols and intervals starting from 2020-01-01.

    Mandatory Arguments:

    • -t: Market type. Options: spot, um (USD-M Futures), cm (COIN-M Futures).

    Common Optional Arguments:

    • -s: Single symbol or multiple symbols separated by space (Default: All symbols).
    • -i: Single kline interval or multiple intervals separated by space (Default: All intervals).
    • -y: Single year or multiple years separated by space.
    • -m: Single month or multiple months separated by space.
    • -startDate: Starting date in [YYYY-MM-DD] format.
    • -endDate: Ending date in [YYYY-MM-DD] format.
    • -skip-monthly: Set to 1 to skip monthly data.
    • -skip-daily: Set to 1 to skip daily data.
    • -c: Set to 1 to download the checksum file.
    • -folder: Directory to store the downloaded data.
  4. Download trade data

    master

    Use download-trade.py to download monthly and daily trade data for all symbols starting from 2020-01-01.

    Mandatory Arguments:

    • -t: Market type. Options: spot, um (USD-M Futures), cm (COIN-M Futures).

    Common Optional Arguments:

    • -s: Single symbol or multiple symbols separated by space.
    • -y: Single year or multiple years separated by space.
    • -m: Single month or multiple months separated by space.
    • -startDate: Starting date in [YYYY-MM-DD] format.
    • -endDate: Ending date in [YYYY-MM-DD] format.
    • -skip-monthly: Set to 1 to skip monthly data.
    • -skip-daily: Set to 1 to skip daily data.
    • -c: Set to 1 to download the checksum file.
    • -folder: Directory to store the downloaded data.
  5. Download aggregated trade (aggTrade) data

    master

    Use download-aggTrade.py to download monthly and daily aggregated trades data for all symbols starting from 2020-01-01.

    Mandatory Arguments:

    • -t: Market type. Options: spot, um (USD-M Futures), cm (COIN-M Futures).

    Common Optional Arguments:

    • -s: Single symbol or multiple symbols separated by space.
    • -y: Single year or multiple years separated by space.
    • -m: Single month or multiple months separated by space.
    • -startDate: Starting date in [YYYY-MM-DD] format.
    • -endDate: Ending date in [YYYY-MM-DD] format.
    • -skip-monthly: Set to 1 to skip monthly data.
    • -skip-daily: Set to 1 to skip daily data.
    • -c: Set to 1 to download the checksum file.
    • -folder: Directory to store the downloaded data.
  6. Download Binance Public Data programmatically

    master

    You can download Binance market data (Spot and Futures) using standard HTTP clients like curl or wget. Data is organized by type (e.g., klines), frequency (daily or monthly), symbol, and interval.

    Example for downloading monthly Spot 1h kline data for the symbol ADABKRW:

    # Using curl
    curl -s "https://data.binance.vision/data/spot/monthly/klines/ADABKRW/1h/ADABKRW-1h-2020-08.zip" -o ADABKRW-1h-2020-08.zip
    
    # Using wget
    wget "https://data.binance.vision/data/spot/monthly/klines/ADABKRW/1h/ADABKRW-1h-2020-08.zip"

    For bulk operations, this repository provides helper scripts in the python/ and shell/ directories. To get a list of all currently running symbols for Spot and Futures, use the shell/fetch-all-trading-pairs.sh script.

    # Examples for downloading monthly Spot 1h lines for "ADABKRW" symbol.
    curl -s "https://data.binance.vision/data/spot/monthly/klines/ADABKRW/1h/ADABKRW-1h-2020-08.zip" -o ADABKRW-1h-2020-08.zip
    wget "https://data.binance.vision/data/spot/monthly/klines/ADABKRW/1h/ADABKRW-1h-2020-08.zip"
  7. Reference: FUTURES Data formats

    master

    FUTURES data is split into USD-M and COIN-M.

    • USD-M AggTrades: Matches /fapi/v1/aggTrades.
    • USD-M Klines: Matches /fapi/v1/klines.
    • USD-M Trades: Matches /fapi/v1/trades.
    • COIN-M Klines: Matches /dapi/v1/klines.
    • COIN-M Trades: Matches /dapi/v1/trades.
    #### AggTrades
    |Aggregate tradeId|Price|Quantity|First tradeId|Last tradeId|Timestamp|Was the buyer the maker|
    | -- | -- | -- | -- | -- | -- | -- |
    |26129|0.01633102|4.70443515|27781|27781|1498793709153|true|
    
    #### Klines (USD-M)
    |Open time|Open|High|Low|Close|Volume|Close time|Quote asset volume|Number of trades|Taker buy base asset volume|Taker buy quote asset volume|Ignore|
    | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
    |1499040000000|0.01634790|0.80000000|0.01575800|0.01577100|148976.11427815|1499644799999|2434.19055334|308|1756.87402397|28.46694368|17928899.62484339|
    
    #### Klines (COIN-M)
    |Open time|Open|High|Low|Close|Volume|Close time|Base asset volume|Number of trades|Taker buy volume|Taker buy base asset volume|Ignore|
    | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
    |1591258320000|9640.7|9642.4|9640.6|9642.0|206|1591258379999|2.13660389|48|119|1.23424865|0|
    
    #### Trades (USD-M)
    |trade Id| price| qty|quoteQty|time|isBuyerMaker|
    | -- | -- | -- | -- | -- | -- |
    |28457|4.00000100|12.00000000|48.00|1499865549590|true|
    
    #### Trades (COIN-M)
    |trade Id| price| qty|baseQty|time|isBuyerMaker|
    | -- | -- | -- | -- | -- | -- |
    |28457|9635.0|1|0.01037883|1591250192508|true|
  8. Reference: SPOT Data formats

    master

    SPOT data includes AggTrades, Klines, and Trades.

    Important Note: For SPOT data from January 1st, 2025 onwards, timestamps are provided in microseconds.

    Supported Kline intervals: 1s, 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1mo. Note that 1mo is used instead of 1M for filesystem compatibility.

    #### AggTrades
    |Aggregate tradeId|Price|Quantity|First tradeId|Last tradeId|Timestamp|Was the buyer the maker|Was the trade the best price match|
    | -- | -- | -- | -- | -- | -- | -- | -- |
    |0|0.20000000|50.00000000|0|0|1735689600010866|False|True|
    
    #### Klines
    |Open time|Open|High|Low|Close|Volume|Close time|Quote asset volume|Number of trades|Taker buy base asset volume|Taker buy quote asset volume|Ignore|
    | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- |
    |1735689600000000|4.15070000|4.15870000|4.15060000|4.15540000|539.23000000|1735693199999999|2240.39860900|13|401.82000000|1669.98121300|0|
    
    #### Trades
    |trade Id| price| qty|quoteQty|time|isBuyerMaker|isBestMatch|
    | -- | -- | -- | -- | -- | -- | -- |
    |51175358|17.80180000|5.69000000|101.29224200|1735689600010866|True|True|