Skip to content

Commit 31a40e5

Browse files
Add new CEX clients (#8)
* feat: binance intervals * feat: okx * feat: bybit * feat: huobi candle * feat: coinone candle * feat: upbit candle * feat: bithumb candle * feat: generate documentation only on `workflow_dispatch`
1 parent 7947171 commit 31a40e5

29 files changed

+1073
-20
lines changed

.github/workflows/docs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Publish Documentation
22

33
on:
4-
push:
5-
branches:
6-
- main
74
workflow_dispatch:
85

96
jobs:

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This package is compatible with Python v3.8+.
2424
## Installation
2525

2626
```shell
27-
pip install datamaxi
27+
pip3 install datamaxi
2828
```
2929

3030
## Configuration
@@ -54,6 +54,12 @@ You may use environment variables to configure the DataMaxi+ client to avoid any
5454
DataMaxi+ Python package currently includes the following clients:
5555

5656
- `Binance`
57+
- `Bithumb`
58+
- `Bybit`
59+
- `Coinone`
60+
- `Huobi`
61+
- `Okx`
62+
- `Upbit`
5763
- `Defillama`
5864
- `Naver`
5965
- `Google`
@@ -62,17 +68,39 @@ All clients accept the same parameters that are described at [Configuration](#co
6268
First, import the clients,
6369

6470
```python
71+
# CEX
6572
from datamaxi.binance import Binance
73+
from datamaxi.bithumb import Bithumb
74+
from datamaxi.bybit import Bybit
75+
from datamaxi.coinone import Coinone
76+
from datamaxi.huobi import Huobi
77+
from datamaxi.okx import Okx
78+
from datamaxi.upbit import Upbit
79+
80+
# DeFi
6681
from datamaxi.defillama import Defillama
82+
83+
# Trend
6784
from datamaxi.naver import Naver
6885
from datamaxi.google import Google
6986
```
7087

7188
and initialize them.
7289

7390
```python
91+
# CEX
7492
binance = Binance(api_key=api_key)
93+
bithumb = Bithumb(api_key=api_key)
94+
bybit = Bybit(api_key=api_key)
95+
coinone = Coinone(api_key=api_key)
96+
huobi = Huobi(api_key=api_key)
97+
okx = Okx(api_key=api_key)
98+
upbit = Upbit(api_key=api_key)
99+
100+
# DeFi
75101
defillama = Defillama(api_key=api_key)
102+
103+
# Trend
76104
naver = Naver(api_key=api_key)
77105
google = Google(api_key=api_key)
78106
```
@@ -87,9 +115,9 @@ If you wish to work on local development please clone/fork the git repo and use
87115

88116
```shell
89117
# In case packages are not installed yet
90-
pip install -r requirements/requirements-test.txt
118+
pip3 install -r requirements/requirements-test.txt
91119

92-
python -m pytest tests/
120+
python3 -m pytest tests/
93121
```
94122

95123
## Links

datamaxi/binance/__init__.py

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ def __init__(self, api_key=None, **kwargs: Any):
1818
"""
1919
if "base_url" not in kwargs:
2020
kwargs["base_url"] = BASE_URL
21-
super().__init__(api_key, **kwargs)
21+
22+
super().__init__(api_key, **kwargs)
2223

2324
def symbols(self) -> List[str]:
2425
"""Supported Binance supported symbols
@@ -33,24 +34,37 @@ def symbols(self) -> List[str]:
3334
url_path = "/v1/raw/binance/symbols"
3435
return self.query(url_path)
3536

37+
def intervals(self) -> List[str]:
38+
"""Supported Binance supported intervals
39+
40+
`GET /v1/raw/binance/intervals`
41+
42+
<https://docs.datamaxiplus.com/cex/binance/intervals>
43+
44+
Returns:
45+
List of supported Binance intervals
46+
"""
47+
url_path = "/v1/raw/binance/intervals"
48+
return self.query(url_path)
49+
3650
@postprocess()
37-
def kline(
51+
def candle(
3852
self, symbol: str, interval: str = "1d", pandas: bool = True
3953
) -> Union[List, pd.DataFrame]:
40-
"""Get Binance k-line data
54+
"""Get Binance candle data
4155
42-
`GET /v1/raw/binance/kline`
56+
`GET /v1/raw/binance/candle`
4357
44-
<https://docs.datamaxiplus.com/cex/binance/kline>
58+
<https://docs.datamaxiplus.com/cex/binance/candle>
4559
4660
Args:
4761
symbol (str): Binance symbol
48-
interval (str): Kline interval
62+
interval (str): Candle interval
4963
pandas (bool): Return data as pandas DataFrame
5064
5165
Returns:
52-
Binance kline data for a given symbol and interval in pandas DataFrame
66+
Binance candle data for a given symbol and interval in pandas DataFrame
5367
"""
5468
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
5569
params = {"symbol": symbol, "interval": interval}
56-
return self.query("/v1/raw/binance/kline", params)
70+
return self.query("/v1/raw/binance/candle", params)

datamaxi/bithumb/__init__.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from typing import Any, List, Union
2+
import pandas as pd
3+
from datamaxi.api import API
4+
from datamaxi.lib.utils import check_required_parameters
5+
from datamaxi.lib.utils import postprocess
6+
from datamaxi.lib.constants import BASE_URL
7+
8+
9+
class Bithumb(API):
10+
"""Client to fetch Bithumb data from DataMaxi+ API."""
11+
12+
def __init__(self, api_key=None, **kwargs: Any):
13+
"""Initialize the object.
14+
15+
Args:
16+
api_key (str): The DataMaxi+ API key
17+
**kwargs: Keyword arguments used by `datamaxi.api.API`.
18+
"""
19+
if "base_url" not in kwargs:
20+
kwargs["base_url"] = BASE_URL
21+
22+
super().__init__(api_key, **kwargs)
23+
24+
def symbols(self) -> List[str]:
25+
"""Supported Bithumb supported symbols
26+
27+
`GET /v1/raw/bithumb/symbols`
28+
29+
<https://docs.datamaxiplus.com/cex/bithumb/symbols>
30+
31+
Returns:
32+
List of supported Bithumb symbols
33+
"""
34+
url_path = "/v1/raw/bithumb/symbols"
35+
return self.query(url_path)
36+
37+
def intervals(self) -> List[str]:
38+
"""Supported Bithumb supported intervals
39+
40+
`GET /v1/raw/bithumb/intervals`
41+
42+
<https://docs.datamaxiplus.com/cex/bithumb/intervals>
43+
44+
Returns:
45+
List of supported Bithumb intervals
46+
"""
47+
url_path = "/v1/raw/bithumb/intervals"
48+
return self.query(url_path)
49+
50+
@postprocess()
51+
def candle(
52+
self, symbol: str, interval: str = "1d", pandas: bool = True
53+
) -> Union[List, pd.DataFrame]:
54+
"""Get Bithumb candle data
55+
56+
`GET /v1/raw/bithumb/candle`
57+
58+
<https://docs.datamaxiplus.com/cex/bithumb/candle>
59+
60+
Args:
61+
symbol (str): Bithumb symbol
62+
interval (str): Candle interval
63+
pandas (bool): Return data as pandas DataFrame
64+
65+
Returns:
66+
Bithumb candle data for a given symbol and interval in pandas DataFrame
67+
"""
68+
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
69+
params = {"symbol": symbol, "interval": interval}
70+
return self.query("/v1/raw/bithumb/candle", params)

datamaxi/bybit/__init__.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from typing import Any, List, Union
2+
import pandas as pd
3+
from datamaxi.api import API
4+
from datamaxi.lib.utils import check_required_parameters
5+
from datamaxi.lib.utils import postprocess
6+
from datamaxi.lib.constants import BASE_URL
7+
8+
9+
class Bybit(API):
10+
"""Client to fetch Bybit data from DataMaxi+ API."""
11+
12+
def __init__(self, api_key=None, **kwargs: Any):
13+
"""Initialize the object.
14+
15+
Args:
16+
api_key (str): The DataMaxi+ API key
17+
**kwargs: Keyword arguments used by `datamaxi.api.API`.
18+
"""
19+
if "base_url" not in kwargs:
20+
kwargs["base_url"] = BASE_URL
21+
22+
super().__init__(api_key, **kwargs)
23+
24+
def symbols(self) -> List[str]:
25+
"""Supported Bybit supported symbols
26+
27+
`GET /v1/raw/bybit/symbols`
28+
29+
<https://docs.datamaxiplus.com/cex/bybit/symbols>
30+
31+
Returns:
32+
List of supported Bybit symbols
33+
"""
34+
url_path = "/v1/raw/bybit/symbols"
35+
return self.query(url_path)
36+
37+
def intervals(self) -> List[str]:
38+
"""Supported Bybit supported intervals
39+
40+
`GET /v1/raw/bybit/intervals`
41+
42+
<https://docs.datamaxiplus.com/cex/bybit/intervals>
43+
44+
Returns:
45+
List of supported Bybit intervals
46+
"""
47+
url_path = "/v1/raw/bybit/intervals"
48+
return self.query(url_path)
49+
50+
@postprocess()
51+
def candle(
52+
self, symbol: str, interval: str = "1d", pandas: bool = True
53+
) -> Union[List, pd.DataFrame]:
54+
"""Get Bybit candle data
55+
56+
`GET /v1/raw/bybit/candle`
57+
58+
<https://docs.datamaxiplus.com/cex/bybit/candle>
59+
60+
Args:
61+
symbol (str): Bybit symbol
62+
interval (str): Candle interval
63+
pandas (bool): Return data as pandas DataFrame
64+
65+
Returns:
66+
Bybit candle data for a given symbol and interval in pandas DataFrame
67+
"""
68+
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
69+
params = {"symbol": symbol, "interval": interval}
70+
return self.query("/v1/raw/bybit/candle", params)

datamaxi/coinone/__init__.py

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
from typing import Any, List, Union
2+
import pandas as pd
3+
from datamaxi.api import API
4+
from datamaxi.lib.utils import check_required_parameters
5+
from datamaxi.lib.utils import postprocess
6+
from datamaxi.lib.constants import BASE_URL
7+
8+
9+
class Coinone(API):
10+
"""Client to fetch Coinone data from DataMaxi+ API."""
11+
12+
def __init__(self, api_key=None, **kwargs: Any):
13+
"""Initialize the object.
14+
15+
Args:
16+
api_key (str): The DataMaxi+ API key
17+
**kwargs: Keyword arguments used by `datamaxi.api.API`.
18+
"""
19+
if "base_url" not in kwargs:
20+
kwargs["base_url"] = BASE_URL
21+
22+
super().__init__(api_key, **kwargs)
23+
24+
def symbols(self) -> List[str]:
25+
"""Supported Coinone supported symbols
26+
27+
`GET /v1/raw/coinone/symbols`
28+
29+
<https://docs.datamaxiplus.com/cex/coinone/symbols>
30+
31+
Returns:
32+
List of supported Coinone symbols
33+
"""
34+
url_path = "/v1/raw/coinone/symbols"
35+
return self.query(url_path)
36+
37+
def intervals(self) -> List[str]:
38+
"""Supported Coinone supported intervals
39+
40+
`GET /v1/raw/coinone/intervals`
41+
42+
<https://docs.datamaxiplus.com/cex/coinone/intervals>
43+
44+
Returns:
45+
List of supported Coinone intervals
46+
"""
47+
url_path = "/v1/raw/coinone/intervals"
48+
return self.query(url_path)
49+
50+
@postprocess()
51+
def candle(
52+
self, symbol: str, interval: str = "1d", pandas: bool = True
53+
) -> Union[List, pd.DataFrame]:
54+
"""Get Coinone candle data
55+
56+
`GET /v1/raw/coinone/candle`
57+
58+
<https://docs.datamaxiplus.com/cex/coinone/candle>
59+
60+
Args:
61+
symbol (str): Coinone symbol
62+
interval (str): Candle interval
63+
pandas (bool): Return data as pandas DataFrame
64+
65+
Returns:
66+
Coinone candle data for a given symbol and interval in pandas DataFrame
67+
"""
68+
check_required_parameters([[symbol, "symbol"], [interval, "interval"]])
69+
params = {"symbol": symbol, "interval": interval}
70+
return self.query("/v1/raw/coinone/candle", params)

0 commit comments

Comments
 (0)