diff --git a/binance/async_client.py b/binance/async_client.py index 3a73e6803..b1391fa85 100644 --- a/binance/async_client.py +++ b/binance/async_client.py @@ -403,6 +403,11 @@ async def aggregate_trade_iter(self, symbol, start_str=None, last_id=None): aggregate_trade_iter.__doc__ = Client.aggregate_trade_iter.__doc__ + async def get_ui_klines(self, **params) -> Dict: + return await self._get("uiKlines", data=params, version=self.PRIVATE_API_VERSION) + + get_ui_klines.__doc__ = Client.get_ui_klines.__doc__ + async def get_klines(self, **params) -> Dict: return await self._get("klines", data=params, version=self.PRIVATE_API_VERSION) diff --git a/binance/client.py b/binance/client.py index 2c9a5233e..1f36fdd41 100755 --- a/binance/client.py +++ b/binance/client.py @@ -650,6 +650,48 @@ def aggregate_trade_iter(self, symbol: str, start_str=None, last_id=None): yield t last_id = trades[-1][self.AGG_ID] + def get_ui_klines(self, **params) -> Dict: + """Kline/candlestick bars for a symbol with UI enhancements. Klines are uniquely identified by their open time. + + https://developers.binance.com/docs/binance-spot-api-docs/rest-api/market-data-endpoints#uiklines + + :param symbol: required + :type symbol: str + :param interval: required - The interval for the klines (e.g., 1m, 3m, 5m, etc.) + :type interval: str + :param limit: optional - Default 500; max 1000. + :type limit: int + :param startTime: optional - Start time in milliseconds + :type startTime: int + :param endTime: optional - End time in milliseconds + :type endTime: int + + :returns: API response + + .. code-block:: python + + [ + [ + 1499040000000, # Open time + "0.01634790", # Open + "0.80000000", # High + "0.01575800", # Low + "0.01577100", # Close + "148976.11427815", # Volume + 1499644799999, # Close time + "2434.19055334", # Quote asset volume + 308, # Number of trades + "1756.87402397", # Taker buy base asset volume + "28.46694368", # Taker buy quote asset volume + "17928899.62484339" # Can be ignored + ] + ] + + :raises: BinanceRequestException, BinanceAPIException + + """ + return self._get("uiKlines", data=params, version=self.PRIVATE_API_VERSION) + def get_klines(self, **params) -> Dict: """Kline/candlestick bars for a symbol. Klines are uniquely identified by their open time. diff --git a/tests/test_async_client.py b/tests/test_async_client.py index 3cbbb7dda..22eb6f9f6 100644 --- a/tests/test_async_client.py +++ b/tests/test_async_client.py @@ -60,6 +60,10 @@ async def test_get_klines(clientAsync): await clientAsync.get_klines(symbol="BTCUSDT", interval="1d") +async def test_get_uiklines(clientAsync): + await clientAsync.get_ui_klines(symbol="BTCUSDT", interval="1d") + + async def test_futures_mark_price_klines(clientAsync): await clientAsync.futures_mark_price_klines(symbol="BTCUSDT", interval="1h") diff --git a/tests/test_client.py b/tests/test_client.py index 2f92c6861..52194e0f0 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -56,6 +56,8 @@ def test_get_aggregate_trades(client): def test_get_klines(client): client.get_klines(symbol="BTCUSDT", interval="1d") +def test_get_ui_klines(client): + client.get_ui_klines(symbol="BTCUSDT", interval="1d") def test_get_avg_price(client): client.get_avg_price(symbol="BTCUSDT")