Skip to content
2 changes: 1 addition & 1 deletion pybit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "5.10.1"
VERSION = "5.10.2"
8 changes: 6 additions & 2 deletions pybit/_http_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]})"

Expand Down
52 changes: 52 additions & 0 deletions pybit/_v5_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -60,6 +79,39 @@ def upgrade_to_unified_trading_account(self, **kwargs):
auth=True,
)

def borrow(self, **kwargs):
"""
https://bybit-exchange.github.io/docs/zh-TW/v5/account/borrow
"""
return self._submit_request(
method="POST",
path=f"{self.endpoint}{Account.BORROW}",
query=kwargs,
auth=True,
)

def repay(self, **kwargs):
"""
https://bybit-exchange.github.io/docs/zh-TW/v5/account/repay
"""
return self._submit_request(
method="POST",
path=f"{self.endpoint}{Account.REPAY}",
query=kwargs,
auth=True,
)

def no_convert_repay(self, **kwargs):
"""
https://bybit-exchange.github.io/docs/zh-TW/v5/account/no-convert-repay
"""
return self._submit_request(
method="POST",
path=f"{self.endpoint}{Account.NO_CONVERT_REPAY}",
query=kwargs,
auth=True,
)

def get_borrow_history(self, **kwargs):
"""Get interest records, sorted in reverse order of creation time.

Expand Down
4 changes: 4 additions & 0 deletions pybit/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,6 +20,9 @@ class Account(str, Enum):
SET_MMP = "/v5/account/mmp-modify"
RESET_MMP = "/v5/account/mmp-reset"
GET_MMP_STATE = "/v5/account/mmp-state"
BORROW = "/v5/account/borrow"
REPAY = "/v5/account/repay"
NO_CONVERT_REPAY = "/v5/account/no-convert-repay"

def __str__(self) -> str:
return self.value
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name='pybit',
version='5.10.1',
version='5.10.8',
description='Python3 Bybit HTTP/WebSocket API Connector',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down