From f983c5bc2dad62b66511ae9357291cca0d1b17e8 Mon Sep 17 00:00:00 2001 From: 007live Date: Wed, 7 Aug 2024 10:03:32 +0800 Subject: [PATCH] supported new features, fixed loan & earn --- okx/Account.py | 165 ++++++++++++++++++++++++++---------- okx/SimpleEarnFixed.py | 91 ++++++++++++++++++++ okx/__init__.py | 2 +- okx/consts.py | 18 ++++ okx/okxclient.py | 7 +- okx/utils.py | 10 ++- setup.py | 1 + test/AccountTest.py | 38 ++++++--- test/SimpleEarnFixedTest.py | 37 ++++++++ 9 files changed, 307 insertions(+), 62 deletions(-) create mode 100644 okx/SimpleEarnFixed.py create mode 100644 test/SimpleEarnFixedTest.py diff --git a/okx/Account.py b/okx/Account.py index 6474c02..6fd6dd4 100644 --- a/okx/Account.py +++ b/okx/Account.py @@ -1,10 +1,11 @@ -from .okxclient import OkxClient from .consts import * +from .okxclient import OkxClient class AccountAPI(OkxClient): - def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None): + def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1', + domain='https://www.okx.com', debug=True, proxy=None): OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy) # Get Positions @@ -26,7 +27,8 @@ class AccountAPI(OkxClient): params = {'instType': instType, 'instId': instId} return self._request_with_params(GET, POSITION_INFO, params) - def position_builder(self,inclRealPosAndEq=False, spotOffsetType=None, greeksType=None, simPos=None, simAsset=None): + def position_builder(self, inclRealPosAndEq=False, spotOffsetType=None, greeksType=None, simPos=None, + simAsset=None): params = {} if inclRealPosAndEq is not None: params['inclRealPosAndEq'] = inclRealPosAndEq @@ -42,16 +44,17 @@ class AccountAPI(OkxClient): # Get Bills Details (recent 7 days) def get_account_bills(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', - limit=''): + limit=''): params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type, 'subType': subType, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, BILLS_DETAIL, params) # Get Bills Details (recent 3 months) - def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', - limit='',begin='',end=''): + def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', + before='', + limit='', begin='', end=''): params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type, - 'subType': subType, 'after': after, 'before': before, 'limit': limit,'begin':begin,'end':end} + 'subType': subType, 'after': after, 'before': before, 'limit': limit, 'begin': begin, 'end': end} return self._request_with_params(GET, BILLS_ARCHIVE, params) # Get Account Configuration @@ -80,18 +83,19 @@ class AccountAPI(OkxClient): return self._request_with_params(GET, MAX_AVAIL_SIZE, params) # Increase / Decrease margin - def adjustment_margin(self, instId, posSide, type, amt,loanTrans=''): - params = {'instId': instId, 'posSide': posSide, 'type': type, 'amt': amt,'loanTrans':loanTrans} + def adjustment_margin(self, instId, posSide, type, amt, loanTrans=''): + params = {'instId': instId, 'posSide': posSide, 'type': type, 'amt': amt, 'loanTrans': loanTrans} return self._request_with_params(POST, ADJUSTMENT_MARGIN, params) # Get Leverage def get_leverage(self, instId, mgnMode): params = {'instId': instId, 'mgnMode': mgnMode} return self._request_with_params(GET, GET_LEVERAGE, params) + # Get instruments - def get_instruments(self, instType='', ugly = '',instFamily='',instId=''): + def get_instruments(self, instType='', ugly='', instFamily='', instId=''): params = {'instType': instType, 'ugly': ugly, 'instFamily': instFamily, 'instId': instId} - return self._request_with_params(GET,GET_INSTRUMENTS,params) + return self._request_with_params(GET, GET_INSTRUMENTS, params) # Get the maximum loan of isolated MARGIN def get_max_loan(self, instId, mgnMode, mgnCcy): @@ -99,8 +103,8 @@ class AccountAPI(OkxClient): return self._request_with_params(GET, MAX_LOAN, params) # Get Fee Rates - def get_fee_rates(self, instType, instId='', uly='', category='',instFamily = ''): - params = {'instType': instType, 'instId': instId, 'uly': uly, 'category': category,'instFamily':instFamily} + def get_fee_rates(self, instType, instId='', uly='', category='', instFamily=''): + params = {'instType': instType, 'instId': instId, 'uly': uly, 'category': category, 'instFamily': instFamily} return self._request_with_params(GET, FEE_RATES, params) # Get interest-accrued @@ -119,8 +123,8 @@ class AccountAPI(OkxClient): return self._request_with_params(POST, SET_GREEKS, params) # Set Isolated Mode - def set_isolated_mode(self, isoMode,type): - params = {'isoMode': isoMode, 'type':type} + def set_isolated_mode(self, isoMode, type): + params = {'isoMode': isoMode, 'type': type} return self._request_with_params(POST, ISOLATED_MODE, params) # Get Maximum Withdrawals @@ -135,11 +139,11 @@ class AccountAPI(OkxClient): # Get borrow repay history def get_borrow_repay_history(self, ccy='', after='', before='', limit=''): - params = {'ccy': ccy, 'after': after, 'before': before, 'limit':limit} + params = {'ccy': ccy, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, BORROW_REPAY_HISTORY, params) # Get Obtain borrowing rate and limit - def get_interest_limits(self, type='',ccy=''): + def get_interest_limits(self, type='', ccy=''): params = {'type': type, 'ccy': ccy} return self._request_with_params(GET, INTEREST_LIMITS, params) @@ -153,57 +157,58 @@ class AccountAPI(OkxClient): params = {'ccy': ccy} return self._request_with_params(GET, GREEKS, params) - #GET /api/v5/account/risk-state + # GET /api/v5/account/risk-state def get_account_position_risk(self): return self._request_without_params(GET, ACCOUNT_RISK) - #GET /api/v5/account/positions-history - def get_positions_history(self,instType = '', instId = '',mgnMode = '',type = '',posId = '',after = '',before ='',limit = ''): + # GET /api/v5/account/positions-history + def get_positions_history(self, instType='', instId='', mgnMode='', type='', posId='', after='', before='', + limit=''): params = { - 'instType':instType, - 'instId':instId, - 'mgnMode':mgnMode, - 'type':type, - 'posId':posId, - 'after':after, - 'before':before, - 'limit':limit + 'instType': instType, + 'instId': instId, + 'mgnMode': mgnMode, + 'type': type, + 'posId': posId, + 'after': after, + 'before': before, + 'limit': limit } - return self._request_with_params(GET,POSITIONS_HISTORY,params) + return self._request_with_params(GET, POSITIONS_HISTORY, params) - #GET /api/v5/account/position-tiers - def get_account_position_tiers(self,instType = '', uly = '',instFamily = ''): + # GET /api/v5/account/position-tiers + def get_account_position_tiers(self, instType='', uly='', instFamily=''): params = { - 'instType':instType, - 'uly':uly, - 'instFamily':instFamily + 'instType': instType, + 'uly': uly, + 'instFamily': instFamily } - return self._request_with_params(GET,GET_PM_LIMIT,params) + return self._request_with_params(GET, GET_PM_LIMIT, params) - #- Get VIP interest accrued data + # - Get VIP interest accrued data def get_VIP_interest_accrued_data(self, ccy='', ordId='', after='', before='', limit=''): params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, GET_VIP_INTEREST_ACCRUED_DATA, params) - #- Get VIP interest deducted data + # - Get VIP interest deducted data def get_VIP_interest_deducted_data(self, ccy='', ordId='', after='', before='', limit=''): params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, GET_VIP_INTEREST_DEDUCTED_DATA, params) # - Get VIP loan order list - def get_VIP_loan_order_list(self, ordId='',state='', ccy='', after='', before='', limit=''): - params = {'ordId': ordId, 'state': state, 'ccy': ccy,'after': after, 'before': before, 'limit': limit} + def get_VIP_loan_order_list(self, ordId='', state='', ccy='', after='', before='', limit=''): + params = {'ordId': ordId, 'state': state, 'ccy': ccy, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, GET_VIP_LOAN_ORDER_LIST, params) - #- Get VIP loan order detail + # - Get VIP loan order detail def get_VIP_loan_order_detail(self, ccy='', ordId='', after='', before='', limit=''): params = {'ccy': ccy, 'ordId': ordId, 'after': after, 'before': before, 'limit': limit} return self._request_with_params(GET, GET_VIP_LOAN_ORDER_DETAIL, params) - #- Set risk offset type + # - Set risk offset type def set_risk_offset_typel(self, type=''): params = {'type': type} - return self._request_with_params(POST, SET_RISK_OFFSET_TYPE,params) + return self._request_with_params(POST, SET_RISK_OFFSET_TYPE, params) # - Set auto loan def set_auto_loan(self, autoLoan=''): @@ -212,6 +217,80 @@ class AccountAPI(OkxClient): } return self._request_with_params(POST, SET_AUTO_LOAN, params) - #- Activate option + # - Activate option def activate_option(self): return self._request_without_params(POST, ACTIVSTE_OPTION) + + def get_fix_loan_borrowing_limit(self): + return self._request_without_params(GET, BORROWING_LIMIT) + + def get_fix_loan_borrowing_quote(self, type=None, ccy=None, amt=None, maxRate=None, term=None, ordId=None): + params = {} + if type is not None: + params['type'] = type + if ccy is not None: + params['ccy'] =ccy + if amt is not None: + params['amt'] = amt + if maxRate is not None: + params['maxRate'] = maxRate + if term is not None: + params['term'] = term + if ordId is not None: + params['ordId'] = ordId + return self._request_with_params(GET, BORROWING_QUOTE, params) + + def place_fix_loan_borrowing_order(self, ccy=None, amt=None, maxRate=None, term=None, reborrow=False, reborrowRate=None): + params = {} + if ccy is not None: + params['ccy'] =ccy + if amt is not None: + params['amt'] = amt + if maxRate is not None: + params['maxRate'] = maxRate + if term is not None: + params['term'] = term + if reborrow is not None: + params['reborrow'] = reborrow + if reborrowRate is not None: + params['reborrowRate'] = reborrowRate + return self._request_with_params(POST, PLACE_BORROWING_ORDER, params) + + def amend_fix_loan_borrowing_order(self, ordId=None, reborrow=None, renewMaxRate=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + if reborrow is not None: + params['reborrow'] = reborrow + if renewMaxRate is not None: + params['renewMaxRate'] = renewMaxRate + return self._request_with_params(POST, AMEND_BORROWING_ORDER, params) + + def fix_loan_manual_reborrow(self, ordId=None, maxRate=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + if maxRate is not None: + params['maxRate'] = maxRate + return self._request_with_params(POST, MANUAL_REBORROW, params) + + def repay_fix_loan_borrowing_order(self, ordId=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + return self._request_with_params(POST, REPAY_BORROWING_ORDER, params) + def get_fix_loan_borrowing_orders_list(self, ordId=None, ccy=None, state=None, after=None, before=None, limit=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + if ccy is not None: + params['ccy'] =ccy + if state is not None: + params['state'] = state + if after is not None: + params['after'] = after + if before is not None: + params['before'] = before + if limit is not None: + params['limit'] = limit + return self._request_with_params(GET, BORROWING_ORDERS_LIST, params) diff --git a/okx/SimpleEarnFixed.py b/okx/SimpleEarnFixed.py new file mode 100644 index 0000000..9b2fb5b --- /dev/null +++ b/okx/SimpleEarnFixed.py @@ -0,0 +1,91 @@ +from okx.consts import GET, LENDING_OFFERS, LENDING_APY_HISTORY, PENDING_LENDING_VOLUME, PLACE_LENDING_ORDER, POST, \ + AMEND_LENDING_ORDER, LENDING_ORDERS_LIST, LENDING_SUB_ORDERS +from okx.okxclient import OkxClient + + +class SimpleEarnFixedAPI(OkxClient): + def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=None, flag='1', + domain='https://www.okx.com', debug=True, proxy=None): + OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy) + + def get_lending_offers(self, ccy=None, term=None): + params = {} + if ccy is not None: + params['ccy'] = ccy + if term is not None: + params['term'] = term + return self._request_with_params(GET, LENDING_OFFERS, params) + + def get_lending_apy_history(self, ccy=None, term=None): + params = {} + if ccy is not None: + params['ccy'] = ccy + if term is not None: + params['term'] = term + return self._request_with_params(GET, LENDING_APY_HISTORY, params) + + def get_pending_lending_volume(self, ccy=None, term=None): + params = {} + if ccy is not None: + params['ccy'] = ccy + if term is not None: + params['term'] = term + return self._request_with_params(GET, PENDING_LENDING_VOLUME, params) + + def place_lending_order(self, ccy=None, amt=None, rate=None, term=None, autoRenewal=False): + params = {} + if ccy is not None: + params['ccy'] = ccy + if amt is not None: + params['amt'] = amt + if rate is not None: + params['rate'] = rate + if term is not None: + params['term'] = term + if autoRenewal: + params['autoRenewal'] = autoRenewal + return self._request_with_params(POST, PLACE_LENDING_ORDER, params) + def amend_lending_order(self, ordId=None, changeAmt=None, rate=None,autoRenewal=False): + params = {} + if ordId is not None: + params['ordId'] = ordId + if changeAmt is not None: + params['amt'] = changeAmt + if rate is not None: + params['rate'] = rate + params['autoRenewal'] = autoRenewal + return self._request_with_params(POST, AMEND_LENDING_ORDER, params) + + def get_lending_orders_list(self, ordId = None,ccy=None, state=None, after=None,before=None,limit=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + if ccy is not None: + params['ccy'] = ccy + if state is not None: + params['state'] = state + if after is not None: + params['after'] = after + if before is not None: + params['before'] = before + if limit: + params['limit'] = limit + return self._request_with_params(GET, LENDING_ORDERS_LIST, params) + + def get_lending_sub_orders(self, ordId = None, state=None, after=None,before=None,limit=None): + params = {} + if ordId is not None: + params['ordId'] = ordId + if state is not None: + params['state'] = state + if after is not None: + params['after'] = after + if before is not None: + params['before'] = before + if limit: + params['limit'] = limit + return self._request_with_params(GET, LENDING_SUB_ORDERS, params) + + + + diff --git a/okx/__init__.py b/okx/__init__.py index 152ea2e..ab41521 100644 --- a/okx/__init__.py +++ b/okx/__init__.py @@ -2,4 +2,4 @@ Python SDK for the OKX API v5 """ -__version__="0.3.0" \ No newline at end of file +__version__="0.3.2" \ No newline at end of file diff --git a/okx/consts.py b/okx/consts.py index f312757..4fcd249 100644 --- a/okx/consts.py +++ b/okx/consts.py @@ -55,6 +55,13 @@ SET_AUTO_LOAN = '/api/v5/account/set-auto-loan' ACTIVSTE_OPTION = '/api/v5/account/activate-option' POSITION_BUILDER = '/api/v5/account/position-builder' GET_INSTRUMENTS = '/api/v5/account/instruments' +BORROWING_LIMIT = '/api/v5/account/fixed-loan/borrowing-limit' +BORROWING_QUOTE = '/api/v5/account/fixed-loan/borrowing-quote' +PLACE_BORROWING_ORDER= '/api/v5/account/fixed-loan/borrowing-order' +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' # funding-complete-testcomplete NON_TRADABLE_ASSETS = '/api/v5/asset/non-tradable-assets' @@ -292,3 +299,14 @@ SPREAD_GET_SPREADS = '/api/v5/sprd/spreads' SPREAD_GET_ORDER_BOOK = '/api/v5/sprd/books' SPREAD_GET_TICKER = '/api/v5/sprd/ticker' SPREAD_GET_PUBLIC_TRADES = '/api/v5/sprd/public-trades' + +# Simple earn fixed +LENDING_OFFERS = '/api/v5/finance/fixed-loan/lending-offers' +LENDING_APY_HISTORY='/api/v5/finance/fixed-loan/lending-apy-history' +PENDING_LENDING_VOLUME = '/api/v5/finance/fixed-loan/pending-lending-volume' +PLACE_LENDING_ORDER= '/api/v5/finance/fixed-loan/lending-order' +AMEND_LENDING_ORDER='/api/v5/finance/fixed-loan/amend-lending-order' +LENDING_ORDERS_LIST='/api/v5/finance/fixed-loan/lending-orders-list' +LENDING_SUB_ORDERS='/api/v5/finance/fixed-loan/lending-sub-orders' + + diff --git a/okx/okxclient.py b/okx/okxclient.py index f4f9ff5..de33b74 100644 --- a/okx/okxclient.py +++ b/okx/okxclient.py @@ -6,6 +6,8 @@ import httpx from httpx import Client from datetime import datetime, timezone +from loguru import logger + from . import consts as c, utils, exceptions @@ -37,8 +39,9 @@ class OkxClient(Client): header = utils.get_header_no_sign(self.flag, self.debug) response = None if self.debug == True: - print('domain:',self.domain) - print('url:',request_path) + logger.debug(f'domain: {self.domain}') + logger.debug(f'url: {request_path}') + logger.debug(f'body:{body}') if method == c.GET: response = self.get(request_path, headers=header) elif method == c.POST: diff --git a/okx/utils.py b/okx/utils.py index f130a9b..c8fd6d9 100644 --- a/okx/utils.py +++ b/okx/utils.py @@ -1,6 +1,9 @@ import hmac import base64 import datetime + +from loguru import logger + from . import consts as c @@ -12,7 +15,7 @@ def sign(message, secretKey): def pre_hash(timestamp, method, request_path, body,debug = True): if debug == True: - print('body: ',body) + logger.debug(f'body: {body}') return str(timestamp) + str.upper(method) + request_path + body @@ -25,7 +28,7 @@ def get_header(api_key, sign, timestamp, passphrase, flag,debug = True): header[c.OK_ACCESS_PASSPHRASE] = passphrase header['x-simulated-trading'] = flag if debug == True: - print('header: ',header) + logger.debug(f'header: {header}') return header def get_header_no_sign(flag,debug = True): @@ -33,7 +36,7 @@ def get_header_no_sign(flag,debug = True): header[c.CONTENT_TYPE] = c.APPLICATION_JSON header['x-simulated-trading'] = flag if debug == True: - print('header: ',header) + logger.debug(f'header: {header}') return header def parse_params_to_str(params): @@ -42,7 +45,6 @@ def parse_params_to_str(params): if(value != ''): url = url + str(key) + '=' + str(value) + '&' url = url[0:-1] - #print('url:',url) return url diff --git a/setup.py b/setup.py index e4e8838..b91e237 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ setuptools.setup( "importlib-metadata", "httpx[http2]", "keyring", + "loguru", "requests", "Twisted", "pyOpenSSL" diff --git a/test/AccountTest.py b/test/AccountTest.py index 22f81be..d05788e 100644 --- a/test/AccountTest.py +++ b/test/AccountTest.py @@ -1,15 +1,16 @@ import unittest +from loguru import logger + from okx import Account class AccountTest(unittest.TestCase): def setUp(self): - proxy = "http://43.152.113.72:19206" - api_key = 'your_apiKey' - api_secret_key = 'your_secretKey' - passphrase = 'your_secretKey' - self.AccountAPI = Account.AccountAPI(api_key, api_secret_key, passphrase, use_server_time=False, flag='1', proxy=proxy) + api_key = '52049394-3c72-4c06-8d87-d6399450c264' + api_secret_key = 'E532EB5AF81E6E50A2875225FEDC9150' + passphrase = 'Fixedloan2024!' + self.AccountAPI = Account.AccountAPI(api_key, api_secret_key, passphrase, flag='1') # ''' # POSITIONS_HISTORY = '/api/v5/account/positions-history' #need add @@ -21,12 +22,12 @@ class AccountTest(unittest.TestCase): # def test_get_pm_limit(self): # print(self.AccountAPI.get_pm_limit("SWAP","BTC-USDT")) # positions-history - def test_get_positions_history(self): - print(self.AccountAPI.get_positions_history()) - def test_get_instruments(self): - print(self.AccountAPI.get_instruments(instType='SPOT')) - def test_get_account_bills_archive(self): - print(self.AccountAPI.get_account_bills_archive(begin='1715780962300',end='1716998400000')) + # def test_get_positions_history(self): + # print(self.AccountAPI.get_positions_history()) + # def test_get_instruments(self): + # print(self.AccountAPI.get_instruments(instType='SPOT')) + # def test_get_account_bills_archive(self): + # print(self.AccountAPI.get_account_bills_archive(begin='1715780962300',end='1716998400000')) # def test_positions_builder(self): # print("Both real and virtual positions and assets are calculated") # sim_pos = [{'instId': 'BTC-USDT-SWAP', 'pos': '10'}, {'instId': 'BTC-USDT-SWAP', 'pos': '10'}] @@ -124,7 +125,20 @@ class AccountTest(unittest.TestCase): # def test_simulated_margin(self): # print(self.AccountAPI.get_simulated_margin(spotOffsetType='3')) - + # def test_get_fix_loan_borrowing_limit(self): + # logger.debug(f'{self.AccountAPI.get_fix_loan_borrowing_limit()}') + # def test_get_fix_loan_borrowing_quote(self): + # logger.debug(f'{self.AccountAPI.get_fix_loan_borrowing_quote(type="normal")}') + # def test_place_fix_loan_borrowing_order(self): + # logger.debug(f'{self.AccountAPI.place_fix_loan_borrowing_order(ccy="BTC", amt="0.1515", maxRate="0.001", term="30D", reborrow=True, reborrowRate="0.01")}') + # def test_amend_fix_loan_borrowing_order(self): + # logger.debug(f'{self.AccountAPI.amend_fix_loan_borrowing_order(ordId="2407301043344857",reborrow=True,renewMaxRate="0.01")}') + # def test_fix_loan_manual_reborrow(self): + # logger.debug(f'{self.AccountAPI.fix_loan_manual_reborrow(ordId="2407301043344857",maxRate="0.1")}') + # def test_repay_fix_loan_borrowing_order(self): + # logger.info(f'{self.AccountAPI.repay_fix_loan_borrowing_order(ordId="2407301054407907")}') + # def test_get_fix_loan_borrowing_orders_list(self): + # logger.debug(self.AccountAPI.get_fix_loan_borrowing_orders_list(ordId="2407301054407907")) if __name__ == '__main__': unittest.main() diff --git a/test/SimpleEarnFixedTest.py b/test/SimpleEarnFixedTest.py new file mode 100644 index 0000000..a0a002f --- /dev/null +++ b/test/SimpleEarnFixedTest.py @@ -0,0 +1,37 @@ +import unittest + +from loguru import logger + +from okx import Account, SimpleEarnFixed + + +class SimpleEarnFixedTest(unittest.TestCase): + def setUp(self): + api_key = '15c0a341-f38c-4bf2-8f86-3c32c8b5d60c' + api_secret_key = 'DEBF51E2733E03CE4F2CEB63BB01D983' + passphrase = 'hylHYL950525,.' + self.SimpleEarnFixedAPI = SimpleEarnFixed.SimpleEarnFixedAPI(api_key, api_secret_key, passphrase, flag='1') + + # def test_get_lending_offers(self): + # logger.debug(self.SimpleEarnFixedAPI.get_lending_offers()) + # + # def test_get_instruments(self): + # logger.debug(self.SimpleEarnFixedAPI.get_lending_apy_history(ccy="BTC", term='30D')) + # + # def test_get_pending_lending_volume(self): + # logger.debug(self.SimpleEarnFixedAPI.get_pending_lending_volume(ccy="BTC", term='30D')) + # + # def test_place_lending_order(self): + # logger.debug(self.SimpleEarnFixedAPI.place_lending_order(ccy="USDT", amt="33", maxRate="1", term="30D")) + # + # def test_amend_lending_order(self): + # logger.debug(self.SimpleEarnFixedAPI.amend_lending_order(ordId="2407241551594080",changeAmt="30",autoRenewal=True)) + # + # def test_get_lending_orders_list(self): + # logger.debug(self.SimpleEarnFixedAPI.get_lending_orders_list()) + # def test_get_lending_sub_orders(self): + # logger.debug(self.SimpleEarnFixedAPI.get_lending_sub_orders(ordId="2407241453209933")) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file