Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add api changes
  • Loading branch information
jason.hsu
jason.hsu committed Dec 19, 2025
commit e8084271d1b8c7a092a272b47271ca73e2475027
4 changes: 3 additions & 1 deletion okx/Account.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ def get_instruments(self, instType='', ugly='', instFamily='', instId=''):
return self._request_with_params(GET, GET_INSTRUMENTS, params)

# Get the maximum loan of isolated MARGIN
def get_max_loan(self, instId, mgnMode, mgnCcy=''):
def get_max_loan(self, instId, mgnMode, mgnCcy='', tradeQuoteCcy=None):
params = {'instId': instId, 'mgnMode': mgnMode, 'mgnCcy': mgnCcy}
if tradeQuoteCcy is not None:
params['tradeQuoteCcy'] = tradeQuoteCcy
return self._request_with_params(GET, MAX_LOAN, params)

# Get Fee Rates
Expand Down
8 changes: 6 additions & 2 deletions okx/Grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_serve
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='',
slTriggerPx='', tag='', quoteSz='', baseSz='', sz='', direction='', lever='', basePos=''):
slTriggerPx='', tag='', quoteSz='', baseSz='', sz='', direction='', lever='', basePos='', tradeQuoteCcy=None):
params = {'instId': instId, 'algoOrdType': algoOrdType, 'maxPx': maxPx, 'minPx': minPx, 'gridNum': gridNum,
'runType': runType, 'tpTriggerPx': tpTriggerPx, 'slTriggerPx': slTriggerPx, 'tag': tag,
'quoteSz': quoteSz, 'baseSz': baseSz, 'sz': sz, 'direction': direction, 'lever': lever,
'basePos': basePos}
if tradeQuoteCcy is not None:
params['tradeQuoteCcy'] = tradeQuoteCcy
return self._request_with_params(POST, GRID_ORDER_ALGO, params)

def grid_amend_order_algo(self, algoId='', instId='', slTriggerPx='', tpTriggerPx=''):
Expand Down Expand Up @@ -79,11 +81,13 @@ def grid_ai_param(self, algoOrdType='', instId='', direction='', duration=''):

# - Place recurring buy order
def place_recurring_buy_order(self, stgyName='', recurringList=[], period='', recurringDay='', recurringTime='',
timeZone='', amt='', investmentCcy='', tdMode='', algoClOrdId='', tag=''):
timeZone='', amt='', investmentCcy='', tdMode='', algoClOrdId='', tag='', tradeQuoteCcy=None):
params = {'stgyName': stgyName, 'recurringList': recurringList, 'period': period, 'recurringDay': recurringDay,
'recurringTime': recurringTime,
'timeZone': timeZone, 'amt': amt, 'investmentCcy': investmentCcy, 'tdMode': tdMode,
'algoClOrdId': algoClOrdId, 'tag': tag}
if tradeQuoteCcy is not None:
params['tradeQuoteCcy'] = tradeQuoteCcy
return self._request_with_params(POST, PLACE_RECURRING_BUY_ORDER, params)

# - Amend recurring buy order
Expand Down
26 changes: 19 additions & 7 deletions okx/Trade.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ def __init__(self, api_key='-1', api_secret_key='-1', passphrase='-1', use_serve

# Place Order
def place_order(self, instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='',
reduceOnly='', tgtCcy='', stpMode='', attachAlgoOrds=None, pxUsd='', pxVol='', banAmend='', tradeQuoteCcy=''):
reduceOnly='', tgtCcy='', stpMode='', attachAlgoOrds=None, pxUsd='', pxVol='', banAmend='', tradeQuoteCcy=None, pxAmendType=None):
params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
'clOrdId': clOrdId, 'tag': tag, 'posSide': posSide, 'px': px, 'reduceOnly': reduceOnly,
'tgtCcy': tgtCcy, 'stpMode': stpMode, 'pxUsd': pxUsd, 'pxVol': pxVol, 'banAmend': banAmend, 'tradeQuoteCcy': tradeQuoteCcy}
'tgtCcy': tgtCcy, 'stpMode': stpMode, 'pxUsd': pxUsd, 'pxVol': pxVol, 'banAmend': banAmend}
if tradeQuoteCcy is not None:
params['tradeQuoteCcy'] = tradeQuoteCcy
if pxAmendType is not None:
params['pxAmendType'] = pxAmendType
params['attachAlgoOrds'] = attachAlgoOrds
return self._request_with_params(POST, PLACR_ORDER, params)

Expand All @@ -35,11 +39,13 @@ def cancel_multiple_orders(self, orders_data):
# Amend Order
def amend_order(self, instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newTpTriggerPx='',
newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='',
attachAlgoOrds='', newTriggerPx='', newOrdPx=''):
attachAlgoOrds='', newTriggerPx='', newOrdPx='', pxAmendType=None):
params = {'instId': instId, 'cxlOnFail': cxlOnFail, 'ordId': ordId, 'clOrdId': clOrdId, 'reqId': reqId,
'newSz': newSz, 'newPx': newPx, 'newTpTriggerPx': newTpTriggerPx, 'newTpOrdPx': newTpOrdPx,
'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx, 'newTpTriggerPxType': newTpTriggerPxType,
'newSlTriggerPxType': newSlTriggerPxType, 'newTriggerPx': newTriggerPx, 'newOrdPx': newOrdPx}
if pxAmendType is not None:
params['pxAmendType'] = pxAmendType
params['attachAlgoOrds'] = attachAlgoOrds
return self._request_with_params(POST, AMEND_ORDER, params)

Expand Down Expand Up @@ -95,8 +101,8 @@ def place_algo_order(self, instId='', tdMode='', side='', ordType='', sz='', ccy
pxSpread='',
szLimit='', pxLimit='', timeInterval='', tpTriggerPxType='', slTriggerPxType='',
callbackRatio='', callbackSpread='', activePx='', tag='', triggerPxType='', closeFraction=''
, quickMgnType='', algoClOrdId='', tradeQuoteCcy='', tpOrdKind='', cxlOnClosePos=''
, chaseType='', chaseVal='', maxChaseType='', maxChaseVal='', attachAlgoOrds=[]):
, quickMgnType='', algoClOrdId='', tradeQuoteCcy=None, tpOrdKind='', cxlOnClosePos=''
, chaseType='', chaseVal='', maxChaseType='', maxChaseVal='', attachAlgoOrds=[], pxAmendType=None):
params = {'instId': instId, 'tdMode': tdMode, 'side': side, 'ordType': ordType, 'sz': sz, 'ccy': ccy,
'posSide': posSide, 'reduceOnly': reduceOnly, 'tpTriggerPx': tpTriggerPx, 'tpOrdPx': tpOrdPx,
'slTriggerPx': slTriggerPx, 'slOrdPx': slOrdPx, 'triggerPx': triggerPx, 'orderPx': orderPx,
Expand All @@ -105,9 +111,13 @@ def place_algo_order(self, instId='', tdMode='', side='', ordType='', sz='', ccy
'pxSpread': pxSpread, 'tpTriggerPxType': tpTriggerPxType, 'slTriggerPxType': slTriggerPxType,
'callbackRatio': callbackRatio, 'callbackSpread': callbackSpread, 'activePx': activePx,
'tag': tag, 'triggerPxType': triggerPxType, 'closeFraction': closeFraction,
'quickMgnType': quickMgnType, 'algoClOrdId': algoClOrdId, 'tradeQuoteCcy': tradeQuoteCcy,
'quickMgnType': quickMgnType, 'algoClOrdId': algoClOrdId,
'tpOrdKind': tpOrdKind, 'cxlOnClosePos': cxlOnClosePos, 'chaseType': chaseType, 'chaseVal': chaseVal,
'maxChaseType': maxChaseType, 'maxChaseVal': maxChaseVal, 'attachAlgoOrds': attachAlgoOrds}
if tradeQuoteCcy is not None:
params['tradeQuoteCcy'] = tradeQuoteCcy
if pxAmendType is not None:
params['pxAmendType'] = pxAmendType
return self._request_with_params(POST, PLACE_ALGO_ORDER, params)

# Cancel Algo Order
Expand Down Expand Up @@ -179,11 +189,13 @@ def get_algo_order_details(self, algoId='', algoClOrdId=''):
# Amend algo order
def amend_algo_order(self, instId='', algoId='', algoClOrdId='', cxlOnFail='', reqId='', newSz='', newTriggerPx='', newOrdPx='',
newTpTriggerPx='', newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='',
newSlTriggerPxType=''):
newSlTriggerPxType='', pxAmendType=None):
params = {'instId': instId, 'algoId': algoId, 'algoClOrdId': algoClOrdId, 'cxlOnFail': cxlOnFail,
'reqId': reqId, 'newSz': newSz, 'newTriggerPx': newTriggerPx, 'newOrdPx': newOrdPx, 'newTpTriggerPx': newTpTriggerPx, 'newTpOrdPx': newTpOrdPx,
'newSlTriggerPx': newSlTriggerPx, 'newSlOrdPx': newSlOrdPx,
'newTpTriggerPxType': newTpTriggerPxType, 'newSlTriggerPxType': newSlTriggerPxType}
if pxAmendType is not None:
params['pxAmendType'] = pxAmendType
return self._request_with_params(POST, AMEND_ALGO_ORDER, params)

def get_oneclick_repay_list_v2(self):
Expand Down