Skip to main content

A very fast downloader for Binance historical data

Project description

A very simple fast fetcher for Binance historical market data.

By using a combination of historical CSV files and API calls this tiny library can avoid rate limits and fetch data significantly faster than alternatives that fetch just from the API.

here is a benchmark for you :)

Downloaded tickers Time range HistoricalBinance Freqtrade
BTC/USDT:USDT, ETH/USDT:USDT 20230201-20240315 5.139s 5min 11.78s
BTC/USDT:USDT, ETH/USDT:USDT, OP/USDT:USDT, FET/USDT:USDT, SOL/USDT:USDT, RUNE/USDT:USDT 20230201-20240315 9.68s 14min 28.22s

Usage

The library includes two classes - BinanceDataDownloader and BinanceDataDownloader

BinanceDataDownloader is a very simple class that just fetches the available tickers to download and upon requesting the download_one_ticker(ticker, start_date, end_date, timeframe) function will return a polars dataframe requested. If necessary it can be easily converted to pandas.

 downloader = BinanceDataDownloader()
 data = await downloader.download_one_ticker("BTCUSDT", datetime(2020, 1, 1), datetime(2024, 3, 10), "1d")

BinanceDataProvider is served as an example of how to effectively use the library - caching and asynchronously fetching multiple tickers.

Here is an example of how to use BinanceDataProvider:

from binance_data import BinanceDataProvider 
 
async def binance_data_provider_example(self):
    provider = BinanceDataProvider(["ETH/USDT:USDT", "BTC/USDT:USDT", "FET/USDT:USDT", "RUNE/USDT:USDT", "SOL/USDT:USDT", "OP/USDT:USDT"], ["1m"])
    await provider.update_tickers_async(["ETH/USDT:USDT", "BTC/USDT:USDT", "FET/USDT:USDT", "RUNE/USDT:USDT", "SOL/USDT:USDT", "OP/USDT:USDT"], ["1m"], datetime(2023, 2, 1))
    print(provider.cached_dataframes["1m"]["ETHUSDT"])

This will print out a polars dataframe with columns 'date', 'open', 'high', 'low', 'close', 'volume', 'count', 'taker_buy_volume', however if you wish you can modify the code to keep the 'ignore', 'taker_buy_quote_volume' and 'quote_volume' fetched from Binance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

historical_binance-0.1.3.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

historical_binance-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file historical_binance-0.1.3.tar.gz.

File metadata

  • Download URL: historical_binance-0.1.3.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.7

File hashes

Hashes for historical_binance-0.1.3.tar.gz
Algorithm Hash digest
SHA256 556d92e4ebd57a2c10ecd9db5ec528b3c7cae12fb6cbf340c35059c0dc00e89d
MD5 19168fe02ec641d0f124c67b1f179f0e
BLAKE2b-256 77111f01a64d239d91d65fe202f926ecf696d17e723f5a31e65523af1564f582

See more details on using hashes here.

File details

Details for the file historical_binance-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for historical_binance-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1410f527c32a159cdafbdfa6ece1eaf9d0142d32e5b2d14a3ee87382766ba89f
MD5 d0547180d2bfbf5a8dcd14538a940e4f
BLAKE2b-256 c95f7234daa74b4ddedfcc6d9414886c8b3ec1e77906af1d2ded76eeccf646bd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page