npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

binance-historical-data

v1.1.0

Published

Download historical trading data from Binance in .csv format

Downloads

161

Readme

Binance Historical Data Collector

A CLI utility to easily download large amounts of historical trading data from Binance. Each file is verified with the checksum.

Why

Binance offers two methods to access the historical data: through their API in JSON format or this webpage in CSV format. It's impossible to quickly get historical data for data types like trades and aggTrades with the first method, and it would still require some manual labor to fetch a lot of files with the second method.

This library allows to collect data in CSV format for any date range, any number of symbols and intervals (if present) with a single command.

Installation

Install globally:

npm i -g binance-historical-data

Run:

binance-fetch --help

Or install locally:

npm i binance-historical-data

And run:

npx binance-fetch --help

Usage

Trading data params

Download daily klines data for spot market:

binance-fetch -d 2020-01-01 -p spot -t klines -s btcusdt -i 1h

YYYY-MM-DD date format is used for daily data. Use YYYY-MM for monthly data.

To get data for a range of dates, provide two date strings separated by a space. Multiple symbols and intervals can also be provided separated by a space.

binance-fetch -d 2021-01 2023-12 -p spot -t klines -s btcusdt ethusdt -i 1s 1m 3m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1mo

This command downloads monthly data for two symbols and all intervals from 2021-01 to 2023-12 (3 years), which will result in 1152 downloaded files.

Possible values

product
  • spot
  • usd-m
  • coin-m
  • option
data-type (spot)
  • klines
  • aggTrades
  • trades
data-type (usd-m/coin-m monthly)
  • aggTrades
  • bookTicker
  • fundingRate
  • indexPriceKlines
  • klines
  • markPriceKlines
  • premiumIndexKlines
  • trades
data-type (usd-m/coin-m daily)
  • aggTrades
  • bookDepth
  • bookTicker
  • indexPriceKlines
  • klines
  • liquidationSnapshot
  • markPriceKlines
  • metrics
  • premiumIndexKlines
  • trades
data-type (option)
  • BVOLIndex
  • EOHSummary
interval

For all the intervals see example above.

Output directory

By default the data is saved in the current directory. Pass -o or --output followed by a relative or absolute path to change that.

Data is loaded with a stream. Until the file is fully downloaded and verified, it will look like this: <symbol>...UNVERIFIED.zip.

Concurrency

By default 5 files are downloaded at a time. Use -P to change the number (pass -P 1 to download each file sequentially).

Debug

If you get (no data) for a file, it's likely that Binance does not have the data for the chosen market/data-type/date/symbol/interval. You can verify what data is available here. Product usd-m corresponds to futures/um, coin-m corresponds to futures/cm.

License

MIT