Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/1.0.1/test klines options #6

Merged
merged 2 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 27 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Python library for bulk downloading Binance historical data
A Python library to efficiently and concurrently download historical data files from Binance.

Supports multiple asset types (spot, futures, options) and various data frequencies.
Supports all asset types (spot, USDT-M, COIN-M, options) and all data frequencies.

Status on available data types is shown below.

Expand Down Expand Up @@ -56,37 +56,39 @@ This library is under development. Not all unit tests have been completed yet an
| bookDepth | ❎ | ✅ | ✅ | ❎ |
| bookTicker | ❎ | ✅ | ✅ | ❎ |
| fundingRate | ❎ | ✅ | ✅ | ❎ |
| indexPriceKlines | ❎ | 🚧 | 🚧 | ❎ |
| klines | ✅ | ✅ | | ❎ |
| indexPriceKlines | ❎ | | | ❎ |
| klines | ✅ | ✅ | | ❎ |
| liquidationSnapshot | ❎ | ✅ | ✅ | ❎ |
| markPriceKlines | ❎ | 🚧 | 🚧 | ❎ |
| markPriceKlines | ❎ | | | ❎ |
| metrics | ❎ | ✅ | ✅ | ❎ |
| premiumIndexKlines | ❎ | 🚧 | 🚧 | ❎ |
| trades | ✅ | ✅ | | ❎ |
| BVOLIndex | ❎ | ❎ | ❎ | ❌ |
| EOHSummary | ❎ | ❎ | ❎ | ❌ |
| premiumIndexKlines | ❎ | | | ❎ |
| trades | ✅ | ✅ | | ❎ |
| BVOLIndex | ❎ | ❎ | ❎ | ✅ |
| EOHSummary | ❎ | ❎ | ❎ | ✅ |

### by data_frequency (klines, indexPriceKlines, markPriceKlines, premiumIndexKlines)

| data_frequency | spot | um | cm | options |
| :------------- | :--: | :--: | :--: | :-----: |
| 1s | ✅ | ❎ | ❎ | ❎ |
| 1m | ✅ | ✅ | ❌ | ❎ |
| 3m | ✅ | ✅ | ❌ | ❎ |
| 5m | ✅ | ✅ | ❌ | ❎ |
| 15m | ✅ | ✅ | ❌ | ❎ |
| 30m | ✅ | ✅ | ❌ | ❎ |
| 1h | ✅ | ✅ | ❌ | ❎ |
| 2h | ✅ | ✅ | ❌ | ❎ |
| 4h | ✅ | ✅ | ❌ | ❎ |
| 6h | ✅ | ✅ | ❌ | ❎ |
| 8h | ✅ | ✅ | ❌ | ❎ |
| 12h | ✅ | ✅ | ❌ | ❎ |
| 1d | ✅ | ✅ | ❌ | ❎ |
| 3d | ❌ | ❌ | ❌ | ❎ |
| 1w | ❌ | ❌ | ❌ | ❎ |
| 1mo | ❌ | ❌ | ❌ | ❎ |

| 1s | ✅ | ❎ | ❎ | ❎ |
| 1m | ✅ | ✅ | ✅ | ❎ |
| 3m | ✅ | ✅ | ✅ | ❎ |
| 5m | ✅ | ✅ | ✅ | ❎ |
| 15m | ✅ | ✅ | ✅ | ❎ |
| 30m | ✅ | ✅ | ✅ | ❎ |
| 1h | ✅ | ✅ | ✅ | ❎ |
| 2h | ✅ | ✅ | ✅ | ❎ |
| 4h | ✅ | ✅ | ✅ | ❎ |
| 6h | ✅ | ✅ | ✅ | ❎ |
| 8h | ✅ | ✅ | ✅ | ❎ |
| 12h | ✅ | ✅ | ✅ | ❎ |
| 1d | ✅ | ✅ | ✅ | ❎ |
| 3d | ✅ | ✅ | ✅ | ❎ |
| 1w | ✅ | ✅ | ✅ | ❎ |
| 1mo | ✅ | ✅ | ✅ | ❎ |

## If you want to report a bug or request a feature
Please create an issue on this repository!

## Disclaimer
This project is for educational purposes only. You should not construe any such information or other material as legal,
Expand Down
2 changes: 1 addition & 1 deletion downloader/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def _make_asset_type(self) -> str:
elif self._asset in "cm":
asset_type = "futures/cm"
elif self._asset in self._OPTIONS_ASSET:
asset_type = "options"
asset_type = "option"
elif self._asset in self._ASSET:
asset_type = "spot"
else:
Expand Down
52 changes: 52 additions & 0 deletions tests/test_bvolindex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# import standard libraries
import os

# import third party libraries
import pytest

# import my libraries
from downloader.downloader import *


def dynamic_bvolindex_test_params():
"""
Generate params for BVOLIndex tests
:return:
"""
for asset in BinanceBulkDownloader._OPTIONS_ASSET:
for data_type in ["BVOLIndex"]:
for timeperiod_per_file in ["daily"]:
yield pytest.param(
asset,
data_type,
timeperiod_per_file,
id=f"{asset}-{data_type}-{timeperiod_per_file}",
)


@pytest.mark.parametrize(
"asset, data_type, timeperiod_per_file", dynamic_bvolindex_test_params()
)
def test_bvolindex(tmpdir, asset, data_type, timeperiod_per_file):
"""
Test BVOLIndex
:param tmpdir:
:param asset: asset (option)
:param data_type: data type (BVOLIndex)
:param timeperiod_per_file: time period per file (daily)
:return:
"""
downloader = BinanceBulkDownloader(
destination_dir=tmpdir,
asset=asset,
data_type=data_type,
timeperiod_per_file=timeperiod_per_file,
)
prefix = downloader._build_prefix()
single_download_prefix = (
prefix + "/BTCBVOLUSDT/BTCBVOLUSDT-BVOLIndex-2023-07-01.zip"
)
destination_path = tmpdir.join(single_download_prefix.replace(".zip", ".csv"))
downloader._download(single_download_prefix)
# If exists csv file on destination dir, test is passed.
assert os.path.exists(destination_path)
50 changes: 50 additions & 0 deletions tests/test_eohsummary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# import standard libraries
import os

# import third party libraries
import pytest

# import my libraries
from downloader.downloader import *


def dynamic_eohsummary_test_params():
"""
Generate params for EOHSummary tests
:return:
"""
for asset in BinanceBulkDownloader._OPTIONS_ASSET:
for data_type in ["EOHSummary"]:
for timeperiod_per_file in ["daily"]:
yield pytest.param(
asset,
data_type,
timeperiod_per_file,
id=f"{asset}-{data_type}-{timeperiod_per_file}",
)


@pytest.mark.parametrize(
"asset, data_type, timeperiod_per_file", dynamic_eohsummary_test_params()
)
def test_eohsummary(tmpdir, asset, data_type, timeperiod_per_file):
"""
Test EOHSummary
:param tmpdir:
:param asset: asset (option)
:param data_type: data type (EOHSummary)
:param timeperiod_per_file: time period per file (daily)
:return:
"""
downloader = BinanceBulkDownloader(
destination_dir=tmpdir,
asset=asset,
data_type=data_type,
timeperiod_per_file=timeperiod_per_file,
)
prefix = downloader._build_prefix()
single_download_prefix = prefix + "/BTCUSDT/BTCUSDT-EOHSummary-2023-07-01.zip"
destination_path = tmpdir.join(single_download_prefix.replace(".zip", ".csv"))
downloader._download(single_download_prefix)
# If exists csv file on destination dir, test is passed.
assert os.path.exists(destination_path)
Loading