python-binance 1.0.26__tar.gz → 1.0.27__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {python_binance-1.0.26/python_binance.egg-info → python_binance-1.0.27}/PKG-INFO +2 -2
  2. {python_binance-1.0.26 → python_binance-1.0.27}/README.rst +1 -1
  3. {python_binance-1.0.26 → python_binance-1.0.27}/binance/__init__.py +4 -2
  4. {python_binance-1.0.26 → python_binance-1.0.27}/binance/async_client.py +136 -1
  5. {python_binance-1.0.26 → python_binance-1.0.27}/binance/base_client.py +14 -0
  6. {python_binance-1.0.26 → python_binance-1.0.27}/binance/client.py +2176 -55
  7. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/keepalive_websocket.py +21 -9
  8. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/reconnecting_websocket.py +2 -3
  9. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/streams.py +28 -3
  10. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/threaded_stream.py +15 -5
  11. {python_binance-1.0.26 → python_binance-1.0.27/python_binance.egg-info}/PKG-INFO +2 -2
  12. {python_binance-1.0.26 → python_binance-1.0.27}/python_binance.egg-info/SOURCES.txt +2 -0
  13. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client.py +23 -0
  14. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_futures.py +29 -8
  15. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client.py +30 -0
  16. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_futures.py +21 -8
  17. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_ws_api.py +30 -0
  18. python_binance-1.0.27/tests/test_init.py +55 -0
  19. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_reconnecting_websocket.py +7 -1
  20. python_binance-1.0.27/tests/test_streams.py +91 -0
  21. python_binance-1.0.27/tests/test_threaded_stream.py +193 -0
  22. python_binance-1.0.26/tests/test_streams.py +0 -15
  23. {python_binance-1.0.26 → python_binance-1.0.27}/LICENSE +0 -0
  24. {python_binance-1.0.26 → python_binance-1.0.27}/binance/enums.py +0 -0
  25. {python_binance-1.0.26 → python_binance-1.0.27}/binance/exceptions.py +0 -0
  26. {python_binance-1.0.26 → python_binance-1.0.27}/binance/helpers.py +0 -0
  27. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/__init__.py +0 -0
  28. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/constants.py +0 -0
  29. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/depthcache.py +0 -0
  30. {python_binance-1.0.26 → python_binance-1.0.27}/binance/ws/websocket_api.py +0 -0
  31. {python_binance-1.0.26 → python_binance-1.0.27}/pyproject.toml +0 -0
  32. {python_binance-1.0.26 → python_binance-1.0.27}/python_binance.egg-info/dependency_links.txt +0 -0
  33. {python_binance-1.0.26 → python_binance-1.0.27}/python_binance.egg-info/requires.txt +0 -0
  34. {python_binance-1.0.26 → python_binance-1.0.27}/python_binance.egg-info/top_level.txt +0 -0
  35. {python_binance-1.0.26 → python_binance-1.0.27}/setup.cfg +0 -0
  36. {python_binance-1.0.26 → python_binance-1.0.27}/setup.py +0 -0
  37. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_api_request.py +0 -0
  38. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_gift_card copy.py +0 -0
  39. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_margin.py +0 -0
  40. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_options.py +0 -0
  41. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_portfolio.py +0 -0
  42. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_ws_api.py +0 -0
  43. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_async_client_ws_futures_requests.py +0 -0
  44. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_gift_card.py +0 -0
  45. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_margin.py +0 -0
  46. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_options.py +0 -0
  47. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_portfolio.py +0 -0
  48. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_client_ws_futures_requests.py +0 -0
  49. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_cryptography.py +0 -0
  50. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_depth_cache.py +0 -0
  51. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_futures.py +0 -0
  52. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_get_order_book.py +0 -0
  53. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_headers.py +0 -0
  54. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_historical_klines.py +0 -0
  55. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_ids.py +0 -0
  56. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_order.py +0 -0
  57. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_ping.py +0 -0
  58. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_socket_manager.py +0 -0
  59. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_threaded_socket_manager.py +0 -0
  60. {python_binance-1.0.26 → python_binance-1.0.27}/tests/test_ws_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-binance
3
- Version: 1.0.26
3
+ Version: 1.0.27
4
4
  Summary: Binance REST API python implementation
5
5
  Home-page: https://github.com/sammchardy/python-binance
6
6
  Author: Sam McHardy
@@ -31,7 +31,7 @@ Requires-Dist: websockets
31
31
  Requires-Dist: pycryptodome
32
32
 
33
33
  =================================
34
- Welcome to python-binance v1.0.26
34
+ Welcome to python-binance v1.0.27
35
35
  =================================
36
36
 
37
37
  .. image:: https://img.shields.io/pypi/v/python-binance.svg
@@ -1,5 +1,5 @@
1
1
  =================================
2
- Welcome to python-binance v1.0.26
2
+ Welcome to python-binance v1.0.27
3
3
  =================================
4
4
 
5
5
  .. image:: https://img.shields.io/pypi/v/python-binance.svg
@@ -4,7 +4,7 @@
4
4
 
5
5
  """
6
6
 
7
- __version__ = "1.0.26"
7
+ __version__ = "1.0.27"
8
8
 
9
9
  from binance.async_client import AsyncClient # noqa
10
10
  from binance.client import Client # noqa
@@ -12,6 +12,8 @@ from binance.ws.depthcache import (
12
12
  DepthCacheManager, # noqa
13
13
  OptionsDepthCacheManager, # noqa
14
14
  ThreadedDepthCacheManager, # noqa
15
+ FuturesDepthCacheManager, # noqa
16
+ OptionsDepthCacheManager, # noqa
15
17
  )
16
18
  from binance.ws.streams import (
17
19
  BinanceSocketManager, # noqa
@@ -23,7 +25,7 @@ from binance.ws.keepalive_websocket import KeepAliveWebsocket # noqa
23
25
 
24
26
  from binance.ws.reconnecting_websocket import ReconnectingWebsocket # noqa
25
27
 
26
- from binance.ws.constants import * # noqa
28
+ from binance.ws.constants import * # noqa
27
29
 
28
30
  from binance.exceptions import * # noqa
29
31
 
@@ -36,6 +36,7 @@ class AsyncClient(BaseClient):
36
36
  private_key: Optional[Union[str, Path]] = None,
37
37
  private_key_pass: Optional[str] = None,
38
38
  https_proxy: Optional[str] = None,
39
+ time_unit: Optional[str] = None,
39
40
  ):
40
41
  self.https_proxy = https_proxy
41
42
  self.loop = loop or get_loop()
@@ -49,6 +50,7 @@ class AsyncClient(BaseClient):
49
50
  testnet,
50
51
  private_key,
51
52
  private_key_pass,
53
+ time_unit=time_unit,
52
54
  )
53
55
 
54
56
  @classmethod
@@ -128,10 +130,25 @@ class AsyncClient(BaseClient):
128
130
  uri = f"{uri}?{kwargs['params']}"
129
131
  kwargs.pop("params")
130
132
 
133
+ data = kwargs.get("data")
134
+ if data is not None:
135
+ del kwargs["data"]
136
+
137
+ if (
138
+ signed and self.PRIVATE_KEY and data
139
+ ): # handle issues with signing using eddsa/rsa and POST requests
140
+ dict_data = Client.convert_to_dict(data)
141
+ signature = dict_data["signature"] if "signature" in dict_data else None
142
+ if signature:
143
+ del dict_data["signature"]
144
+ url_encoded_data = urlencode(dict_data)
145
+ data = f"{url_encoded_data}&signature={signature}"
146
+
131
147
  async with getattr(self.session, method)(
132
148
  yarl.URL(uri, encoded=True),
133
149
  proxy=self.https_proxy,
134
150
  headers=headers,
151
+ data=data,
135
152
  **kwargs,
136
153
  ) as response:
137
154
  self.response = response
@@ -1736,6 +1753,11 @@ class AsyncClient(BaseClient):
1736
1753
  return await self._request_futures_data_api(
1737
1754
  "get", "globalLongShortAccountRatio", data=params
1738
1755
  )
1756
+
1757
+ async def futures_taker_longshort_ratio(self, **params):
1758
+ return await self._request_futures_data_api(
1759
+ "get", "takerlongshortRatio", data=params
1760
+ )
1739
1761
 
1740
1762
  async def futures_ticker(self, **params):
1741
1763
  return await self._request_futures_api("get", "ticker/24hr", data=params)
@@ -1746,6 +1768,13 @@ class AsyncClient(BaseClient):
1746
1768
  async def futures_orderbook_ticker(self, **params):
1747
1769
  return await self._request_futures_api("get", "ticker/bookTicker", data=params)
1748
1770
 
1771
+ async def futures_index_price_constituents(self, **params):
1772
+ return await self._request_futures_api("get", "constituents", data=params)
1773
+
1774
+ futures_index_price_constituents.__doc__ = (
1775
+ Client.futures_index_price_constituents.__doc__
1776
+ )
1777
+
1749
1778
  async def futures_liquidation_orders(self, **params):
1750
1779
  return await self._request_futures_api(
1751
1780
  "get", "forceOrders", signed=True, data=params
@@ -2043,6 +2072,13 @@ class AsyncClient(BaseClient):
2043
2072
  "get", "ticker/bookTicker", data=params
2044
2073
  )
2045
2074
 
2075
+ async def futures_coin_index_price_constituents(self, **params):
2076
+ return await self._request_futures_coin_api("get", "constituents", data=params)
2077
+
2078
+ futures_coin_index_price_constituents.__doc__ = (
2079
+ Client.futures_coin_index_price_constituents.__doc__
2080
+ )
2081
+
2046
2082
  async def futures_coin_liquidation_orders(self, **params):
2047
2083
  return await self._request_futures_coin_api(
2048
2084
  "get", "forceOrders", signed=True, data=params
@@ -2427,6 +2463,28 @@ class AsyncClient(BaseClient):
2427
2463
  ====================================================================================================================
2428
2464
  """
2429
2465
 
2466
+ async def papi_stream_get_listen_key(self):
2467
+ res = await self._request_papi_api("post", "listenKey", signed=False, data={})
2468
+ return res["listenKey"]
2469
+
2470
+ papi_stream_get_listen_key.__doc__ = Client.papi_stream_get_listen_key.__doc__
2471
+
2472
+ async def papi_stream_keepalive(self, listenKey):
2473
+ params = {"listenKey": listenKey}
2474
+ return await self._request_papi_api(
2475
+ "put", "listenKey", signed=False, data=params
2476
+ )
2477
+
2478
+ papi_stream_keepalive.__doc__ = Client.papi_stream_keepalive.__doc__
2479
+
2480
+ async def papi_stream_close(self, listenKey):
2481
+ params = {"listenKey": listenKey}
2482
+ return await self._request_papi_api(
2483
+ "delete", "listenKey", signed=False, data=params
2484
+ )
2485
+
2486
+ papi_stream_close.__doc__ = Client.papi_stream_close.__doc__
2487
+
2430
2488
  async def papi_get_balance(self, **params):
2431
2489
  return await self._request_papi_api("get", "balance", signed=True, data=params)
2432
2490
 
@@ -3523,7 +3581,7 @@ class AsyncClient(BaseClient):
3523
3581
  async def ws_cancel_order(self, **params):
3524
3582
  return await self._ws_api_request("order.cancel", True, params)
3525
3583
 
3526
- cancel_order.__doc__ = cancel_order.__doc__
3584
+ ws_cancel_order.__doc__ = Client.ws_cancel_order.__doc__
3527
3585
 
3528
3586
  async def cancel_all_open_orders(self, **params):
3529
3587
  return await self._delete("openOrders", True, data=params)
@@ -3533,105 +3591,173 @@ class AsyncClient(BaseClient):
3533
3591
  params["newClientOrderId"] = self.SPOT_ORDER_PREFIX + self.uuid22()
3534
3592
  return await self._post("order/cancelReplace", signed=True, data=params)
3535
3593
 
3594
+ cancel_replace_order.__doc__ = Client.cancel_replace_order.__doc__
3595
+
3536
3596
  async def ws_cancel_and_replace_order(self, **params):
3537
3597
  return await self._ws_api_request("order.cancelReplace", True, params)
3538
3598
 
3599
+ ws_cancel_and_replace_order.__doc__ = Client.ws_cancel_and_replace_order.__doc__
3600
+
3539
3601
  async def ws_get_open_orders(self, **params):
3540
3602
  return await self._ws_api_request("openOrders.status", True, params)
3541
3603
 
3604
+ ws_get_open_orders.__doc__ = Client.ws_get_open_orders.__doc__
3605
+
3542
3606
  async def ws_cancel_all_open_orders(self, **params):
3543
3607
  return await self._ws_api_request("openOrders.cancelAll", True, params)
3544
3608
 
3609
+ ws_cancel_all_open_orders.__doc__ = Client.ws_cancel_all_open_orders.__doc__
3610
+
3545
3611
  async def ws_create_oco_order(self, **params):
3546
3612
  return await self._ws_api_request("orderList.place.oco", True, params)
3547
3613
 
3614
+ ws_create_oco_order.__doc__ = Client.ws_create_oco_order.__doc__
3615
+
3548
3616
  async def ws_create_oto_order(self, **params):
3549
3617
  return await self._ws_api_request("orderList.place.oto", True, params)
3550
3618
 
3619
+ ws_create_oto_order.__doc__ = Client.ws_create_oto_order.__doc__
3620
+
3551
3621
  async def ws_create_otoco_order(self, **params):
3552
3622
  return await self._ws_api_request("orderList.place.otoco", True, params)
3553
3623
 
3624
+ ws_create_otoco_order.__doc__ = Client.ws_create_otoco_order.__doc__
3625
+
3554
3626
  async def ws_get_oco_order(self, **params):
3555
3627
  return await self._ws_api_request("orderList.status", True, params)
3556
3628
 
3629
+ ws_get_oco_order.__doc__ = Client.ws_get_oco_order.__doc__
3630
+
3557
3631
  async def ws_cancel_oco_order(self, **params):
3558
3632
  return await self._ws_api_request("orderList.cancel", True, params)
3559
3633
 
3634
+ ws_cancel_oco_order.__doc__ = Client.ws_cancel_oco_order.__doc__
3635
+
3560
3636
  async def ws_get_oco_open_orders(self, **params):
3561
3637
  return await self._ws_api_request("openOrderLists.status", True, params)
3562
3638
 
3639
+ ws_get_oco_open_orders.__doc__ = Client.ws_get_oco_open_orders.__doc__
3640
+
3563
3641
  async def ws_create_sor_order(self, **params):
3564
3642
  return await self._ws_api_request("sor.order.place", True, params)
3565
3643
 
3644
+ ws_create_sor_order.__doc__ = Client.ws_create_sor_order.__doc__
3645
+
3566
3646
  async def ws_create_test_sor_order(self, **params):
3567
3647
  return await self._ws_api_request("sor.order.test", True, params)
3568
3648
 
3649
+ ws_create_test_sor_order.__doc__ = Client.ws_create_test_sor_order.__doc__
3650
+
3569
3651
  async def ws_get_account(self, **params):
3570
3652
  return await self._ws_api_request("account.status", True, params)
3571
3653
 
3654
+ ws_get_account.__doc__ = Client.ws_get_account.__doc__
3655
+
3572
3656
  async def ws_get_account_rate_limits_orders(self, **params):
3573
3657
  return await self._ws_api_request("account.rateLimits.orders", True, params)
3574
3658
 
3659
+ ws_get_account_rate_limits_orders.__doc__ = Client.ws_get_account_rate_limits_orders.__doc__
3660
+
3575
3661
  async def ws_get_all_orders(self, **params):
3576
3662
  return await self._ws_api_request("allOrders", True, params)
3577
3663
 
3664
+ ws_get_all_orders.__doc__ = Client.ws_get_all_orders.__doc__
3665
+
3578
3666
  async def ws_get_my_trades(self, **params):
3579
3667
  return await self._ws_api_request("myTrades", True, params)
3580
3668
 
3669
+ ws_get_my_trades.__doc__ = Client.ws_get_my_trades.__doc__
3670
+
3581
3671
  async def ws_get_prevented_matches(self, **params):
3582
3672
  return await self._ws_api_request("myPreventedMatches", True, params)
3583
3673
 
3674
+ ws_get_prevented_matches.__doc__ = Client.ws_get_prevented_matches.__doc__
3675
+
3584
3676
  async def ws_get_allocations(self, **params):
3585
3677
  return await self._ws_api_request("myAllocations", True, params)
3586
3678
 
3679
+ ws_get_allocations.__doc__ = Client.ws_get_allocations.__doc__
3680
+
3587
3681
  async def ws_get_commission_rates(self, **params):
3588
3682
  return await self._ws_api_request("account.commission", True, params)
3589
3683
 
3684
+ ws_get_commission_rates.__doc__ = Client.ws_get_commission_rates.__doc__
3685
+
3590
3686
  async def ws_get_order_book(self, **params):
3591
3687
  return await self._ws_api_request("depth", False, params)
3592
3688
 
3689
+ ws_get_order_book.__doc__ = Client.ws_get_order_book.__doc__
3690
+
3593
3691
  async def ws_get_recent_trades(self, **params):
3594
3692
  return await self._ws_api_request("trades.recent", False, params)
3595
3693
 
3694
+ ws_get_recent_trades.__doc__ = Client.ws_get_recent_trades.__doc__
3695
+
3596
3696
  async def ws_get_historical_trades(self, **params):
3597
3697
  return await self._ws_api_request("trades.historical", False, params)
3598
3698
 
3699
+ ws_get_historical_trades.__doc__ = Client.ws_get_historical_trades.__doc__
3700
+
3599
3701
  async def ws_get_aggregate_trades(self, **params):
3600
3702
  return await self._ws_api_request("trades.aggregate", False, params)
3601
3703
 
3704
+ ws_get_aggregate_trades.__doc__ = Client.ws_get_aggregate_trades.__doc__
3705
+
3602
3706
  async def ws_get_klines(self, **params):
3603
3707
  return await self._ws_api_request("klines", False, params)
3604
3708
 
3709
+ ws_get_klines.__doc__ = Client.ws_get_klines.__doc__
3710
+
3605
3711
  async def ws_get_uiKlines(self, **params):
3606
3712
  return await self._ws_api_request("uiKlines", False, params)
3607
3713
 
3714
+ ws_get_uiKlines.__doc__ = Client.ws_get_uiKlines.__doc__
3715
+
3608
3716
  async def ws_get_avg_price(self, **params):
3609
3717
  return await self._ws_api_request("avgPrice", False, params)
3610
3718
 
3719
+ ws_get_avg_price.__doc__ = Client.ws_get_avg_price.__doc__
3720
+
3611
3721
  async def ws_get_ticker(self, **params):
3612
3722
  return await self._ws_api_request("ticker.24hr", False, params)
3613
3723
 
3724
+ ws_get_ticker.__doc__ = Client.ws_get_ticker.__doc__
3725
+
3614
3726
  async def ws_get_trading_day_ticker(self, **params):
3615
3727
  return await self._ws_api_request("ticker.tradingDay", False, params)
3616
3728
 
3729
+ ws_get_trading_day_ticker.__doc__ = Client.ws_get_trading_day_ticker.__doc__
3730
+
3617
3731
  async def ws_get_symbol_ticker_window(self, **params):
3618
3732
  return await self._ws_api_request("ticker", False, params)
3619
3733
 
3734
+ ws_get_symbol_ticker_window.__doc__ = Client.ws_get_symbol_ticker_window.__doc__
3735
+
3620
3736
  async def ws_get_symbol_ticker(self, **params):
3621
3737
  return await self._ws_api_request("ticker.price", False, params)
3622
3738
 
3739
+ ws_get_symbol_ticker.__doc__ = Client.ws_get_symbol_ticker.__doc__
3740
+
3623
3741
  async def ws_get_orderbook_ticker(self, **params):
3624
3742
  return await self._ws_api_request("ticker.book", False, params)
3625
3743
 
3744
+ ws_get_orderbook_ticker.__doc__ = Client.ws_get_orderbook_ticker.__doc__
3745
+
3626
3746
  async def ws_ping(self, **params):
3627
3747
  return await self._ws_api_request("ping", False, params)
3628
3748
 
3749
+ ws_ping.__doc__ = Client.ws_ping.__doc__
3750
+
3629
3751
  async def ws_get_time(self, **params):
3630
3752
  return await self._ws_api_request("time", False, params)
3631
3753
 
3754
+ ws_get_time.__doc__ = Client.ws_get_time.__doc__
3755
+
3632
3756
  async def ws_get_exchange_info(self, **params):
3633
3757
  return await self._ws_api_request("exchangeInfo", False, params)
3634
3758
 
3759
+ ws_get_exchange_info.__doc__ = Client.ws_get_exchange_info.__doc__
3760
+
3635
3761
  ####################################################
3636
3762
  # FUTURES WS API Endpoints
3637
3763
  ####################################################
@@ -3886,3 +4012,12 @@ class AsyncClient(BaseClient):
3886
4012
  )
3887
4013
 
3888
4014
  margin_max_borrowable.__doc__ = Client.margin_max_borrowable.__doc__
4015
+
4016
+ ####################################################
4017
+ # Futures Data
4018
+ ####################################################
4019
+
4020
+ async def futures_historical_data_link(self, **params):
4021
+ return await self._request_margin_api("get", "futures/data/histDataLink", signed=True, data=params)
4022
+
4023
+ futures_historical_data_link.__doc__ = Client.futures_historical_data_link.__doc__
@@ -160,6 +160,7 @@ class BaseClient:
160
160
  private_key: Optional[Union[str, Path]] = None,
161
161
  private_key_pass: Optional[str] = None,
162
162
  loop: Optional[asyncio.AbstractEventLoop] = None,
163
+ time_unit: Optional[str] = None,
163
164
  ):
164
165
  """Binance API Client constructor
165
166
 
@@ -175,6 +176,8 @@ class BaseClient:
175
176
  :type private_key: optional - str or Path
176
177
  :param private_key_pass: Password of private key
177
178
  :type private_key_pass: optional - str
179
+ :param time_unit: Time unit to use for requests. Supported values: "MILLISECOND", "MICROSECOND"
180
+ :type time_unit: optional - str
178
181
 
179
182
  """
180
183
 
@@ -191,6 +194,7 @@ class BaseClient:
191
194
 
192
195
  self.API_KEY = api_key
193
196
  self.API_SECRET = api_secret
197
+ self.TIME_UNIT = time_unit
194
198
  self._is_rsa = False
195
199
  self.PRIVATE_KEY: Any = self._init_private_key(private_key, private_key_pass)
196
200
  self.session = self._init_session()
@@ -199,6 +203,8 @@ class BaseClient:
199
203
  self.testnet = testnet
200
204
  self.timestamp_offset = 0
201
205
  ws_api_url = self.WS_API_TESTNET_URL if testnet else self.WS_API_URL.format(tld)
206
+ if self.TIME_UNIT:
207
+ ws_api_url += f"?timeUnit={self.TIME_UNIT}"
202
208
  self.ws_api = WebsocketAPI(url=ws_api_url, tld=tld)
203
209
  ws_future_url = (
204
210
  self.WS_FUTURES_TESTNET_URL if testnet else self.WS_FUTURES_URL.format(tld)
@@ -215,6 +221,9 @@ class BaseClient:
215
221
  if self.API_KEY:
216
222
  assert self.API_KEY
217
223
  headers["X-MBX-APIKEY"] = self.API_KEY
224
+ if self.TIME_UNIT:
225
+ assert self.TIME_UNIT
226
+ headers["X-MBX-TIME-UNIT"] = self.TIME_UNIT
218
227
  return headers
219
228
 
220
229
  def _init_session(self):
@@ -312,6 +321,11 @@ class BaseClient:
312
321
  def encode_uri_component(uri, safe="~()*!.'"):
313
322
  return _urlencode.quote(uri, safe=safe)
314
323
 
324
+ @staticmethod
325
+ def convert_to_dict(list_tuples):
326
+ dictionary = dict((key, value) for key, value in list_tuples)
327
+ return dictionary
328
+
315
329
  def _ed25519_signature(self, query_string: str):
316
330
  assert self.PRIVATE_KEY
317
331
  res = b64encode(