This commit is contained in:
zihao.jiang 2024-12-09 17:37:04 +08:00
parent 7420e2a4da
commit 6cd392d1a6
6 changed files with 41 additions and 11 deletions

View File

@ -88,8 +88,8 @@ class AccountAPI(OkxClient):
return self._request_with_params(POST, ADJUSTMENT_MARGIN, params) return self._request_with_params(POST, ADJUSTMENT_MARGIN, params)
# Get Leverage # Get Leverage
def get_leverage(self, instId, mgnMode): def get_leverage(self, mgnMode, ccy='', instId=''):
params = {'instId': instId, 'mgnMode': mgnMode} params = {'instId': instId, 'mgnMode': mgnMode, 'ccy': ccy}
return self._request_with_params(GET, GET_LEVERAGE, params) return self._request_with_params(GET, GET_LEVERAGE, params)
# Get instruments # Get instruments
@ -294,3 +294,23 @@ class AccountAPI(OkxClient):
if limit is not None: if limit is not None:
params['limit'] = limit params['limit'] = limit
return self._request_with_params(GET, BORROWING_ORDERS_LIST, params) return self._request_with_params(GET, BORROWING_ORDERS_LIST, params)
def spot_manual_borrow_repay(self, ccy=None, side=None, amt=None):
params = {}
if ccy is not None:
params['ccy'] = ccy
if side is not None:
params['side'] = side
if amt is not None:
params['amt'] = amt
return self._request_with_params(POST, MANUAL_REBORROW_REPAY, params)
def set_auto_repay(self, autoRepay=False):
params = {}
if autoRepay is not None:
params['autoRepay'] = autoRepay
return self._request_with_params(POST, SET_AUTO_REPAY, params)
def spot_borrow_repay_history(self, ccy='', type='', after='', before='', limit=''):
params = {'ccy': ccy, 'type': type, 'after': after, 'before': before, 'limit': limit}
return self._request_with_params(GET, GET_BORROW_REPAY_HISTORY, params)

View File

@ -35,8 +35,8 @@ class FundingAPI(OkxClient):
return self._request_with_params(POST, FUNDS_TRANSFER, params) return self._request_with_params(POST, FUNDS_TRANSFER, params)
# Withdrawal # Withdrawal
def withdrawal(self, ccy, amt, dest, toAddr, fee, chain='', areaCode='', clientId=''): def withdrawal(self, ccy, amt, dest, toAddr, chain='', areaCode='', clientId=''):
params = {'ccy': ccy, 'amt': amt, 'dest': dest, 'toAddr': toAddr, 'fee': fee, 'chain': chain, params = {'ccy': ccy, 'amt': amt, 'dest': dest, 'toAddr': toAddr, 'chain': chain,
'areaCode': areaCode, 'clientId': clientId} 'areaCode': areaCode, 'clientId': clientId}
return self._request_with_params(POST, WITHDRAWAL_COIN, params) return self._request_with_params(POST, WITHDRAWAL_COIN, params)

View File

@ -2,4 +2,4 @@
Python SDK for the OKX API v5 Python SDK for the OKX API v5
""" """
__version__="0.3.3" __version__="0.3.4"

View File

@ -62,6 +62,9 @@ AMEND_BORROWING_ORDER='/api/v5/account/fixed-loan/amend-borrowing-order'
MANUAL_REBORROW = '/api/v5/account/fixed-loan/manual-reborrow' MANUAL_REBORROW = '/api/v5/account/fixed-loan/manual-reborrow'
REPAY_BORROWING_ORDER='/api/v5/account/fixed-loan/repay-borrowing-order' REPAY_BORROWING_ORDER='/api/v5/account/fixed-loan/repay-borrowing-order'
BORROWING_ORDERS_LIST='/api/v5/account/fixed-loan/borrowing-orders-list' BORROWING_ORDERS_LIST='/api/v5/account/fixed-loan/borrowing-orders-list'
MANUAL_REBORROW_REPAY = '/api/v5/account/spot-manual-borrow-repay'
SET_AUTO_REPAY='/api/v5/account/set-auto-repay'
GET_BORROW_REPAY_HISTORY='/api/v5/account/spot-borrow-repay-history'
# funding-complete-testcomplete # funding-complete-testcomplete
NON_TRADABLE_ASSETS = '/api/v5/asset/non-tradable-assets' NON_TRADABLE_ASSETS = '/api/v5/asset/non-tradable-assets'

View File

@ -140,5 +140,12 @@ class AccountTest(unittest.TestCase):
# def test_get_fix_loan_borrowing_orders_list(self): # def test_get_fix_loan_borrowing_orders_list(self):
# logger.debug(self.AccountAPI.get_fix_loan_borrowing_orders_list(ordId="2407301054407907")) # logger.debug(self.AccountAPI.get_fix_loan_borrowing_orders_list(ordId="2407301054407907"))
# def test_spot_manual_borrow_repay(self):
# logger.debug(f'{self.AccountAPI.spot_manual_borrow_repay(ccy="USDT",side="borrow",amt=1)}')
# def test_set_auto_repay(self):
# logger.info(f'{self.AccountAPI.set_auto_repay(autoRepay=True)}')
# def test_spot_borrow_repay_history(self):
# logger.debug(self.AccountAPI.spot_borrow_repay_history(ccy="USDT",type="auto_borrow",after="1597026383085"))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -58,8 +58,8 @@ class FundingTest(unittest.TestCase):
print(self.FundingAPI.get_lending_rate_summary('BTC')) print(self.FundingAPI.get_lending_rate_summary('BTC'))
""" """
def test_get_non_tradable_assets(self): # def test_get_non_tradable_assets(self):
print(self.FundingAPI.get_non_tradable_assets()) # print(self.FundingAPI.get_non_tradable_assets())
# def test_get_lending_summary(self): # def test_get_lending_summary(self):
# print(self.FundingAPI.get_lending_rate_summary('BTC')) # print(self.FundingAPI.get_lending_rate_summary('BTC'))
# def test_get_lending_rate_history(self): # def test_get_lending_rate_history(self):
@ -68,8 +68,8 @@ class FundingTest(unittest.TestCase):
# def test_get_non_tradable_assets(self): # def test_get_non_tradable_assets(self):
# print(self.FundingAPI.get_non_tradable_assets()) # print(self.FundingAPI.get_non_tradable_assets())
def test_get_deposit_withdraw_status(self): # def test_get_deposit_withdraw_status(self):
print(self.FundingAPI.get_deposit_withdraw_status(wdId='84804812')) # print(self.FundingAPI.get_deposit_withdraw_status(wdId='84804812'))
# def test_get_withdrawal_history(self): # def test_get_withdrawal_history(self):
# print(self.FundingAPI.get_withdrawal_history()) # print(self.FundingAPI.get_withdrawal_history())
@ -77,8 +77,8 @@ class FundingTest(unittest.TestCase):
# def test_get_deposit_history(self): # def test_get_deposit_history(self):
# print(self.FundingAPI.get_deposit_history()) # print(self.FundingAPI.get_deposit_history())
# def test_withdrawal(self): def test_withdrawal(self):
# print(self.FundingAPI.withdrawal(ccy='USDT',amt='1',dest='3',toAddr='18740405107',fee='0',areaCode='86')) print(self.FundingAPI.withdrawal(ccy='USDT',amt='1',dest='3',toAddr='18740405107',areaCode='86'))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()