add new api and extend new apram

This commit is contained in:
007live 2024-05-31 12:01:59 +08:00
parent ef7e4f3a21
commit 2a796ab74d
6 changed files with 16 additions and 7 deletions

View File

@ -49,9 +49,9 @@ class AccountAPI(OkxClient):
# Get Bills Details (recent 3 months) # Get Bills Details (recent 3 months)
def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='', def get_account_bills_archive(self, instType='', ccy='', mgnMode='', ctType='', type='', subType='', after='', before='',
limit=''): limit='',begin='',end=''):
params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type, params = {'instType': instType, 'ccy': ccy, 'mgnMode': mgnMode, 'ctType': ctType, 'type': type,
'subType': subType, 'after': after, 'before': before, 'limit': limit} 'subType': subType, 'after': after, 'before': before, 'limit': limit,'begin':begin,'end':end}
return self._request_with_params(GET, BILLS_ARCHIVE, params) return self._request_with_params(GET, BILLS_ARCHIVE, params)
# Get Account Configuration # Get Account Configuration
@ -88,6 +88,10 @@ class AccountAPI(OkxClient):
def get_leverage(self, instId, mgnMode): def get_leverage(self, instId, mgnMode):
params = {'instId': instId, 'mgnMode': mgnMode} params = {'instId': instId, 'mgnMode': mgnMode}
return self._request_with_params(GET, GET_LEVERAGE, params) return self._request_with_params(GET, GET_LEVERAGE, params)
# Get instruments
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)
# Get the maximum loan of isolated MARGIN # Get the maximum loan of isolated MARGIN
def get_max_loan(self, instId, mgnMode, mgnCcy): def get_max_loan(self, instId, mgnMode, mgnCcy):

View File

@ -86,9 +86,9 @@ class TradeAPI(OkxClient):
return self._request_with_params(GET, ORDERS_HISTORY_ARCHIVE, params) return self._request_with_params(GET, ORDERS_HISTORY_ARCHIVE, params)
# Get Transaction Details # Get Transaction Details
def get_fills(self, instType='', uly='', instId='', ordId='', after='', before='', limit='', instFamily=''): def get_fills(self, instType='', uly='', instId='', ordId='', after='', before='', limit='', instFamily='',begin='',end=''):
params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordId': ordId, 'after': after, 'before': before, params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordId': ordId, 'after': after, 'before': before,
'limit': limit, 'instFamily': instFamily} 'limit': limit, 'instFamily': instFamily,'begin': begin, 'end' :end}
return self._request_with_params(GET, ORDER_FILLS, params) return self._request_with_params(GET, ORDER_FILLS, params)
# Place Algo Order # Place Algo Order

View File

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

View File

@ -54,6 +54,7 @@ SET_RISK_OFFSET_TYPE = '/api/v5/account/set-riskOffset-type'
SET_AUTO_LOAN = '/api/v5/account/set-auto-loan' SET_AUTO_LOAN = '/api/v5/account/set-auto-loan'
ACTIVSTE_OPTION = '/api/v5/account/activate-option' ACTIVSTE_OPTION = '/api/v5/account/activate-option'
POSITION_BUILDER = '/api/v5/account/position-builder' POSITION_BUILDER = '/api/v5/account/position-builder'
GET_INSTRUMENTS = '/api/v5/account/instruments'
# 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

@ -23,6 +23,10 @@ class AccountTest(unittest.TestCase):
# positions-history # positions-history
def test_get_positions_history(self): def test_get_positions_history(self):
print(self.AccountAPI.get_positions_history()) 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): # def test_positions_builder(self):
# print("Both real and virtual positions and assets are calculated") # print("Both real and virtual positions and assets are calculated")
# sim_pos = [{'instId': 'BTC-USDT-SWAP', 'pos': '10'}, {'instId': 'BTC-USDT-SWAP', 'pos': '10'}] # sim_pos = [{'instId': 'BTC-USDT-SWAP', 'pos': '10'}, {'instId': 'BTC-USDT-SWAP', 'pos': '10'}]

View File

@ -125,8 +125,8 @@ class TradeTest(unittest.TestCase):
# print(self.tradeApi.get_orders_history("SPOT")) # print(self.tradeApi.get_orders_history("SPOT"))
# def test_get_order_histry_archive(self): # def test_get_order_histry_archive(self):
# print(self.tradeApi.orders_history_archive("SPOT")) # print(self.tradeApi.orders_history_archive("SPOT"))
# def test_get_fills(self): def test_get_fills(self):
# print(self.tradeApi.get_fills("SPOT")) print(self.tradeApi.get_fills(begin='1717045609000',end='1717045609100'))
# def test_get_fills_history(self): # def test_get_fills_history(self):
# print(self.tradeApi.get_fills_history("SPOT")) # print(self.tradeApi.get_fills_history("SPOT"))
# def test_get_order_algo_pending(self): # def test_get_order_algo_pending(self):