diff --git a/pybit/__init__.py b/pybit/__init__.py index 36d94a4..9ce04fa 100644 --- a/pybit/__init__.py +++ b/pybit/__init__.py @@ -1 +1 @@ -VERSION = "5.10.1" +VERSION = "5.10.2" diff --git a/pybit/_http_manager.py b/pybit/_http_manager.py index 8e54b51..342dada 100644 --- a/pybit/_http_manager.py +++ b/pybit/_http_manager.py @@ -71,7 +71,7 @@ class _V5HTTPManager: log_requests: bool = field(default=False) timeout: int = field(default=10) recv_window: bool = field(default=5000) - force_retry: bool = field(default=False) + force_retry: bool = field(default=True) retry_codes: defaultdict[dict] = field(default_factory=dict) ignore_codes: dict = field(default_factory=dict) max_retries: bool = field(default=3) @@ -332,8 +332,12 @@ def _submit_request(self, method=None, path=None, query=None, auth=False): ret_code = "retCode" ret_msg = "retMsg" + if ret_code not in s_json: + logging.info(s_json) + # If Bybit returns an error, raise. - if s_json[ret_code]: + s_code = s_json[ret_code] if ret_code in s_json else s_json['ret_code'] + if s_code: # Generate error message. error_msg = f"{s_json[ret_msg]} (ErrCode: {s_json[ret_code]})" diff --git a/pybit/_v5_account.py b/pybit/_v5_account.py index 349bee2..d09ff47 100644 --- a/pybit/_v5_account.py +++ b/pybit/_v5_account.py @@ -25,6 +25,25 @@ def get_wallet_balance(self, **kwargs): auth=True, ) + def get_coin_withdrawal(self, **kwargs): + """Query the available amount to transfer of a specific coin in the Unified wallet. + + Required args: + coinName (string): Coin name, uppercase only + + Returns: + Request results as dictionary. + + Additional information: + https://bybit-exchange.github.io/docs/v5/account/unified-trans-amnt + """ + return self._submit_request( + method="GET", + path=f"{self.endpoint}{Account.GET_COIN_WITHDRAWAL}", + query=kwargs, + auth=True, + ) + def get_transferable_amount(self, **kwargs): """Query the available amount to transfer of a specific coin in the Unified wallet. diff --git a/pybit/account.py b/pybit/account.py index fbe9b19..3bc4f9d 100644 --- a/pybit/account.py +++ b/pybit/account.py @@ -3,6 +3,7 @@ class Account(str, Enum): GET_WALLET_BALANCE = "/v5/account/wallet-balance" + GET_COIN_WITHDRAWAL = "/v5/account/withdrawal" GET_TRANSFERABLE_AMOUNT = "/v5/account/withdrawal" UPGRADE_TO_UNIFIED_ACCOUNT = "/v5/account/upgrade-to-uta" GET_BORROW_HISTORY = "/v5/account/borrow-history" diff --git a/setup.py b/setup.py index 8df2dde..3923571 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name='pybit', - version='5.10.1', + version='5.10.6', description='Python3 Bybit HTTP/WebSocket API Connector', long_description=long_description, long_description_content_type="text/markdown",