binance_historical_data
Short Overview.
binance_historical_data is a python package (py>=3.8) which makes download of historical crypto data (prices and volumes) from binance server as simple as it can only be. You don’t even need to have an account at binance.com to download all history of crypto data
Installation via pip:
pip install binance_historical_data
How to use it
Initialize main object: data_dumper
from binance_historical_data import BinanceDataDumper
data_dumper = BinanceDataDumper(
path_dir_where_to_dump=".",
asset_class="spot", # spot, um, cm
data_type="klines", # aggTrades, klines, trades
data_frequency="1m",
)
Arguments:
- path_dir_where_to_dump:
- (string) Path to folder where to dump the data
- asset_class:
- (string) Source of data: [spot, um, cm] um: usd(t) margined futures, cm: coin margined futures
- data_type=”klines”:
- (string) data type to dump:[aggTrades, klines, trades] for spot[aggTrades, klines, trades, indexPriceKlines, markPriceKlines, premiumIndexKlines, metrics] for futures (metrics only supported for um)Refer to binance doc for additional info: https://github.com/binance/binance-public-data
- str_data_frequency:
- (string) One of [1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h]Frequency of price-volume data candles to get
1) The only method to dump the data
data_dumper.dump_data(
tickers=None,
date_start=None,
date_end=None,
is_to_update_existing=False,
tickers_to_exclude=["UST"],
)
Arguments:
- tickers=None:
- (list) Trading pairs for which to dump dataif equals to None - all USDT pairs will be used
- date_start=None:
- (datetime.date) The date from which to start dumpif equals to None - every trading pair will be dumped from the early begining (the earliest is 2017-01-01)
- date_end=True=None:
- (datetime.date) The last date for which to dump dataif equals to None - Today’s date will be used
- is_to_update_existing=False:
- (bool) Flag if you want to update the data if it’s already exist
- tickers_to_exclude=None:
- (list) Tickers to exclude from dump
2) Delete outdated daily results
Delete all daily data for which full month monthly data was already dumped
data_dumper.delete_outdated_daily_results()
.csv klines (candles) files columns
Examples
How to dump all data for all USDT trading pairs
Please be advised that the first data dump for all trading pairs might take some time (~40 minutes)
data_dumper.dump_data()
How to update data (get all new data)
data_dumper.dump_data()
How to update (reload) data for the asked time period
data_dumper.dump_data(
date_start=datetime.date(year=2021, month=1, day=1),
date_end=datetime.date(year=2022, month=1, day=1),
is_to_update_existing=True
)
Other useful methods
Get all trading pairs (tickers) from binance
print(data_dumper.get_list_all_trading_pairs())
Get the first data when data for the ticker can be found
print(data_dumper.get_min_start_date_for_ticker())
Get all tickers with locally saved data
print(
data_dumper.get_all_tickers_with_data(timeperiod_per_file="daily")
)
Get all dates for which there is locally saved data
print(
data_dumper.get_all_dates_with_data_for_ticker(
ticker,
timeperiod_per_file="monthly"
)
)
Get directory where the local data of exact ticker lies
print(
data_dumper.get_local_dir_to_data(
ticker,
timeperiod_per_file,
)
)
Create file name for the local file
print(
data_dumper.create_filename(
ticker,
date_obj,
timeperiod_per_file="monthly",
)
)
Links
Project local Links
Contacts
License
This project is licensed under the MIT License.
Metadata
Release files for binance-historical-data 0.1.14
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| binance_historical_data-0.1.14.tar.gz | 14.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| binance_historical_data-0.1.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.5 kB
Release files / binance_historical_data-0.1.14.tar.gz
| Download URL | binance_historical_data-0.1.14.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fdd776093bedfd44a9f4463e63ba67b92656f840e10fab4180b8eb756b837a54
|
|
BLAKE2b-256 checksum How to use checksums |
ec0f3b241a021c36ec64fad094dbcd6d9f359b5545ab01802fa75e3693d9f201
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.7 Windows/10
|
Release files / binance_historical_data-0.1.14-py3-none-any.whl
| Download URL | binance_historical_data-0.1.14-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47caf4e785cb88f0bff04e425e3d29b83b4a8d56d0401f0e0e542d26a4cd315c
|
|
BLAKE2b-256 checksum How to use checksums |
8fa58826a2fe598b1c08be13d5b3a15f3106142f966907e12eb413f9350ced2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.9.7 Windows/10
|
Security for binance-historical-data 0.1.14
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.