A tool for exporting in JSON the historical data of a symbol from Binance
Project description
Binance API Data Exporter
This Python script allows you to retrieve historical data from Binance API and export it to a JSON file. The data can be retrieved for any specified symbol (e.g. BTCUSDT) and interval (e.g. 1m, 1h, 1d) for a given period of time.
Installation
- Install it via pip by running the following command in your terminal:
pip install binance-data-exporter
-
Check out the project on PyPI at https://pypi.org/project/binance-data-exporter/.
-
Clone the project repository from GitHub by running the following command in your terminal:
git clone git@github.com:zestones/Binance-Data-Exporter.git
Usage
To run the script, use the following command:
python binance_data_exporter.py [OPTIONS]
Bellow the list of available options you can use to customize the request to the Binance API:
Option | Description | Possible Values | Default Value |
---|---|---|---|
-h ,--help |
Show the help message and exit | ||
-i ,--interval |
The interval of the data | 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M | 1d |
-p ,--pair |
The pair of coin (refer to the binance symbol list) | BTCUSDT, ETHUSDT, etc | BTCUSDT |
-l ,--limit |
The limit of the data per request | 1, 2, ..., 1000 (Should be integer) | 500 |
-s ,--start-time |
The start time of the data | YYYY_MM_DD | None |
-e ,--end-time |
The end time of the data | YYYY_MM_DD | TODAY |
-o ,--output-folder |
The folder where the data will be exported | Path | ./data |
NOTE
- If you don't specify a start time for your request, it will use the earliest available data for the requested time interval.
- If the end-time is not specified the date of the day will be choosed by default.
- If you dont provide parameters, the script will use the default values specified.
Examples
To retrieve data for ETHUSDT from 2018-01-15 to 2018-01-16 with an interval of 1 hour, a limit of 10, and export the data to ./data/eth_usdt/
, use the following command:
python binance_data_exporter.py -l 10 -i 1h -p ETHUSDT -s 2018_01_15 -e 2018_01_16 -o ./data/eth_usdt/
You can customize the parameters to retrieve data as you wish.
Dependencies
The script requires the following dependencies:
- requests
- colorama
- tabulate
You can install the dependencies using the following command:
pip install -r requirements.txt
Output
The script exports the retrieved data as a JSON file in the OUTPUT_FOLDER
specified in the configuration. The filename of the JSON file is in the following format: symbol_start-date_to_end-date_interval.json
where start_date
and end_date
are the start and end dates of the data retrieved, respectively and interval
is the interval between each data point.
API Limits and Maximum Number of Requests
Please note that Binance API has certain limits on the number of requests that can be made within a specific time frame.
It is important to be mindful of these limits when making requests to avoid being disconnected or banned. Make sure to not exceed the number of requests allowed by the API, when configuring the limit
and interval
parameters in the script.
Binance API Documentation
For more information on the Binance API, you can refer to the official documentation at:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file binance_data_exporter-0.2.7.tar.gz
.
File metadata
- Download URL: binance_data_exporter-0.2.7.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f35a4594ac0723d20a598bac441937f6d79acc6e1c98582d8649498e504ccd |
|
MD5 | c0b4e06a75eb9ac1b3bf59486241d718 |
|
BLAKE2b-256 | 8b5c7bd52093da7f2e0daabd20e34022f936190115a641745a49c75ffb4a091f |
File details
Details for the file binance_data_exporter-0.2.7-py3-none-any.whl
.
File metadata
- Download URL: binance_data_exporter-0.2.7-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df23c79b1eb69c1ff3f8e7e6c5ced054c143fa61eb1ade17b96a594a6cd4ec3 |
|
MD5 | ede77b4aff0d8e0626cbbcb15cae6f8a |
|
BLAKE2b-256 | 4c2aae241b00992a398205676fe6a2823f4af2ef3e1340831c49a17c38025e66 |