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.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: binance_ohlcv-0.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2f8c124a073f3a3be88f8c9b99c6454ffa2a868675ca796a57dca2ab5ba30aeb
MD5 d66c2f9bc4b2b8f7c9fe407da3413df2
BLAKE2b-256 c7ac0debd3b1e12a600beb41bedb190124607c3d209e19996be8493c6cf00b97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for binance_ohlcv-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f99d92e3bdc07ea02c3f35f7515e080c7fb9a05507faf08853f3fda8b5839e18
MD5 a365b548c732a638ddc6830abc47777f
BLAKE2b-256 b69d88c2438a4eec6c5d4f4766414380b00e82490f165223c58b8926a7252825

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