Skip to content
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
1 change: 1 addition & 0 deletions datamaxi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from datamaxi.datamaxi import Datamaxi # noqa: F401
4 changes: 2 additions & 2 deletions datamaxi/binance/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Binance supported symbols
"""Binance supported symbols

`GET /v1/raw/binance/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Binance supported intervals
"""Binance supported intervals

`GET /v1/raw/binance/intervals`

Expand Down
4 changes: 2 additions & 2 deletions datamaxi/bithumb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Bithumb supported symbols
"""Bithumb supported symbols

`GET /v1/raw/bithumb/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Bithumb supported intervals
"""Bithumb supported intervals

`GET /v1/raw/bithumb/intervals`

Expand Down
4 changes: 2 additions & 2 deletions datamaxi/bybit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Bybit supported symbols
"""Bybit supported symbols

`GET /v1/raw/bybit/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Bybit supported intervals
"""Bybit supported intervals

`GET /v1/raw/bybit/intervals`

Expand Down
4 changes: 2 additions & 2 deletions datamaxi/coinone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Coinone supported symbols
"""Coinone supported symbols

`GET /v1/raw/coinone/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Coinone supported intervals
"""Coinone supported intervals

`GET /v1/raw/coinone/intervals`

Expand Down
84 changes: 84 additions & 0 deletions datamaxi/datamaxi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
from typing import Any, List, Union
import pandas as pd
from datamaxi.api import API
from datamaxi.lib.utils import check_required_parameter
from datamaxi.lib.utils import check_required_parameters
from datamaxi.lib.utils import postprocess
from datamaxi.lib.constants import BASE_URL


class Datamaxi(API):
"""Client to fetch unified data from DataMaxi+ API."""

def __init__(self, api_key=None, **kwargs: Any):
"""Initialize the object.

Args:
api_key (str): The DataMaxi+ API key
**kwargs: Keyword arguments used by `datamaxi.api.API`.
"""
if "base_url" not in kwargs:
kwargs["base_url"] = BASE_URL

super().__init__(api_key, **kwargs)

def symbols(self, exchange: str) -> List[str]:
"""Supported symbols by given exchange

`GET /v1/symbols`

<https://docs.datamaxiplus.com/symbols>

Args:
exchange (str): Exchange name

Returns:
List of supported symbols
"""
check_required_parameter(exchange, "exchange")
params = {"exchange": exchange}
url_path = "/v1/symbols"
return self.query(url_path, params)

def intervals(self, exchange: str) -> List[str]:
"""Supported intervals by given exchange

`GET /v1/intervals`

<https://docs.datamaxiplus.com/intervals>

Args:
exchange (str): Exchange name

Returns:
List of supported intervals
"""
check_required_parameter(exchange, "exchange")
params = {"exchange": exchange}
url_path = "/v1/intervals"
return self.query(url_path, params)

@postprocess()
def candle(
self, exchange: str, symbol: str, interval: str = "1d", pandas: bool = True
) -> Union[List, pd.DataFrame]:
"""Get candle data

`GET /v1/candle`

<https://docs.datamaxiplus.com/candle>

Args:
exchange (str): Exchange name
symbol (str): Symbol name
interval (str): Candle interval
pandas (bool): Return data as pandas DataFrame

Returns:
Candle data for a given symbol and interval in pandas DataFrame
"""
check_required_parameters(
[[exchange, "exchange"], [symbol, "symbol"], [interval, "interval"]]
)
params = {"exchange": exchange, "symbol": symbol, "interval": interval}
return self.query("/v1/candle", params)
4 changes: 2 additions & 2 deletions datamaxi/huobi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Huobi supported symbols
"""Huobi supported symbols

`GET /v1/raw/huobi/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Huobi supported intervals
"""Huobi supported intervals

`GET /v1/raw/huobi/intervals`

Expand Down
4 changes: 2 additions & 2 deletions datamaxi/okx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Okx supported symbols
"""Okx supported symbols

`GET /v1/raw/okx/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Okx supported intervals
"""Okx supported intervals

`GET /v1/raw/okx/intervals`

Expand Down
4 changes: 2 additions & 2 deletions datamaxi/upbit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, api_key=None, **kwargs: Any):
super().__init__(api_key, **kwargs)

def symbols(self) -> List[str]:
"""Supported Upbit supported symbols
"""Upbit supported symbols

`GET /v1/raw/upbit/symbols`

Expand All @@ -35,7 +35,7 @@ def symbols(self) -> List[str]:
return self.query(url_path)

def intervals(self) -> List[str]:
"""Supported Upbit supported intervals
"""Upbit supported intervals

`GET /v1/raw/upbit/intervals`

Expand Down