Skip to main content

Binance Downloader

Build Status

Python tool to download Binance Candlestick (k-line) data from REST API

Originally forked from bullsignals/binance-downloader, that project does not seem to be maintained any longer and I wanted to actually make use of this project and allow others to contribute. At this point, I have re-written almost all the code from scratch, but would like to thank the original authors for their ideas that got me started.

Installation

Prerequisites

You will need Poetry installed in order to install this package and run from the command line. Poetry is a Python package and dependency manager that makes installation and distribution really easy. Installation instructions can be found here for macOS/Linux/Windows

  • Verify Poetry installation
$ poetry --version
Poetry 0.12.10

Download and install

Clone the repository
$ git clone https://github.com/anson-vandoren/binance-downloader.git
$ cd binance-downloader
Activate your virtual environment

Poetry will try to automatically enable a virtual environment for you if it detects you are not already using one.

If you already use virtualenvwrapper (or similar), go ahead and make (or switch to) your working environment beforehand:

$ mkvirtualenv binance-downloader

or

$ workon binance-downloader
Install dependencies
$ poetry install
Installing dependencies from lock file

Package operations: 12 installs, 0 updates, 0 removals

  - Installing six (1.12.0)
  - Installing certifi (2008.11.29)
  - Installing chardet (3.0.4)
  - Installing idna (2.8)
  - Installing numpy (1.15.4)
  - Installing python-dateutil (2.7.5)
  - Installing pytz (2018.7)
  - Installing urllib3 (1.22)
  - Installing logbook (1.4.1)
  - Installing pandas (0.23.4)
  - Installing requests (2.21.0)
  - Installing tqdm (4.28.1)
  - Installing binance-downloader (0.2.0)

Using the Command Line Interface

Show available options
$  kline-binance --help
usage: kline-binance [-h] [--start START] [--end END] [--dtfmt DATE_FORMAT]
                     symbol interval

CLI for downloading Binance Candlestick (k-line) data in bulk

positional arguments:
  symbol               (Required) Binance symbol pair, e.g. ETHBTC
  interval             (Required) Frequency interval in minutes(m); hours(h);
                       days(d); weeks(w); months(M); All possibles values: 1m
                       3m 5m 15m 30m 1h 2h 4h 6h 8h 12h 1d 3d 1w 1M

optional arguments:
  -h, --help           show this help message and exit
  --start START        Start date to get data (inclusive). Format: yyyy/mm/dd
  --end END            End date to get data (exclusive). Format: yyyy/mm/dd
  --dtfmt DATE_FORMAT  Format to use for dates (DMY, MDY, YMD, etc). Default:
                       YMD
Downloading data
$  kline-binance XRPBTC 1m --start 2016-01-01 --end now
[2019-01-02 05:12:40.941301] NOTICE: api: First available kline starts on {from_ms_utc(period_start)}
[2019-01-02 05:12:40.941867] NOTICE: api: Downloading 620 chunks...
Download : 100%|█████████████████████████████████████████████████| 620/620 [00:48<00:00, 12.73 chunk/s]
Write CSV: 100%|███████████████████████████████████████████████████| 100/100 [00:14<00:00,  7.04 pct/s]
[2019-01-02 05:13:44.784379] NOTICE: db: Done writing ./downloaded/2019-01-01_211330_XRPBTC_1m.csv for 612794 lines

License

This code is made available under the MIT License. See LICENSE file for detail.

Metadata

Release files for binance-downloader 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for binance-downloader 0.2.5
File Size Uploaded
binance-downloader-0.2.5.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for binance-downloader 0.2.5
File Interpreter ABI Platform
binance_downloader-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 36.5 kB

Release files / binance-downloader-0.2.5.tar.gz

Download URL binance-downloader-0.2.5.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6ef1ac3a999ae843ffebe7cf0cfc4bf15dc83c9ba235c96c21a91a474b85a44f
BLAKE2b-256 checksum
How to use checksums
dfa68ca78752bf68156b50eed7b8539db54d0867b94c6c0b54b7b3becdf01088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-41-generic

Release files / binance_downloader-0.2.5-py3-none-any.whl

Download URL binance_downloader-0.2.5-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4336b926f720b65ed22b841d36c577c663f38cdbc03c48aa80c89c595316b0bd
BLAKE2b-256 checksum
How to use checksums
b3e7459d853ce90648f0b88cfbb9893cd5b45bc29a9c9d7f05c178d98a9f9358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.10.0 Linux/5.11.0-41-generic

Release history Release notifications | RSS feed

This release

0.2.5 This release

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page