binance-ohlcv 0.0.3
Get OHLCV/klines/candlesticks data from binance.
License: MIT
Requires Python: <3.13,>=3.9

# binance-ohlcv

[![Run tests](https://github.com/decotra/binance-ohlcv/actions/workflows/tests.yml/badge.svg)](https://github.com/decotra/binance-ohlcv/actions/workflows/tests.yml)
[![codecov](https://codecov.io/gh/decotra/binance-ohlcv/graph/badge.svg?token=FKXYXZDQF5)](https://codecov.io/gh/decotra/binance-ohlcv)
[![PyPI version](https://badge.fury.io/py/binance-ohlcv.svg)](https://badge.fury.io/py/binance-ohlcv)

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

```python
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]
```