From 6cd392d1a698cfba2f516b809070c53b65640e5c Mon Sep 17 00:00:00 2001 From: "zihao.jiang" Date: Mon, 9 Dec 2024 17:37:04 +0800 Subject: [PATCH] upgrade --- okx/Account.py | 24 ++++++++++++++++++++++-- okx/Funding.py | 4 ++-- okx/__init__.py | 2 +- okx/consts.py | 3 +++ test/AccountTest.py | 7 +++++++ test/FundingTest.py | 12 ++++++------ 6 files changed, 41 insertions(+), 11 deletions(-) diff --git a/okx/Account.py b/okx/Account.py index 89f25b0..c66834c 100644 --- a/okx/Account.py +++ b/okx/Account.py @@ -88,8 +88,8 @@ class AccountAPI(OkxClient): return self._request_with_params(POST, ADJUSTMENT_MARGIN, params) # Get Leverage - def get_leverage(self, instId, mgnMode): - params = {'instId': instId, 'mgnMode': mgnMode} + def get_leverage(self, mgnMode, ccy='', instId=''): + params = {'instId': instId, 'mgnMode': mgnMode, 'ccy': ccy} return self._request_with_params(GET, GET_LEVERAGE, params) # Get instruments @@ -294,3 +294,23 @@ class AccountAPI(OkxClient): if limit is not None: params['limit'] = limit 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) diff --git a/okx/Funding.py b/okx/Funding.py index 39e298b..61cd021 100644 --- a/okx/Funding.py +++ b/okx/Funding.py @@ -35,8 +35,8 @@ class FundingAPI(OkxClient): return self._request_with_params(POST, FUNDS_TRANSFER, params) # Withdrawal - def withdrawal(self, ccy, amt, dest, toAddr, fee, chain='', areaCode='', clientId=''): - params = {'ccy': ccy, 'amt': amt, 'dest': dest, 'toAddr': toAddr, 'fee': fee, 'chain': chain, + def withdrawal(self, ccy, amt, dest, toAddr, chain='', areaCode='', clientId=''): + params = {'ccy': ccy, 'amt': amt, 'dest': dest, 'toAddr': toAddr, 'chain': chain, 'areaCode': areaCode, 'clientId': clientId} return self._request_with_params(POST, WITHDRAWAL_COIN, params) diff --git a/okx/__init__.py b/okx/__init__.py index fa0038c..cedfd53 100644 --- a/okx/__init__.py +++ b/okx/__init__.py @@ -2,4 +2,4 @@ Python SDK for the OKX API v5 """ -__version__="0.3.3" \ No newline at end of file +__version__="0.3.4" \ No newline at end of file diff --git a/okx/consts.py b/okx/consts.py index 4fcd249..6c66242 100644 --- a/okx/consts.py +++ b/okx/consts.py @@ -62,6 +62,9 @@ AMEND_BORROWING_ORDER='/api/v5/account/fixed-loan/amend-borrowing-order' MANUAL_REBORROW = '/api/v5/account/fixed-loan/manual-reborrow' REPAY_BORROWING_ORDER='/api/v5/account/fixed-loan/repay-borrowing-order' 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 NON_TRADABLE_ASSETS = '/api/v5/asset/non-tradable-assets' diff --git a/test/AccountTest.py b/test/AccountTest.py index d05788e..4f1d715 100644 --- a/test/AccountTest.py +++ b/test/AccountTest.py @@ -140,5 +140,12 @@ class AccountTest(unittest.TestCase): # def test_get_fix_loan_borrowing_orders_list(self): # 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__': unittest.main() diff --git a/test/FundingTest.py b/test/FundingTest.py index d96926c..e87bb76 100644 --- a/test/FundingTest.py +++ b/test/FundingTest.py @@ -58,8 +58,8 @@ class FundingTest(unittest.TestCase): print(self.FundingAPI.get_lending_rate_summary('BTC')) """ - def test_get_non_tradable_assets(self): - print(self.FundingAPI.get_non_tradable_assets()) + # def test_get_non_tradable_assets(self): + # print(self.FundingAPI.get_non_tradable_assets()) # def test_get_lending_summary(self): # print(self.FundingAPI.get_lending_rate_summary('BTC')) # def test_get_lending_rate_history(self): @@ -68,8 +68,8 @@ class FundingTest(unittest.TestCase): # def test_get_non_tradable_assets(self): # print(self.FundingAPI.get_non_tradable_assets()) - def test_get_deposit_withdraw_status(self): - print(self.FundingAPI.get_deposit_withdraw_status(wdId='84804812')) + # def test_get_deposit_withdraw_status(self): + # print(self.FundingAPI.get_deposit_withdraw_status(wdId='84804812')) # def test_get_withdrawal_history(self): # print(self.FundingAPI.get_withdrawal_history()) @@ -77,8 +77,8 @@ class FundingTest(unittest.TestCase): # def test_get_deposit_history(self): # print(self.FundingAPI.get_deposit_history()) - # def test_withdrawal(self): - # print(self.FundingAPI.withdrawal(ccy='USDT',amt='1',dest='3',toAddr='18740405107',fee='0',areaCode='86')) + def test_withdrawal(self): + print(self.FundingAPI.withdrawal(ccy='USDT',amt='1',dest='3',toAddr='18740405107',areaCode='86')) if __name__ == '__main__': unittest.main() \ No newline at end of file