feat:Support multiply trigger TP

This commit is contained in:
007live 2024-01-28 19:50:13 +08:00
parent 068c63d5c5
commit 422ee7ec8b
20 changed files with 331 additions and 261 deletions

View File

@ -1,11 +1,11 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class AccountAPI(Client): class AccountAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None,timeout = 30): def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy,timeout) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
# Get Positions # Get Positions
def get_position_risk(self, instType=''): def get_position_risk(self, instType=''):

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class BlockTradingAPI(Client): class BlockTradingAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def counterparties(self): def counterparties(self):
params = {} params = {}

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class ConvertAPI(Client): class ConvertAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True,proxy = None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def get_currencies(self): def get_currencies(self):
params = {} params = {}

View File

@ -1,12 +1,12 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class CopyTradingAPI(Client): class CopyTradingAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',
domain='https://www.okx.com', debug=True, proxy=None): domain='https://www.okx.com', debug=True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,
proxy=proxy) proxy=proxy)
# Get existing leading positions # Get existing leading positions
def get_existing_leading_positions(self, instId=''): def get_existing_leading_positions(self, instId=''):

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class EarningAPI(Client): class EarningAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def get_offers(self,productId = '',protocolType = '',ccy = ''): def get_offers(self,productId = '',protocolType = '',ccy = ''):
params = { params = {

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class FDBrokerAPI(Client): class FDBrokerAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def generate_rebate_details_download_link(self, begin ='', end = ''): def generate_rebate_details_download_link(self, begin ='', end = ''):
params = {'begin': begin, 'end': end} params = {'begin': begin, 'end': end}

View File

@ -1,12 +1,12 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class FundingAPI(Client): class FundingAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
# Get Deposit Address # Get Deposit Address
def get_deposit_address(self, ccy): def get_deposit_address(self, ccy):

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class GridAPI(Client): class GridAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def grid_order_algo(self, instId='', algoOrdType='', maxPx='', minPx='', gridNum='', runType='', tpTriggerPx='', def grid_order_algo(self, instId='', algoOrdType='', maxPx='', minPx='', gridNum='', runType='', tpTriggerPx='',
slTriggerPx='', tag='', quoteSz='', baseSz='', sz='', direction='', lever='', basePos=''): slTriggerPx='', tag='', quoteSz='', baseSz='', sz='', direction='', lever='', basePos=''):

View File

@ -1,11 +1,11 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class MarketAPI(Client): class MarketAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
# Get Tickers # Get Tickers

View File

@ -1,8 +1,8 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class NDBrokerAPI(Client): class NDBrokerAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
#GET /api/v5/broker/nd/info #GET /api/v5/broker/nd/info
def get_broker_info(self): def get_broker_info(self):

View File

@ -1,11 +1,11 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class PublicAPI(Client): class PublicAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
# Get Instruments # Get Instruments
def get_instruments(self, instType, uly='', instId='',instFamily = ''): def get_instruments(self, instType, uly='', instId='',instFamily = ''):

View File

@ -1,11 +1,11 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class SpreadTradingAPI(Client): class SpreadTradingAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
# Place Order # Place Order
def place_order(self, sprdId='', clOrdId='', tag='', side='', ordType='', sz='', px=''): def place_order(self, sprdId='', clOrdId='', tag='', side='', ordType='', sz='', px=''):

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class StatusAPI(Client): class StatusAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def status(self, state=''): def status(self, state=''):
params = {'state': state} params = {'state': state}

View File

@ -1,10 +1,10 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class SubAccountAPI(Client): class SubAccountAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def get_account_balance(self, subAcct): def get_account_balance(self, subAcct):
params = {"subAcct": subAcct} params = {"subAcct": subAcct}

View File

@ -1,21 +1,26 @@
from .client import Client import json
from .okxclient import OkxClient
from .consts import * from .consts import *
class TradeAPI(Client): class TradeAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1',
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) 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)
# Place Order # Place Order
def place_order(self, instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='', def place_order(self, instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='',
reduceOnly='', tgtCcy='', tpTriggerPx='', tpOrdPx='', slTriggerPx='', slOrdPx='', reduceOnly='', tgtCcy='', tpTriggerPx='', tpOrdPx='', slTriggerPx='', slOrdPx='',
tpTriggerPxType='', slTriggerPxType='', quickMgnType='', stpId='', stpMode=''): tpTriggerPxType='', slTriggerPxType='', quickMgnType='', stpId='', stpMode='',
attachAlgoOrds=None):
params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy, params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
'clOrdId': clOrdId, 'tag': tag, 'posSide': posSide, 'px': px, 'reduceOnly': reduceOnly, 'clOrdId': clOrdId, 'tag': tag, 'posSide': posSide, 'px': px, 'reduceOnly': reduceOnly,
'tgtCcy': tgtCcy, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx, 'slTriggerPx': slTriggerPx, 'tgtCcy': tgtCcy, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx, 'slTriggerPx': slTriggerPx,
'slOrdPx': slOrdPx, 'tpTriggerPxType': tpTriggerPxType, 'slTriggerPxType': slTriggerPxType, 'slOrdPx': slOrdPx, 'tpTriggerPxType': tpTriggerPxType, 'slTriggerPxType': slTriggerPxType,
'quickMgnType': quickMgnType, 'stpId': stpId, 'stpMode': stpMode} 'quickMgnType': quickMgnType, 'stpId': stpId, 'stpMode': stpMode}
params['attachAlgoOrds'] = attachAlgoOrds
return self._request_with_params(POST, PLACR_ORDER, params) return self._request_with_params(POST, PLACR_ORDER, params)
# Place Multiple Orders # Place Multiple Orders
@ -33,11 +38,13 @@ class TradeAPI(Client):
# Amend Order # Amend Order
def amend_order(self, instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newTpTriggerPx='', def amend_order(self, instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newTpTriggerPx='',
newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType=''): newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='',
attachAlgoOrds=''):
params = {'instId': instId, 'cxlOnFailc': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId, params = {'instId': instId, 'cxlOnFailc': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId,
'newSz': newSz, 'newPx': newPx, 'newTpTriggerPx': newTpTriggerPx, 'newTpOrdPx': newTpOrdPx, 'newSz': newSz, 'newPx': newPx, 'newTpTriggerPx': newTpTriggerPx, 'newTpOrdPx': newTpOrdPx,
'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx, 'newTpTriggerPxType': newTpTriggerPxType, 'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx, 'newTpTriggerPxType': newTpTriggerPxType,
'newSlTriggerPxType': newSlTriggerPxType} 'newSlTriggerPxType': newSlTriggerPxType}
params['attachAlgoOrds'] = attachAlgoOrds
return self._request_with_params(POST, AMEND_ORDER, params) return self._request_with_params(POST, AMEND_ORDER, params)
# Amend Multiple Orders # Amend Multiple Orders
@ -56,9 +63,10 @@ class TradeAPI(Client):
return self._request_with_params(GET, ORDER_INFO, params) return self._request_with_params(GET, ORDER_INFO, params)
# Get Order List # Get Order List
def get_order_list(self, instType='', uly='', instId='', ordType='', state='', after='', before='', limit='',instFamily = ''): def get_order_list(self, instType='', uly='', instId='', ordType='', state='', after='', before='', limit='',
instFamily=''):
params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordType': ordType, 'state': state, params = {'instType': instType, 'uly': uly, 'instId': instId, 'ordType': ordType, 'state': state,
'after': after, 'before': before, 'limit': limit,'instFamily':instFamily} 'after': after, 'before': before, 'limit': limit, 'instFamily': instFamily}
return self._request_with_params(GET, ORDERS_PENDING, params) return self._request_with_params(GET, ORDERS_PENDING, params)
# Get Order History (last 7 days # Get Order History (last 7 days
@ -78,9 +86,9 @@ class TradeAPI(Client):
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=''):
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}
return self._request_with_params(GET, ORDER_FILLS, params) return self._request_with_params(GET, ORDER_FILLS, params)
# Place Algo Order # Place Algo Order
@ -90,16 +98,17 @@ class TradeAPI(Client):
triggerPx='', orderPx='', tgtCcy='', pxVar='', triggerPx='', orderPx='', tgtCcy='', pxVar='',
pxSpread='', pxSpread='',
szLimit='', pxLimit='', timeInterval='', tpTriggerPxType='', slTriggerPxType='', szLimit='', pxLimit='', timeInterval='', tpTriggerPxType='', slTriggerPxType='',
callbackRatio='',callbackSpread='',activePx='',tag='',triggerPxType='',closeFraction='' callbackRatio='', callbackSpread='', activePx='', tag='', triggerPxType='', closeFraction=''
,quickMgnType='',algoClOrdId=''): , quickMgnType='', algoClOrdId=''):
params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy, params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
'posSide': posSide, 'reduceOnly': reduceOnly, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx, 'posSide': posSide, 'reduceOnly': reduceOnly, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx,
'slTriggerPx': slTriggerPx, 'slOrdPx': slOrdPx, 'triggerPx': triggerPx, 'orderPx': orderPx, 'slTriggerPx': slTriggerPx, 'slOrdPx': slOrdPx, 'triggerPx': triggerPx, 'orderPx': orderPx,
'tgtCcy': tgtCcy, 'pxVar': pxVar, 'szLimit': szLimit, 'pxLimit': pxLimit, 'tgtCcy': tgtCcy, 'pxVar': pxVar, 'szLimit': szLimit, 'pxLimit': pxLimit,
'timeInterval': timeInterval, 'timeInterval': timeInterval,
'pxSpread': pxSpread, 'tpTriggerPxType': tpTriggerPxType, 'slTriggerPxType': slTriggerPxType, 'pxSpread': pxSpread, 'tpTriggerPxType': tpTriggerPxType, 'slTriggerPxType': slTriggerPxType,
'callbackRatio' : callbackRatio, 'callbackSpread':callbackSpread,'activePx':activePx, 'callbackRatio': callbackRatio, 'callbackSpread': callbackSpread, 'activePx': activePx,
'tag':tag,'triggerPxType':triggerPxType,'closeFraction':closeFraction,'quickMgnType':quickMgnType,'algoClOrdId':algoClOrdId} 'tag': tag, 'triggerPxType': triggerPxType, 'closeFraction': closeFraction,
'quickMgnType': quickMgnType, 'algoClOrdId': algoClOrdId}
return self._request_with_params(POST, PLACE_ALGO_ORDER, params) return self._request_with_params(POST, PLACE_ALGO_ORDER, params)
# Cancel Algo Order # Cancel Algo Order
@ -107,11 +116,12 @@ class TradeAPI(Client):
return self._request_with_params(POST, CANCEL_ALGOS, params) return self._request_with_params(POST, CANCEL_ALGOS, params)
# Cancel Advance Algos # Cancel Advance Algos
def cancel_advance_algos(self,params): def cancel_advance_algos(self, params):
return self._request_with_params(POST, Cancel_Advance_Algos, params) return self._request_with_params(POST, Cancel_Advance_Algos, params)
# Get Algo Order List # Get Algo Order List
def order_algos_list(self, ordType='', algoId='', instType='', instId='', after='', before='', limit='',algoClOrdId=''): def order_algos_list(self, ordType='', algoId='', instType='', instId='', after='', before='', limit='',
algoClOrdId=''):
params = {'ordType': ordType, 'algoId': algoId, 'instType': instType, 'instId': instId, 'after': after, params = {'ordType': ordType, 'algoId': algoId, 'instType': instType, 'instId': instId, 'after': after,
'before': before, 'limit': limit, 'algoClOrdId': algoClOrdId} 'before': before, 'limit': limit, 'algoClOrdId': algoClOrdId}
return self._request_with_params(GET, ORDERS_ALGO_OENDING, params) return self._request_with_params(GET, ORDERS_ALGO_OENDING, params)
@ -123,49 +133,49 @@ class TradeAPI(Client):
return self._request_with_params(GET, ORDERS_ALGO_HISTORY, params) return self._request_with_params(GET, ORDERS_ALGO_HISTORY, params)
# Get Transaction Details History # Get Transaction Details History
def get_fills_history(self, instType, uly='', instId='', ordId='', after='', before='', limit='',instFamily=''): def get_fills_history(self, instType, uly='', instId='', ordId='', after='', before='', limit='', instFamily=''):
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}
return self._request_with_params(GET, ORDERS_FILLS_HISTORY, params) return self._request_with_params(GET, ORDERS_FILLS_HISTORY, params)
def get_easy_convert_currency_list(self): def get_easy_convert_currency_list(self):
return self._request_without_params(GET, EASY_CONVERT_CURRENCY_LIST) return self._request_without_params(GET, EASY_CONVERT_CURRENCY_LIST)
def easy_convert(self,fromCcy = [],toCcy = ''): def easy_convert(self, fromCcy=[], toCcy=''):
params = { params = {
'fromCcy':fromCcy, 'fromCcy': fromCcy,
'toCcy':toCcy 'toCcy': toCcy
} }
return self._request_with_params(POST, EASY_CONVERT, params) return self._request_with_params(POST, EASY_CONVERT, params)
def get_easy_convert_history(self,before = '',after = '',limit = ''): def get_easy_convert_history(self, before='', after='', limit=''):
params = { params = {
'before':before, 'before': before,
'after':after, 'after': after,
'limit':limit 'limit': limit
} }
return self._request_with_params(GET,CONVERT_EASY_HISTORY,params) return self._request_with_params(GET, CONVERT_EASY_HISTORY, params)
def get_oneclick_repay_list(self,debtType = ''): def get_oneclick_repay_list(self, debtType=''):
params = { params = {
'debtType':debtType 'debtType': debtType
} }
return self._request_with_params(GET,ONE_CLICK_REPAY_SUPPORT,params) return self._request_with_params(GET, ONE_CLICK_REPAY_SUPPORT, params)
def oneclick_repay(self,debtCcy = [] , repayCcy=''): def oneclick_repay(self, debtCcy=[], repayCcy=''):
params = { params = {
'debtCcy':debtCcy, 'debtCcy': debtCcy,
'repayCcy':repayCcy 'repayCcy': repayCcy
} }
return self._request_with_params(POST,ONE_CLICK_REPAY,params) return self._request_with_params(POST, ONE_CLICK_REPAY, params)
def oneclick_repay_history(self,after = '',before = '',limit = ''): def oneclick_repay_history(self, after='', before='', limit=''):
params = { params = {
'after':after, 'after': after,
'before':before, 'before': before,
'limit':limit 'limit': limit
} }
return self._request_with_params(GET,ONE_CLICK_REPAY_HISTORY,params) return self._request_with_params(GET, ONE_CLICK_REPAY_HISTORY, params)
# Get algo order details # Get algo order details
def get_algo_order_details(self, algoId='', algoClOrdId=''): def get_algo_order_details(self, algoId='', algoClOrdId=''):

View File

@ -1,11 +1,11 @@
from .client import Client from .okxclient import OkxClient
from .consts import * from .consts import *
class TradingDataAPI(Client): class TradingDataAPI(OkxClient):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, 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=False, flag='1', domain = 'https://www.okx.com',debug = True, proxy=None):
Client.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug,proxy) OkxClient.__init__(self, api_key, api_secret_key, passphrase, use_server_time, flag, domain, debug, proxy)
def get_support_coin(self): def get_support_coin(self):

View File

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

View File

@ -6,10 +6,10 @@ from httpx import Client
from . import consts as c, utils, exceptions from . import consts as c, utils, exceptions
class Client(Client): class OkxClient(Client):
def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',base_api=c.API_URL, debug='True', proxy=None): def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1',base_api=c.API_URL, debug='True', proxy=None):
super().__init__(base_url=base_api, http2=True, proxy= proxy) super().__init__(base_url=base_api, http2=True, proxy=proxy)
self.API_KEY = api_key self.API_KEY = api_key
self.API_SECRET_KEY = api_secret_key self.API_SECRET_KEY = api_secret_key
self.PASSPHRASE = passphrase self.PASSPHRASE = passphrase

View File

@ -1,78 +1,80 @@
import unittest import unittest
from okx import Account from okx import Account
class AccountTest(unittest.TestCase): class AccountTest(unittest.TestCase):
def setUp(self): def setUp(self):
proxy = "http://125.106.203.126:10423"; proxy = "http://43.152.113.72:19206"
api_key = 'aee24256-7393-422f-90d9-47cc4028ce39' api_key = 'your_apiKey'
api_secret_key = 'FF517E627F6A702E2BF50F311F245D2A' api_secret_key = 'your_secretKey'
passphrase = 'hylHYL950525,.' passphrase = 'your_secretKey'
self.AccountAPI = Account.AccountAPI(api_key, api_secret_key, passphrase, use_server_time=False, flag='1',proxy=proxy,timeout=30) self.AccountAPI = Account.AccountAPI(api_key, api_secret_key, passphrase, use_server_time=False, flag='1', proxy=proxy)
# ''' # '''
POSITIONS_HISTORY = '/api/v5/account/positions-history' #need add # POSITIONS_HISTORY = '/api/v5/account/positions-history' #need add
GET_PM_LIMIT = '/api/v5/account/position-tiers' #need add # GET_PM_LIMIT = '/api/v5/account/position-tiers' #need add
ACCOUNT_RISK = '/api/v5/account/risk-state' #need add # ACCOUNT_RISK = '/api/v5/account/risk-state' #need add
# def test_account_risk(self): # def test_account_risk(self):
# print(self.AccountAPI.get_account_risk()) # print(self.AccountAPI.get_account_risk())
# #
# def test_get_pm_limit(self): # def test_get_pm_limit(self):
# print(self.AccountAPI.get_pm_limit("SWAP","BTC-USDT")) # print(self.AccountAPI.get_pm_limit("SWAP","BTC-USDT"))
#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_user_config(self): # def test_get_user_config(self):
print(self.AccountAPI.get_account_config()) # print(self.AccountAPI.get_account_config())
def test_get_positions(self): # def test_get_positions(self):
print(self.AccountAPI.get_positions("SWAP")) # print(self.AccountAPI.get_positions("SWAP"))
def test_get_balance(self): # def test_get_balance(self):
print(self.AccountAPI.get_account()) # print(self.AccountAPI.get_account())
def test_get_positions_risk(self): # def test_get_positions_risk(self):
print(self.AccountAPI.get_position_risk("SWAP")) # print(self.AccountAPI.get_position_risk("SWAP"))
def test_get_bills(self): # def test_get_bills(self):
print(self.AccountAPI.get_bills_detail()) # print(self.AccountAPI.get_bills_detail())
#
def test_get_bills_arch(self): # def test_get_bills_arch(self):
print(self.AccountAPI.get_bills_details()) # print(self.AccountAPI.get_bills_details())
def test_set_position_mode(self): # def test_set_position_mode(self):
print(self.AccountAPI.set_position_mode("long_short_mode")) # print(self.AccountAPI.set_position_mode("long_short_mode"))
def test_set_leverage(self): # def test_set_leverage(self):
print(self.AccountAPI.set_leverage(instId="BTC-USDT",lever="5",mgnMode="isolated")) # print(self.AccountAPI.set_leverage(instId="BTC-USDT",lever="5",mgnMode="isolated"))
def test_get_max_avaliable_size(self): # def test_get_max_avaliable_size(self):
print(self.AccountAPI.get_max_avail_size(instId="BTC-USDT",tdMode="cash")) # print(self.AccountAPI.get_max_avail_size(instId="BTC-USDT",tdMode="cash"))
def test_get_max_size(self): # def test_get_max_size(self):
print(self.AccountAPI.get_maximum_trade_size(instId="BTC-USDT",tdMode="cash")) # print(self.AccountAPI.get_maximum_trade_size(instId="BTC-USDT",tdMode="cash"))
def test_get_positions(self): # def test_get_positions(self):
print(self.AccountAPI.get_positions("MARGIN")) # print(self.AccountAPI.get_positions("MARGIN"))
def test_set_margin_balance(self): # def test_set_margin_balance(self):
print(self.AccountAPI.Adjustment_margin(instId="BTC-USDT",posSide="net",type="add",amt="1")) # print(self.AccountAPI.Adjustment_margin(instId="BTC-USDT",posSide="net",type="add",amt="1"))
def test_get_lev_info(self): # def test_get_lev_info(self):
print(self.AccountAPI.get_leverage("BTC-USDT","cross")); # print(self.AccountAPI.get_leverage("BTC-USDT","cross"));
def test_get_max_loan(self): # def test_get_max_loan(self):
print(self.AccountAPI.get_max_loan("BTC-USDT","cross","USDT")) # print(self.AccountAPI.get_max_loan("BTC-USDT","cross","USDT"))
def test_get_trade_fee(self): # def test_get_trade_fee(self):
print(self.AccountAPI.get_fee_rates("SPOT")) # print(self.AccountAPI.get_fee_rates("SPOT"))
def test_get_insterested_accrued(self): # def test_get_insterested_accrued(self):
print(self.AccountAPI.get_interest_accrued()) # print(self.AccountAPI.get_interest_accrued())
def test_get_interestred_rate(self): # def test_get_interestred_rate(self):
print(self.AccountAPI.get_interest_rate()) # print(self.AccountAPI.get_interest_rate())
def test_set_greeks(self): # def test_set_greeks(self):
print(self.AccountAPI.set_greeks("BS")) # print(self.AccountAPI.set_greeks("BS"))
#
def test_set_isolated_mode(self): # def test_set_isolated_mode(self):
print(self.AccountAPI.set_isolated_mode("automatic","MARGIN")) # print(self.AccountAPI.set_isolated_mode("automatic","MARGIN"))
def test_set_max_withdraw(self): # def test_set_max_withdraw(self):
print(self.AccountAPI.get_max_withdrawal("USDT")) # print(self.AccountAPI.get_max_withdrawal("USDT"))
def test_borrow_repay(self): # def test_borrow_repay(self):
print(self.AccountAPI.borrow_repay("BTC","borrow","1.0")) # print(self.AccountAPI.borrow_repay("BTC","borrow","1.0"))
def test_borrow_repay_history(self): # def test_borrow_repay_history(self):
print(self.AccountAPI.get_borrow_repay_history()) # print(self.AccountAPI.get_borrow_repay_history())
def test_get_interest_limits(self): # def test_get_interest_limits(self):
print(self.AccountAPI.get_interest_limits()) # print(self.AccountAPI.get_interest_limits())
def test_simulated_margin(self): # def test_simulated_margin(self):
print(self.AccountAPI.get_simulated_margin()) # print(self.AccountAPI.get_simulated_margin())
def test_get_greeks(self): # def test_get_greeks(self):
print(self.AccountAPI.get_greeks()) # print(self.AccountAPI.get_greeks())
# ''' # '''
# def test_simulated_margin(self): # def test_simulated_margin(self):
# print(self.AccountAPI.get_simulated_margin()) # print(self.AccountAPI.get_simulated_margin())
@ -103,7 +105,9 @@ class AccountTest(unittest.TestCase):
# def test_borrow_repay(self): # def test_borrow_repay(self):
# print(self.AccountAPI.borrow_repay("BTC", "borrow", "1.0")) # print(self.AccountAPI.borrow_repay("BTC", "borrow", "1.0"))
def test_simulated_margin(self): # def test_simulated_margin(self):
print(self.AccountAPI.get_simulated_margin(spotOffsetType='3')) # print(self.AccountAPI.get_simulated_margin(spotOffsetType='3'))
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()

View File

@ -1,117 +1,171 @@
import unittest import unittest
from okx import Trade from okx import Trade
class TradeTest(unittest.TestCase): class TradeTest(unittest.TestCase):
def setUp(self): def setUp(self):
api_key = 'your_apiKey' api_key = 'your_apiKey'
api_secret_key = 'your_secretKey' api_secret_key = 'your_secretKey'
passphrase = 'your_secretKey' passphrase = 'your_secretKey'
self.tradeApi = Trade.TradeAPI(api_key, api_secret_key, passphrase, False, '1') self.tradeApi = Trade.TradeAPI(api_key, api_secret_key, passphrase, False, '1')
"""
def test_place_order(self):
print(self.tradeApi.place_order("BTC-USDT",tdMode="cross",clOrdId="asCai1",side="buy",ordType="limit",sz="0.01",px="18000"))
def test_cancel_order(self):
print(self.tradeApi.cancel_order(instId="ETH-USDT",ordId="480702180748558336"))
def test_batch_order(self): # # """
orderData = [ { # def test_place_order(self):
"instId":"ETH-USDT", # attachAlgoOrds = [{'tpTriggerPx': '49000.0', 'tpOrdPx': '-1', 'sz': '1', 'tpTriggerPxType': 'last'}];
"tdMode":"cross", # print(self.tradeApi.place_order(
"clOrdId":"b151121", # "BTC-USDT-SWAP", tdMode="isolated", clOrdId="asCai1234", side='buy', posSide="long", ordType="limit",
"side":"buy", # sz="1",
"ordType":"limit", # px="30000.0",
"px":"2.15", # attachAlgoOrds=attachAlgoOrds)
"sz":"2" # );
}, #
{ # attachAlgoOrds = [{'slTriggerPx': '25000.0', 'slOrdPx': '-1', 'sz': '1', 'slTriggerPxType': 'last'}];
"instId":"BTC-USDT", # print(self.tradeApi.place_order(
"tdMode":"cross", # "BTC-USDT-SWAP", tdMode="isolated", clOrdId="asCai1234", side='buy', posSide="long", ordType="limit",
"clOrdId":"b152233", # sz="1",
"side":"buy", # px="30000.0",
"ordType":"limit", # attachAlgoOrds=attachAlgoOrds)
"px":"2.15", # );
"sz":"2" #
}] # attachAlgoOrds = [
print(self.tradeApi.place_multiple_orders(orderData)) # {
#480702180748558336 # "tpTriggerPxType": "last",
def test_cancel_batch_orders(self): # "tpOrdPx": "-1",
data=[ # "tpTriggerPx": "34000",
{ # "sz": "1"
'instId':"ETH-USDT", # },
'ordId':"480702885353881600" # {
}, # "tpTriggerPxType": "last",
{ # "tpOrdPx": "-1",
'instId':"BTC-USDT", # "tpTriggerPx": "35000",
'ordId':'480702885353881601' # "sz": "1"
} # },
] # {
print(self.tradeApi.cancel_multiple_orders(data)) # "slTriggerPxType": "last",
def test_amend_order(self): # "slOrdPx": "-1",
print(self.tradeApi.amend_order("BTC-USDT",ordId="480706017781743616",newSz="0.03")) # "slTriggerPx": "20000",
def test_amend_order_batch(self): # "sz": "3"
orderData = [ # }
{ # ]
'instId':'ETH-USDT', # print(self.tradeApi.place_order(
'ordId':'480707205436669952', # "BTC-USDT-SWAP", tdMode="isolated", clOrdId="asCai1234", side='buy', posSide="long", ordType="limit",
'newSz':'0.02' # sz="1",
}, # px="30000.0",
{ # attachAlgoOrds=attachAlgoOrds)
'instId':'BTC-USDT', # );
'ordId':'480707205436669953',
'newPx':'3.0'
}
]
print(self.tradeApi.amend_multiple_orders(orderData))
def test_close_all_positions(self):
print(self.tradeApi.close_positions("BTC-USDT",mgnMode="cross"))
def test_get_order_info(self):
print(self.tradeApi.get_orders("ETH-USDT","480707205436669952"))
def test_get_order_pending(self):
print(self.tradeApi.get_order_list("SPOT"))
def test_get_order_history(self):
print(self.tradeApi.get_orders_history("SPOT"))
def test_get_order_histry_archive(self):
print(self.tradeApi.orders_history_archive("SPOT"))
def test_get_fills(self):
print(self.tradeApi.get_fills("SPOT"))
def test_get_fills_history(self):
print(self.tradeApi.get_fills_history("SPOT"))
def test_get_order_algo_pending(self):
print(self.tradeApi.order_algos_list('oco'))
def test_order_algo(self):
print(self.tradeApi.place_algo_order('BTC-USDT-SWAP', 'cross', side='buy', ordType='trigger', posSide='long',
sz='100', triggerPx='22000', triggerPxType ='index', orderPx='-1'))
def test_cancel_algos(self):
params = [{
'algoId': '485903392536264704',
'instId': 'BTC-USDT-SWAP'
}]
# def test_cancel_order(self):
# print(self.tradeApi.cancel_order(instId="ETH-USDT",ordId="480702180748558336"))
print(self.tradeApi.cancel_algo_order(params)) # def test_batch_order(self):
def test_cancel_adv_algos(self): # orderData = [{
params = [{ # "instId": "BTC-USDT-SWAP",
'algoId': '485936482235191296', # "tdMode": "isolated",
'instId': 'BTC-USDT-SWAP' # "clOrdId": "b15112122",
}] # "side": "buy",
# "posSide": "long",
# "ordType": "limit",
# "px": "30000.0",
# "sz": "2",
# "attachAlgoOrds": [{'tpTriggerPx': '50000.0', 'tpOrdPx': '-1', 'sz': '1', 'tpTriggerPxType': 'last'}]
# },
# {
# "instId": "BTC-USDT-SWAP",
# "tdMode": "isolated",
# "clOrdId": "b15112111",
# "side": "buy",
# "posSide": "long",
# "ordType": "limit",
# "px": "31000.0",
# "sz": "2",
# "attachAlgoOrds": [{'tpTriggerPx': '51000.0', 'tpOrdPx': '-1', 'sz': '1', 'tpTriggerPxType': 'last'}]
# }
# ]
#
# print(self.tradeApi.place_multiple_orders(orderData))
print(self.tradeApi.cancel_advance_algos(params))) # 480702180748558336
def test_orders_algo_pending(self): # def test_cancel_batch_orders(self):
print(self.tradeApi.order_algos_list(ordType='iceberg')) # data=[
def test_algo_order_history(self): # {
print(self.tradeApi.order_algos_history(algoId='485903392536264704',ordType='conditional')) # 'instId':"ETH-USDT",
def test_get_easy_convert_list(self): # 'ordId':"480702885353881600"
print(self.tradeApi.get_easy_convert_currency_list()) # },
def test_easy_convert(self): # {
print(self.tradeApi.easy_convert(fromCcy=['BTC'],toCcy='OKB')) # 'instId':"BTC-USDT",
def test_get_convert_history(self): # 'ordId':'480702885353881601'
print(self.tradeApi.get_easy_convert_history()) # }
def test_get_oneclick_repay_support_list(self): # ]
print(self.tradeApi.get_oneclick_repay_list('cross')) # print(self.tradeApi.cancel_multiple_orders(data))
def test_oneclick_repay(self): # def test_amend_order(self):
print(self.tradeApi.oneclick_repay(['BTC'],'USDT')) # attachAlgoOrds = [{'attachAlgoId': '672081789170569217', 'newTpTriggerPx': '55000.0'}];
""" # print(self.tradeApi.amend_order("BTC-USDT-SWAP", ordId="672081789170569216", newSz="1",
#485903392536264704 # attachAlgoOrds=attachAlgoOrds))
#485936482235191296
# def test_amend_order_batch(self):
# orderData = [
# {
# 'instId': 'BTC-USDT-SWAP',
# 'ordId': '672081789170569216',
# 'newSz': '1',
# "attachAlgoOrds": [{'attachAlgoId': '672081789170569217', 'newTpTriggerPx': '53000.0'}]
# }
# ]
#
# print(self.tradeApi.amend_multiple_orders(orderData))
# def test_close_all_positions(self):
# print(self.tradeApi.close_positions("BTC-USDT",mgnMode="cross"))
# def test_get_order_info(self):
# print(self.tradeApi.get_orders("ETH-USDT","480707205436669952"))
# def test_get_order_pending(self):
# print(self.tradeApi.get_order_list("SPOT"))
# def test_get_order_history(self):
# print(self.tradeApi.get_orders_history("SPOT"))
# def test_get_order_histry_archive(self):
# print(self.tradeApi.orders_history_archive("SPOT"))
# def test_get_fills(self):
# print(self.tradeApi.get_fills("SPOT"))
# def test_get_fills_history(self):
# print(self.tradeApi.get_fills_history("SPOT"))
# def test_get_order_algo_pending(self):
# print(self.tradeApi.order_algos_list('oco'))
# def test_order_algo(self):
# print(self.tradeApi.place_algo_order('BTC-USDT-SWAP', 'cross', side='buy', ordType='trigger', posSide='long',
# sz='100', triggerPx='22000', triggerPxType ='index', orderPx='-1'))
# def test_cancel_algos(self):
# params = [{
# 'algoId': '485903392536264704',
# 'instId': 'BTC-USDT-SWAP'
# }]
#
#
# print(self.tradeApi.cancel_algo_order(params))
# def test_cancel_adv_algos(self):
# params = [{
# 'algoId': '485936482235191296',
# 'instId': 'BTC-USDT-SWAP'
# }]
#
# print(self.tradeApi.cancel_advance_algos(params)))
# def test_orders_algo_pending(self):
# print(self.tradeApi.order_algos_list(ordType='iceberg'))
# def test_algo_order_history(self):
# print(self.tradeApi.order_algos_history(algoId='485903392536264704',ordType='conditional'))
# def test_get_easy_convert_list(self):
# print(self.tradeApi.get_easy_convert_currency_list())
# def test_easy_convert(self):
# print(self.tradeApi.easy_convert(fromCcy=['BTC'],toCcy='OKB'))
# def test_get_convert_history(self):
# print(self.tradeApi.get_easy_convert_history())
# def test_get_oneclick_repay_support_list(self):
# print(self.tradeApi.get_oneclick_repay_list('cross'))
# def test_oneclick_repay(self):
# print(self.tradeApi.oneclick_repay(['BTC'],'USDT'))
# """
# 485903392536264704
# 485936482235191296
# def test_oneclick_repay_history(self): # def test_oneclick_repay_history(self):
# print(self.tradeApi.oneclick_repay_history()) # print(self.tradeApi.oneclick_repay_history())
# def test_order_algo(self): # def test_order_algo(self):
@ -122,7 +176,7 @@ class TradeTest(unittest.TestCase):
# def test_get_algo_order_details(self): # def test_get_algo_order_details(self):
# print(self.tradeApi.get_algo_order_details(algoId='581628185981308928')) # print(self.tradeApi.get_algo_order_details(algoId='581628185981308928'))
#581628185981308928 # 581628185981308928
# def test_amend_algo_order(self): # def test_amend_algo_order(self):
# print(self.tradeApi.amend_algo_order(instId='BTC-USDT-SWAP', algoId='581628185981308928',newSz='3')) # print(self.tradeApi.amend_algo_order(instId='BTC-USDT-SWAP', algoId='581628185981308928',newSz='3'))
@ -155,8 +209,8 @@ class TradeTest(unittest.TestCase):
# }] # }]
# print(self.tradeApi.place_multiple_orders(orderData)) # print(self.tradeApi.place_multiple_orders(orderData))
#581616258865516544 # 581616258865516544
#581616258865516545 # 581616258865516545
# def test_amend_order(self): # def test_amend_order(self):
# print(self.tradeApi.amend_order("BTC-USDT", ordId="581616258865516544", newSz="0.03")) # print(self.tradeApi.amend_order("BTC-USDT", ordId="581616258865516544", newSz="0.03"))
# def test_amend_order_batch(self): # def test_amend_order_batch(self):
@ -179,13 +233,15 @@ class TradeTest(unittest.TestCase):
# print(self.tradeApi.place_algo_order(instId='BTC-USDT-SWAP', tdMode='cross', side='buy', ordType='conditional', \ # print(self.tradeApi.place_algo_order(instId='BTC-USDT-SWAP', tdMode='cross', side='buy', ordType='conditional', \
# tpTriggerPx='15', tpOrdPx='18', sz='2',algoClOrdId='7678687',quickMgnType='manual')) # tpTriggerPx='15', tpOrdPx='18', sz='2',algoClOrdId='7678687',quickMgnType='manual'))
def test_order_algos_list(self): # def test_order_algos_list(self):
print(self.tradeApi.order_algos_list(ordType='conditional')) # print(self.tradeApi.order_algos_list(ordType='conditional'))
# def test_order_algo(self): # def test_order_algo(self):
# print(self.tradeApi.place_order(instId='BTC-USDT-SWAP', tdMode='cross', side='buy',px='121',sz='2', # print(self.tradeApi.place_order(instId='BTC-USDT-SWAP', tdMode='cross', side='buy',px='121',sz='2',
# clOrdId='234234565535',ordType='market')) # clOrdId='234234565535',ordType='market'))
# def test_close_all_positions(self): # def test_close_all_positions(self):
# print(self.tradeApi.close_positions(instId="BTC-USDT-SWAP", mgnMode="cross",clOrdId='1213124')) # print(self.tradeApi.close_positions(instId="BTC-USDT-SWAP", mgnMode="cross",clOrdId='1213124'))
if __name__=='__main__':
if __name__ == '__main__':
unittest.main() unittest.main()