Skip to main content

Get OHLCV/klines/candlesticks data from binance.

Project description

binance-ohlcv

Run tests codecov PyPI version

Get OHLCV data from binance.

Installation

Install latest release from PyPI:

pip install binance-ohlcv

Or install latest commit from the github repository:

pip install git+https://github.com/decotra/binance-ohlcv

Usage

import binance_ohlcv as bo
from datetime import date

df1 = bo.get_spot(symbol='BTCUSDT', timeframe='1s', start=date(2023, 1, 1), end=date(2023, 1, 2))
df2 = bo.get_futures_um(symbol='BTCUSDT', timeframe='1m', start=date(2023, 1, 1), end=date(2023, 1, 2))
df3 = bo.get_futures_cm(symbol='BTCUSD_PERP', timeframe='1m', start=date(2023, 1, 1), end=date(2023, 1, 2))

print(df1)
print(df2)
print(df3)

Output:

                               open      high       low     close   volume
timestamp
2023-01-01 00:00:00+00:00  16541.77  16543.20  16541.73  16542.37  2.03879
2023-01-01 00:00:01+00:00  16541.90  16542.40  16541.55  16542.16  2.34046
2023-01-01 00:00:02+00:00  16542.16  16542.18  16541.56  16541.62  0.46549
2023-01-01 00:00:03+00:00  16542.12  16542.37  16541.56  16541.78  1.55876
2023-01-01 00:00:04+00:00  16541.79  16542.26  16541.39  16541.95  2.26832
...                             ...       ...       ...       ...      ...
2023-01-02 23:59:55+00:00  16675.08  16675.28  16674.57  16674.58  2.41974
2023-01-02 23:59:56+00:00  16674.58  16674.58  16673.54  16673.57  1.66548
2023-01-02 23:59:57+00:00  16673.53  16673.87  16673.45  16673.53  0.15998
2023-01-02 23:59:58+00:00  16673.52  16673.52  16672.91  16673.26  2.41843
2023-01-02 23:59:59+00:00  16672.86  16673.13  16672.39  16672.87  3.18091

[172800 rows x 5 columns]
                              open     high      low    close    volume
timestamp
2023-01-01 00:00:00+00:00  16537.5  16538.0  16534.3  16538.0   170.576
2023-01-01 00:01:00+00:00  16538.0  16538.0  16534.9  16534.9    44.287
2023-01-01 00:02:00+00:00  16534.9  16535.0  16531.3  16531.4   100.228
2023-01-01 00:03:00+00:00  16531.4  16531.4  16526.6  16526.9   317.879
2023-01-01 00:04:00+00:00  16527.0  16529.3  16523.0  16529.2   211.281
...                            ...      ...      ...      ...       ...
2023-01-02 23:55:00+00:00  16672.7  16672.7  16650.0  16665.1  1879.831
2023-01-02 23:56:00+00:00  16665.2  16666.9  16663.6  16663.6   181.900
2023-01-02 23:57:00+00:00  16663.7  16668.5  16663.6  16666.9   156.172
2023-01-02 23:58:00+00:00  16666.8  16668.0  16666.8  16667.9   115.988
2023-01-02 23:59:00+00:00  16668.0  16668.0  16665.9  16666.0   146.532

[2880 rows x 5 columns]
                              open     high      low    close  volume
timestamp
2023-01-01 00:00:00+00:00  16531.2  16531.2  16531.1  16531.1     132
2023-01-01 00:01:00+00:00  16531.1  16531.2  16531.1  16531.1     333
2023-01-01 00:02:00+00:00  16531.1  16531.1  16528.0  16528.0    4254
2023-01-01 00:03:00+00:00  16528.1  16528.1  16524.4  16524.5    4589
2023-01-01 00:04:00+00:00  16524.5  16524.5  16521.6  16521.7    3141
...                            ...      ...      ...      ...     ...
2023-01-02 23:55:00+00:00  16667.5  16667.6  16650.0  16660.4   31447
2023-01-02 23:56:00+00:00  16660.3  16660.4  16660.3  16660.4    1434
2023-01-02 23:57:00+00:00  16660.4  16661.6  16660.4  16661.6    2441
2023-01-02 23:58:00+00:00  16661.6  16661.6  16661.5  16661.6     316
2023-01-02 23:59:00+00:00  16661.6  16661.6  16661.5  16661.6     888

[2880 rows x 5 columns]

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

binance_ohlcv-0.0.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

binance_ohlcv-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file binance_ohlcv-0.0.2.tar.gz.

File metadata

  • Download URL: binance_ohlcv-0.0.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.10.0 CPython/3.10.12

File hashes

Hashes for binance_ohlcv-0.0.2.tar.gz
Algorithm Hash digest
SHA256 036d8c3f7fa1d9c8304d3fbebd41917072d485694bb7fc2672175a3fc14da948
MD5 6fa14ba0bc3d78e247b0a777f92c94d9
BLAKE2b-256 0ad278ce00e878771d62184f5ef0453a2678414d07b4627da24a308f5a97598c

See more details on using hashes here.

File details

Details for the file binance_ohlcv-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for binance_ohlcv-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9300939904cfe16da968256a7cc5f2079e0f53068c69cf02d0f96554249e55b1
MD5 99b7d7377ab62ec6fc99f4db1a2ff3d5
BLAKE2b-256 b82574db27d28e7f0093bfe9cf3dca1a6c3e53ef878c6c811e586f534a1ca663

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