diff --git a/datamaxi/__init__.py b/datamaxi/__init__.py index 4548bca..1d709d2 100644 --- a/datamaxi/__init__.py +++ b/datamaxi/__init__.py @@ -1 +1,3 @@ from datamaxi.datamaxi import Datamaxi # noqa: F401 +from datamaxi.telegram import Telegram # noqa: F401 +from datamaxi.naver import Naver # noqa: F401 diff --git a/datamaxi/datamaxi/cex_announcement.py b/datamaxi/datamaxi/cex_announcement.py index 642dc5f..2f72d31 100644 --- a/datamaxi/datamaxi/cex_announcement.py +++ b/datamaxi/datamaxi/cex_announcement.py @@ -17,10 +17,12 @@ def __init__(self, api_key=None, **kwargs: Any): def __call__( self, - category: Optional[str] = None, page: int = 1, limit: int = 1000, sort: str = DESC, + key: Optional[str] = None, + exchange: Optional[str] = None, + category: Optional[str] = None, ) -> Dict[str, Any]: """Get exchange announcements @@ -47,10 +49,12 @@ def __call__( raise ValueError("sort must be either asc or desc") params = { - "category": category, "page": page, "limit": limit, "sort": sort, + "key": key, + "exchange": exchange, + "category": category, } res = self.query("/api/v1/cex/announcements", params) diff --git a/datamaxi/datamaxi/cex_candle.py b/datamaxi/datamaxi/cex_candle.py index 87c0c3f..f24debb 100644 --- a/datamaxi/datamaxi/cex_candle.py +++ b/datamaxi/datamaxi/cex_candle.py @@ -27,10 +27,10 @@ def __call__( exchange: str, market: str, symbol: str, + currency: str = USD, interval: str = INTERVAL_1D, from_unix: str = None, to_unix: str = None, - currency: str = USD, pandas: bool = True, ) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]: """Fetch candle data @@ -43,10 +43,10 @@ def __call__( exchange (str): Exchange name market (str): Market type (spot/futures) symbol (str): Symbol name + currency (str): Currency interval (str): Candle interval from_unix (str): Start time in Unix timestamp to_unix (str): End time in Unix timestamp - currency (str): Currency pandas (bool): Return data as pandas DataFrame Returns: @@ -86,7 +86,7 @@ def __call__( def exchanges(self, market: str) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.CexCandle.get](./#datamaxi.datamaxi.CexCandle.get) + [datamaxi.CexCandle.get](#datamaxi.datamaxi.CexCandle.get) API. `GET /api/v1/cex/candle/exchanges` @@ -110,7 +110,7 @@ def exchanges(self, market: str) -> List[str]: def symbols(self, exchange: str = None, market: str = None) -> List[Dict]: """Fetch supported symbols accepted by - [datamaxi.CexCandle.get](./#datamaxi.datamaxi.CexCandle.get) + [datamaxi.CexCandle.get](#datamaxi.datamaxi.CexCandle.get) API. `GET /api/v1/cex/candle/symbols` @@ -138,7 +138,7 @@ def symbols(self, exchange: str = None, market: str = None) -> List[Dict]: def intervals(self) -> List[str]: """Fetch supported intervals accepted by - [datamaxi.CexCandle.get](./#datamaxi.datamaxi.CexCandle.get) + [datamaxi.CexCandle.get](#datamaxi.datamaxi.CexCandle.get) API. `GET /api/v1/candle/intervals` diff --git a/datamaxi/datamaxi/cex_fee.py b/datamaxi/datamaxi/cex_fee.py index b13192b..296d3d8 100644 --- a/datamaxi/datamaxi/cex_fee.py +++ b/datamaxi/datamaxi/cex_fee.py @@ -44,7 +44,7 @@ def __call__( def exchanges(self) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.CexFee.get](./#datamaxi.datamaxi.CexFee.get) + [datamaxi.CexFee.get](#datamaxi.datamaxi.CexFee.get) API. `GET /api/v1/trading-fees/exchanges` @@ -59,7 +59,7 @@ def exchanges(self) -> List[str]: def symbols(self, exchange: str) -> List[str]: """Fetch supported symbols accepted by - [datamaxi.CexTradingFees.get](./#datamaxi.datamaxi.CexTradingFees.get) + [datamaxi.CexTradingFees.get](#datamaxi.datamaxi.CexTradingFees.get) API. `GET /api/v1/trading-fees/symbols` diff --git a/datamaxi/datamaxi/cex_ticker.py b/datamaxi/datamaxi/cex_ticker.py index eb2762b..a6f27f2 100644 --- a/datamaxi/datamaxi/cex_ticker.py +++ b/datamaxi/datamaxi/cex_ticker.py @@ -22,6 +22,8 @@ def get( exchange: str, symbol: str, market: str, + currency: str = None, + conversion_base: str = None, pandas: bool = True, ) -> Union[Dict, pd.DataFrame]: """Fetch ticker data @@ -57,6 +59,12 @@ def get( "market": market, } + if currency is not None: + params["currency"] = currency + + if conversion_base is not None: + params["conversion_base"] = conversion_base + res = self.query("/api/v1/ticker", params) if pandas: @@ -71,7 +79,7 @@ def exchanges( market: str, ) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.CexTicker.get](./#datamaxi.datamaxi.CexTicker.get) + [datamaxi.CexTicker.get](#datamaxi.datamaxi.CexTicker.get) API. `GET /api/v1/ticker/exchanges` @@ -106,7 +114,7 @@ def symbols( market: str, ) -> List[str]: """Fetch supported symbols accepted by - [datamaxi.CexTicker.get](./#datamaxi.datamaxi.CexTicker.get) + [datamaxi.CexTicker.get](#datamaxi.datamaxi.CexTicker.get) API. `GET /api/v1/ticker/symbols` diff --git a/datamaxi/datamaxi/cex_token.py b/datamaxi/datamaxi/cex_token.py index 08d99a6..78e0421 100644 --- a/datamaxi/datamaxi/cex_token.py +++ b/datamaxi/datamaxi/cex_token.py @@ -17,9 +17,9 @@ def __init__(self, api_key=None, **kwargs: Any): def updates( self, - type: Optional[str] = None, page: int = 1, limit: int = 1000, + type: Optional[str] = None, sort: str = DESC, ) -> Dict[str, Any]: """Get token update data @@ -29,10 +29,10 @@ def updates( Args: - type (str): Update type page (int): Page number limit (int): Limit of data sort (str): Sort order + type (str): Update type Returns: Token update data in list of dictionary @@ -50,9 +50,9 @@ def updates( raise ValueError("type must be either listed or delisted when set") params = { - "type": type, "page": page, "limit": limit, + "type": type, "sort": sort, } diff --git a/datamaxi/datamaxi/cex_wallet_status.py b/datamaxi/datamaxi/cex_wallet_status.py index 3999145..4e49498 100644 --- a/datamaxi/datamaxi/cex_wallet_status.py +++ b/datamaxi/datamaxi/cex_wallet_status.py @@ -60,7 +60,7 @@ def __call__( def exchanges(self) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.CexWalletStatus.__call__](./#datamaxi.datamaxi.CexWalletStatus.__call__) + [datamaxi.CexWalletStatus.__call__](#datamaxi.datamaxi.CexWalletStatus.__call__) API. `GET /api/v1/wallet-status/exchanges` @@ -75,7 +75,7 @@ def exchanges(self) -> List[str]: def assets(self, exchange: str) -> List[str]: """Fetch supported assets accepted by - [datamaxi.CexWalletStatus.__call__](./#datamaxi.datamaxi.CexWalletStatus.__call__) + [datamaxi.CexWalletStatus.__call__](#datamaxi.datamaxi.CexWalletStatus.__call__) API. `GET /api/v1/wallet-status/assets` diff --git a/datamaxi/datamaxi/dex.py b/datamaxi/datamaxi/dex.py index 51e3e53..e041aaf 100644 --- a/datamaxi/datamaxi/dex.py +++ b/datamaxi/datamaxi/dex.py @@ -24,10 +24,10 @@ def trade( chain: str, exchange: str, pool: str, - page: int = 1, - limit: int = 1000, fromDateTime: str = None, toDateTime: str = None, + page: int = 1, + limit: int = 1000, sort: str = "desc", pandas: bool = True, ) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]: @@ -41,10 +41,10 @@ def trade( chain (str): Chain name exchange (str): Exchange name pool (str): Pool name - page (int): Page number - limit (int): Limit of data fromDateTime (str): Start date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") toDateTime (str): End date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") + page (int): Page number + limit (int): Limit of data sort (str): Sort order pandas (bool): Return data as pandas DataFrame @@ -114,10 +114,10 @@ def candle( exchange: str, pool: str, interval: str = "1d", - page: int = 1, - limit: int = 1000, fromDateTime: str = None, toDateTime: str = None, + page: int = 1, + limit: int = 1000, sort: str = "desc", pandas: bool = True, ) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]: @@ -132,10 +132,10 @@ def candle( exchange (str): Exchange name pool (str): Pool name interval (str): Candle interval - page (int): Page number - limit (int): Limit of data fromDateTime (str): Start date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") toDateTime (str): End date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") + page (int): Page number + limit (int): Limit of data sort (str): Sort order pandas (bool): Return data as pandas DataFrame @@ -203,103 +203,10 @@ def next_request(): else: return res, next_request - def liquidity( - self, - chain: str, - exchange: str, - pool: str, - page: int = 1, - limit: int = 1000, - fromDateTime: str = None, - toDateTime: str = None, - sort: str = "desc", - pandas: bool = True, - ) -> Union[Tuple[Dict, Callable], Tuple[pd.DataFrame, Callable]]: - """Fetch DEX liquidity data - - `GET /api/v1/dex/liquidity` - - - - Args: - chain (str): Chain name - exchange (str): Exchange name - pool (str): Pool name - page (int): Page number - limit (int): Limit of data - fromDateTime (str): Start date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") - toDateTime (str): End date and time (accepts format "2006-01-02 15:04:05" or "2006-01-02") - sort (str): Sort order - pandas (bool): Return data as pandas DataFrame - - Returns: - DEX liquidity data in pandas DataFrame and next request function - """ - logging.warning("warning: dex related endpoints are experimental") - - check_required_parameters( - [ - [chain, "chain"], - [exchange, "exchange"], - [pool, "pool"], - ] - ) - - if page < 1: - raise ValueError("page must be greater than 0") - - if limit < 1: - raise ValueError("limit must be greater than 0") - - if fromDateTime is not None and toDateTime is not None: - raise ValueError( - "fromDateTime and toDateTime cannot be set at the same time" - ) - - if sort not in [ASC, DESC]: - raise ValueError("sort must be either asc or desc") - - params = { - "chain": chain, - "exchange": exchange, - "pool": pool, - "page": page, - "limit": limit, - "from": fromDateTime, - "to": toDateTime, - "sort": sort, - } - - res = self.query("/api/v1/dex/liquidity", params) - if res["data"] is None or len(res["data"]) == 0: - raise ValueError("no data found") - - def next_request(): - return self.get( - chain, - exchange, - pool, - page + 1, - limit, - fromDateTime, - toDateTime, - sort, - pandas, - ) - - if pandas: - df = convert_data_to_data_frame( - res["data"], - ) - return df, next_request - else: - return res, next_request - def chains(self) -> List[str]: """Fetch supported chains accepted by - [datamaxi.Dex.candle](./#datamaxi.datamaxi.Dex.candle), - [datamaxi.Dex.trade](./#datamaxi.datamaxi.Dex.trade) and - [datamaxi.Dex.liquidity](./#datamaxi.datamaxi.Dex.liquidity). + [datamaxi.Dex.candle](#datamaxi.datamaxi.Dex.candle), + [datamaxi.Dex.trade](#datamaxi.datamaxi.Dex.trade). `GET /api/v1/dex/chains` @@ -315,9 +222,8 @@ def chains(self) -> List[str]: def exchanges(self) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.Dex.candle](./#datamaxi.datamaxi.Dex.candle), - [datamaxi.Dex.trade](./#datamaxi.datamaxi.Dex.trade) and - [datamaxi.Dex.liquidity](./#datamaxi.datamaxi.Dex.liquidity). + [datamaxi.Dex.candle](#datamaxi.datamaxi.Dex.candle), + [datamaxi.Dex.trade](#datamaxi.datamaxi.Dex.trade). `GET /api/v1/dex/exchanges` @@ -333,9 +239,8 @@ def exchanges(self) -> List[str]: def pools(self, exchange: str = None, chain: str = None) -> List[Dict]: """Fetch supported pools accepted by - [datamaxi.Dex.candle](./#datamaxi.datamaxi.Dex.candle), - [datamaxi.Dex.trade](./#datamaxi.datamaxi.Dex.trade) and - [datamaxi.Dex.liquidity](./#datamaxi.datamaxi.Dex.liquidity). + [datamaxi.Dex.candle](#datamaxi.datamaxi.Dex.candle), + [datamaxi.Dex.trade](#datamaxi.datamaxi.Dex.trade). `GET /api/v1/dex/pools` @@ -359,7 +264,7 @@ def pools(self, exchange: str = None, chain: str = None) -> List[Dict]: def intervals(self) -> List[str]: """Fetch supported intervals accepted by - [datamaxi.Dex.candle](./#datamaxi.datamaxi.Dex.candle). + [datamaxi.Dex.candle](#datamaxi.datamaxi.Dex.candle). `GET /api/v1/dex/intervals` diff --git a/datamaxi/datamaxi/forex.py b/datamaxi/datamaxi/forex.py index 3c3e619..e4cce60 100644 --- a/datamaxi/datamaxi/forex.py +++ b/datamaxi/datamaxi/forex.py @@ -52,7 +52,7 @@ def __call__( def symbols(self) -> List[str]: """Fetch supported symbols accepted by - [datamaxi.Forex.get](./#datamaxi.datamaxi.Forex.get) + [datamaxi.Forex.get](#datamaxi.datamaxi.Forex.get) API. `GET /api/v1/forex/symbols` diff --git a/datamaxi/datamaxi/funding_rate.py b/datamaxi/datamaxi/funding_rate.py index 34c248d..481c331 100644 --- a/datamaxi/datamaxi/funding_rate.py +++ b/datamaxi/datamaxi/funding_rate.py @@ -34,7 +34,7 @@ def history( `GET /api/v1/funding-rate` - + Args: exchange (str): Exchange name @@ -104,23 +104,23 @@ def next_request(): def latest( self, + exchange: str = None, + symbol: str = None, sort: str = None, limit: int = None, - symbol: str = None, - exchange: str = None, pandas: bool = True, ) -> Union[Tuple[List, Callable], Tuple[pd.DataFrame, Callable]]: """Fetch latest funding rate data `GET /api/v1/funding-rate/latest` - + Args: + exchange (str): exchange name + symbol (str): Symbol name sort (str): Sort data by `asc` or `desc` limit (int): Limit number of data to return - symbol (str): Symbol name - exchange (str): exchange name pandas (bool): Return data as pandas DataFrame Returns: @@ -128,18 +128,18 @@ def latest( """ params = {} + if exchange is not None: + params["exchange"] = exchange + + if symbol is not None: + params["symbol"] = symbol + if sort is not None: params["sort"] = sort if limit is not None: params["limit"] = limit - if symbol is not None: - params["symbol"] = symbol - - if exchange is not None: - params["exchange"] = exchange - res = self.query("/api/v1/funding-rate/latest", params) if pandas: @@ -151,12 +151,12 @@ def latest( def exchanges(self) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.FundingRate.get](./#datamaxi.datamaxi.FundingRate.get) + [datamaxi.FundingRate.get](#datamaxi.datamaxi.FundingRate.get) API. `GET /api/v1/funding-rate/exchanges` - + Returns: List of supported exchanges @@ -166,12 +166,12 @@ def exchanges(self) -> List[str]: def symbols(self, exchange: str, market: str = "spot") -> List[str]: """Fetch supported symbols accepted by - [datamaxi.FundingRate.get](./#datamaxi.datamaxi.FundingRate.get) + [datamaxi.FundingRate.get](#datamaxi.datamaxi.FundingRate.get) API. `GET /api/v1/funding-rate/symbols` - + Args: exchange (str): Exchange name diff --git a/datamaxi/datamaxi/premium.py b/datamaxi/datamaxi/premium.py index 9bf8cfd..52efb88 100644 --- a/datamaxi/datamaxi/premium.py +++ b/datamaxi/datamaxi/premium.py @@ -30,6 +30,58 @@ def __call__( # noqa: C901 page: int = 1, limit: int = 100, currency: str = None, + conversion_base: str = None, + min_pd: str = None, + max_pd: str = None, + min_pdp: str = None, + max_pdp: str = None, + min_pdp24h: str = None, + max_pdp24h: str = None, + min_pdp4h: str = None, + max_pdp4h: str = None, + min_pdp1h: str = None, + max_pdp1h: str = None, + min_pdp30m: str = None, + max_pdp30m: str = None, + min_pdp15m: str = None, + max_pdp15m: str = None, + min_pdp5m: str = None, + max_pdp5m: str = None, + min_dsp: str = None, + max_dsp: str = None, + min_dtp: str = None, + max_dtp: str = None, + min_spdp24h: str = None, + max_spdp24h: str = None, + min_spdp4h: str = None, + max_spdp4h: str = None, + min_spdp1h: str = None, + max_spdp1h: str = None, + min_spdp30m: str = None, + max_spdp30m: str = None, + min_spdp15m: str = None, + max_spdp15m: str = None, + min_spdp5m: str = None, + max_spdp5m: str = None, + min_sv: str = None, + max_sv: str = None, + min_tv: str = None, + max_tv: str = None, + min_net_funding_rate: str = None, + max_net_funding_rate: str = None, + min_source_funding_rate: str = None, + max_source_funding_rate: str = None, + min_target_funding_rate: str = None, + max_target_funding_rate: str = None, + source_market: str = None, + target_market: str = None, + only_transferable: bool = False, + network: str = None, + source_funding_rate_interval: str = None, + target_funding_rate_interval: str = None, + premium_type: str = None, + token_include: str = None, + token_exclude: str = None, pandas: bool = True, ) -> Union[List, pd.DataFrame]: """Fetch premium data @@ -43,11 +95,65 @@ def __call__( # noqa: C901 asset (str): Asset name source_quote (str): Source quote currency target_quote (str): Target quote currency - currency (str): Currency applied to cross-exchange price differences sort (str): Sort data by `asc` or `desc` key (str): Key to sort data page (int): Page number limit (int): Page size + currency (str): Currency applied to cross-exchange price differences + conversion_base (str): conversion base for price difference calculation + + min_pd (str): Return results with price difference in USD above min_pd + max_pd (str): Return results with price difference in USD below max_pd + min_pdp (str): Return results with price difference percentage above min_pdp + max_pdp (str): Return results with price difference percentage below max_pdp + min_pdp24h (str): Return results with price difference percentage from 24h ago above min_pdp24h + max_pdp24h (str): Return results with price difference percentage from 24h ago below max_pdp24h + min_pdp4h (str): Return results with price difference percentage from 4h ago above min_pdp4h + max_pdp4h (str): Return results with price difference percentage from 4h ago below max_pdp4h + min_pdp1h (str): Return results with price difference percentage from 1h ago above min_pdp1h + max_pdp1h (str): Return results with price difference percentage from 1h ago below max_pdp1h + min_pdp30m (str): Return results with price difference percentage from 30m ago above min_pdp30m + max_pdp30m (str): Return results with price difference percentage from 30m ago below max_pdp30m + min_pdp15m (str): Return results with price difference percentage from 15m ago above min_pdp15m + max_pdp15m (str): Return results with price difference percentage from 15m ago below max_pdp15m + min_pdp5m (str): Return results with price difference percentage from 5m ago above min_pdp5m + max_pdp5m (str): Return results with price difference percentage from 5m ago below max_pdp5m + min_dsp (str): Return results with price in fiat on source exchange above min_dsp + max_dsp (str): Return results with price in fiat on source exchange below max_dsp + min_dtp (str): Return results with price in fiat on target exchange above min_dtp + max_dtp (str): Return results with price in fiat on target exchange below max_dtp + min_spdp24h (str): Return results with price difference percentage (between now and 24h ago on source exchange) above min_spdp24h + max_spdp24h (str): Return results with price difference percentage (between now and 24h ago on source exchange) below max_spdp24h + min_spdp4h (str): Return results with price difference percentage (between now and 4h ago on source exchange) above min_spdp4h + max_spdp4h (str): Return results with price difference percentage (between now and 4h ago on source exchange) below max_spdp4h + min_spdp1h (str): Return results with price difference percentage (between now and 1h ago on source exchange) above min_spdp1h + max_spdp1h (str): Return results with price difference percentage (between now and 1h ago on source exchange) below max_spdp1h + min_spdp30m (str): Return results with price difference percentage (between now and 30m ago on source exchange) above min_spdp30m + max_spdp30m (str): Return results with price difference percentage (between now and 30m ago on source exchange) below max_spdp30m + min_spdp15m (str): Return results with price difference percentage (between now and 15m ago on source exchange) above min_spdp15m + max_spdp15m (str): Return results with price difference percentage (between now and 15m ago on source exchange) below max_spdp15m + min_spdp5m (str): Return results with price difference percentage (between now and 5m ago on source exchange) above min_spdp5m + max_spdp5m (str): Return results with price difference percentage (between now and 5m ago on source exchange) below max_spdp5m + min_sv (str): Return results with 24h volume in fiat on source exchange above min_sv + max_sv (str): Return results with 24h volume in fiat on source exchange below max_sv + min_tv (str): Return results with 24h volume in fiat on target exchange above min_tv + max_tv (str): Return results with 24h volume in fiat on target exchange below max_tv + min_net_funding_rate (str): Return results with net funding rate above min_net_funding_rate + max_net_funding_rate (str): Return results with net funding rate below max_net_funding_rate + min_source_funding_rate (str): Return results with source funding rate above min_source_funding_rate + max_source_funding_rate (str): Return results with source funding rate below max_source_funding_rate + min_target_funding_rate (str): Return results with target funding rate above min_target_funding_rate + max_target_funding_rate (str): Return results with target funding rate below max_target_funding_rate + source_market (str): Return results matching source market + target_market (str): Return results matching target market + only_transferable (bool): Return only transferable if set true + network (str): Return results containing only specified network + source_funding_rate_interval (str): Return results with min source funding rate interval + target_funding_rate_interval (str): Return results with min target funding rate interval + premium_type (str): Return based on matching premium_type + token_include (str): Return results containing only specified token + token_exclude (str): Return results not containing specified token + pandas (bool): Return data as pandas DataFrame Returns: @@ -73,32 +179,200 @@ def __call__( # noqa: C901 if sort is not None: params["sort"] = sort - if page is not None: - params["page"] = page - if key is not None: params["key"] = key + if page is not None: + params["page"] = page + if limit is not None: params["limit"] = limit if currency is not None: params["currency"] = currency + if conversion_base is not None: + params["conversion_base"] = conversion_base + + if min_pd is not None: + params["min_pd"] = min_pd + + if max_pd is not None: + params["max_pd"] = max_pd + + if min_pdp is not None: + params["min_pdp"] = min_pdp + + if max_pdp is not None: + params["max_pdp"] = max_pdp + + if min_pdp24h is not None: + params["min_pdp24h"] = min_pdp24h + + if max_pdp24h is not None: + params["max_pdp24h"] = max_pdp24h + + if min_pdp4h is not None: + params["min_pdp4h"] = min_pdp4h + + if max_pdp4h is not None: + params["max_pdp4h"] = max_pdp4h + + if min_pdp1h is not None: + params["min_pdp1h"] = min_pdp1h + + if max_pdp1h is not None: + params["max_pdp1h"] = max_pdp1h + + if min_pdp30m is not None: + params["min_pdp30m"] = min_pdp30m + + if max_pdp30m is not None: + params["max_pdp30m"] = max_pdp30m + + if min_pdp15m is not None: + params["min_pdp15m"] = min_pdp15m + + if max_pdp15m is not None: + params["max_pdp15m"] = max_pdp15m + + if min_pdp5m is not None: + params["min_pdp5m"] = min_pdp5m + + if max_pdp5m is not None: + params["max_pdp5m"] = max_pdp5m + + if min_dsp is not None: + params["min_dsp"] = min_dsp + + if max_dsp is not None: + params["max_dsp"] = max_dsp + + if min_dtp is not None: + params["min_dtp"] = min_dtp + + if max_dtp is not None: + params["max_dtp"] = max_dtp + + if min_spdp24h is not None: + params["min_spdp24h"] = min_spdp24h + + if max_spdp24h is not None: + params["max_spdp24h"] = max_spdp24h + + if min_spdp4h is not None: + params["min_spdp4h"] = min_spdp4h + + if max_spdp4h is not None: + params["max_spdp4h"] = max_spdp4h + + if min_spdp1h is not None: + params["min_spdp1h"] = min_spdp1h + + if max_spdp1h is not None: + params["max_spdp1h"] = max_spdp1h + + if min_spdp30m is not None: + params["min_spdp30m"] = min_spdp30m + + if max_spdp30m is not None: + params["max_spdp30m"] = max_spdp30m + + if min_spdp15m is not None: + params["min_spdp15m"] = min_spdp15m + + if max_spdp15m is not None: + params["max_spdp15m"] = max_spdp15m + + if min_spdp5m is not None: + params["min_spdp5m"] = min_spdp5m + + if max_spdp5m is not None: + params["max_spdp5m"] = max_spdp5m + + if min_sv is not None: + params["min_sv"] = min_sv + + if max_sv is not None: + params["max_sv"] = max_sv + + if min_tv is not None: + params["min_tv"] = min_tv + + if max_tv is not None: + params["max_tv"] = max_tv + + if min_net_funding_rate is not None: + params["min_net_funding_rate"] = min_net_funding_rate + + if max_net_funding_rate is not None: + params["max_net_funding_rate"] = max_net_funding_rate + + if min_source_funding_rate is not None: + params["min_source_funding_rate"] = min_source_funding_rate + + if max_source_funding_rate is not None: + params["max_source_funding_rate"] = max_source_funding_rate + + if min_target_funding_rate is not None: + params["min_target_funding_rate"] = min_target_funding_rate + + if max_target_funding_rate is not None: + params["max_target_funding_rate"] = max_target_funding_rate + + if source_market is not None: + params["source_market"] = source_market + + if target_market is not None: + params["target_market"] = target_market + + if only_transferable: + params["only_transferable"] = True + + if network is not None: + params["network"] = network + + if source_funding_rate_interval is not None: + params["source_funding_rate_interval"] = source_funding_rate_interval + + if target_funding_rate_interval is not None: + params["target_funding_rate_interval"] = target_funding_rate_interval + + if premium_type is not None: + params["premium_type"] = premium_type + + if token_include is not None: + params["token_include"] = token_include + + if token_exclude is not None: + params["token_exclude"] = token_exclude + res = self.query("/api/v1/premium", params) if res["data"] is None or len(res["data"]) == 0: raise ValueError("no data found") if pandas: - df = pd.DataFrame(res["data"]) - df = df.set_index("d") + df = pd.DataFrame( + [ + { + **item["detail"], + "source_annualized_funding_rate": item.get( + "source_annualized_funding_rate" + ), + "target_annualized_funding_rate": item.get( + "target_annualized_funding_rate" + ), + } + for item in res["data"] + ] + ) return df else: return res def exchanges(self) -> List[str]: """Fetch supported exchanges accepted by - [datamaxi.Premium.get](./#datamaxi.datamaxi.Premium.get) + [datamaxi.Premium.get](#datamaxi.datamaxi.Premium.get) API. `GET /api/v1/Premium/exchanges` diff --git a/datamaxi/lib/utils.py b/datamaxi/lib/utils.py index 2e41ba3..b9c9997 100644 --- a/datamaxi/lib/utils.py +++ b/datamaxi/lib/utils.py @@ -111,7 +111,6 @@ def wrapper(*arg, **kwarg): if not kwarg.get("pandas", True): return res - if isinstance(res, dict): res["data"] = _postprocess(res["data"], res["data"][0][:num_index]) else: diff --git a/datamaxi/naver/__init__.py b/datamaxi/naver/__init__.py index a5a2b5d..c249f5d 100644 --- a/datamaxi/naver/__init__.py +++ b/datamaxi/naver/__init__.py @@ -3,7 +3,6 @@ from datamaxi.api import API from datamaxi.lib.utils import check_required_parameter from datamaxi.lib.constants import BASE_URL -from datamaxi.lib.utils import postprocess class Naver(API): @@ -23,23 +22,22 @@ def __init__(self, api_key=None, **kwargs: Any): def symbols(self) -> List[str]: """Get Naver trend supported token symbols - `GET /api/v1/naver/symbols` + `GET /api/v1/naver-trend/symbols` Returns: List of supported Naver trend token symbols """ - url_path = "/api/v1/naver/symbols" + url_path = "/api/v1/naver-trend/symbols" return self.query(url_path) - @postprocess() def trend(self, symbol: str, pandas: bool = True) -> Union[List, pd.DataFrame]: """Get Naver trend for given token symbol - `GET /api/v1/naver/trend` + `GET /api/v1/naver-trend` - + Args: symbol (str): token symbol to search for @@ -50,4 +48,4 @@ def trend(self, symbol: str, pandas: bool = True) -> Union[List, pd.DataFrame]: """ check_required_parameter(symbol, "symbol") params = {"symbol": symbol} - return self.query("/api/v1/naver/trend", params) + return self.query("/api/v1/naver-trend", params) diff --git a/datamaxi/telegram/__init__.py b/datamaxi/telegram/__init__.py index 4c3049f..b5ca348 100644 --- a/datamaxi/telegram/__init__.py +++ b/datamaxi/telegram/__init__.py @@ -19,9 +19,10 @@ def __init__(self, api_key=None, **kwargs: Any): def channels( self, - category: Optional[str] = None, page: int = 1, limit: int = 1000, + category: Optional[str] = None, + key: Optional[str] = None, sort: str = "desc", ) -> Dict[str, Any]: """Get Telegram supported channels @@ -31,9 +32,10 @@ def channels( Args: - category (str): channel category page (int): Page number limit (int): Limit of data + category (str): channel category + key (str): Specifies key to sort by sort (str): Sort order Returns: @@ -49,9 +51,10 @@ def channels( raise ValueError("sort must be either asc or desc") params = { - "category": category, "page": page, "limit": limit, + "category": category, + "key": key, "sort": sort, } @@ -69,24 +72,28 @@ def next_request(): return res, next_request - def posts( + def messages( self, channel_name: Optional[str] = None, page: int = 1, limit: int = 1000, + key: Optional[str] = None, sort: str = "desc", + category: Optional[str] = None, ) -> Dict[str, Any]: """Get Telegram posts for given channel username - `GET /api/v1/telegram/posts` + `GET /api/v1/telegram/messages` - + Args: channel_name (str): channel name to get posts from page (int): Page number limit (int): Limit of data + key (str): Specifies key to sort by sort (str): Sort order + category (str): Specifies category Returns: Telegram channel posts @@ -104,10 +111,12 @@ def posts( "channel": channel_name, "page": page, "limit": limit, + "key": key, "sort": sort, + "category": category, } - res = self.query("/api/v1/telegram/posts", params) + res = self.query("/api/v1/telegram/messages", params) if res["data"] is None: raise ValueError("no data found") diff --git a/pyproject.toml b/pyproject.toml index 9b47c87..a24d0fd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "datamaxi" -version = "0.25.0" +version = "0.26.0" authors = [ { name="Bisonai", email="business@bisonai.com" }, ] diff --git a/tests/test_call.py b/tests/test_call.py index 474813c..7016b17 100644 --- a/tests/test_call.py +++ b/tests/test_call.py @@ -1,6 +1,8 @@ import os import logging from datamaxi import Datamaxi +from datamaxi import Telegram +from datamaxi import Naver logging.basicConfig(level=logging.INFO) @@ -9,6 +11,8 @@ base_url = os.getenv("BASE_URL") or "https://api.datamaxiplus.com" datamaxi = Datamaxi(api_key=api_key, base_url=base_url) +telegram = Telegram(api_key=api_key, base_url=base_url) +naver = Naver(api_key=api_key, base_url=base_url) def test_cex_candle(): @@ -63,17 +67,7 @@ def test_dex(): datamaxi.dex.trade( exchange="pancakeswap", chain="bsc_mainnet", - pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", - ) - datamaxi.dex.liquidity( - exchange="pancakeswap", - chain="bsc_mainnet", - pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", - ) - datamaxi.dex.trade( - exchange="pancakeswap", - chain="bsc_mainnet", - pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423", + pool="0x6ee3eE9C3395BbD136B6076A70Cb6cFF241c0E24", # btc-usdt pool ) @@ -85,3 +79,13 @@ def test_forex(): def test_premium(): datamaxi.premium() datamaxi.premium.exchanges() + + +def test_telegram(): + telegram.channels() + telegram.messages() + + +def test_naver(): + naver.symbols() + naver.trend("BTC")