pyokx.low_rest_api.Trade

class pyokx.low_rest_api.Trade.TradeAPI(api_key='-1', api_secret_key='-1', passphrase='-1', use_server_time=False, flag='1', domain='https://www.okx.com', debug=True)[source]

Bases: Client

amend_algo_order(instId='', algoId='', algoClOrdId='', cxlOnFail='', reqId='', newSz='', newTpTriggerPx='', newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='')[source]
amend_multiple_orders(orders_data)[source]
amend_order(instId, cxlOnFail='', ordId='', clOrdId='', reqId='', newSz='', newPx='', newTpTriggerPx='', newTpOrdPx='', newSlTriggerPx='', newSlOrdPx='', newTpTriggerPxType='', newSlTriggerPxType='')[source]
cancel_advance_algos(params)[source]
cancel_algo_order(params)[source]
cancel_multiple_orders(orders_data)[source]
cancel_order(instId, ordId='', clOrdId='')[source]
async close_positions(instId, mgnMode, posSide='', ccy='', autoCxl='', clOrdId='', tag='')[source]

Closes a position based on the given parameters.

Parameters:
  • instId (str) – The instrument ID for the position to be closed.

  • mgnMode (str) – The margin mode for the position (e.g., ‘isolated’, ‘cross’).

  • posSide (str, optional) – The position side (e.g., ‘long’, ‘short’). Defaults to an empty string.

  • ccy (str, optional) – The currency used for the position. Defaults to an empty string.

  • autoCxl (str, optional) – Automatically cancel the position. Defaults to an empty string.

  • clOrdId (str, optional) – The client order ID. Defaults to an empty string.

  • tag (str, optional) – A tag for the position. Defaults to an empty string.

Returns:

The response from the position close request.

easy_convert(fromCcy=[], toCcy='')[source]
get_algo_order_details(algoId='', algoClOrdId='')[source]
get_easy_convert_currency_list()[source]
get_easy_convert_history(before='', after='', limit='')[source]
get_fills(instType='', uly='', instId='', ordId='', after='', before='', limit='', instFamily='', begin='', end='')[source]
get_fills_history(instType, uly='', instId='', ordId='', after='', before='', limit='', instFamily='', begin='', end='')[source]
get_oneclick_repay_list(debtType='')[source]
get_order(instId, ordId='', clOrdId='')[source]
get_order_list(instType='', uly='', instId='', ordType='', state='', after='', before='', limit='', instFamily='')[source]
get_orders_history(instType, uly='', instId='', ordType='', state='', after='', before='', begin='', end='', limit='', instFamily='')[source]
get_orders_history_archive(instType, uly='', instId='', ordType='', state='', after='', before='', begin='', end='', limit='', instFamily='')[source]
oneclick_repay(debtCcy=[], repayCcy='')[source]
oneclick_repay_history(after='', before='', limit='')[source]
order_algos_history(ordType, state='', algoId='', instType='', instId='', after='', before='', limit='')[source]
order_algos_list(ordType='', algoId='', instType='', instId='', after='', before='', limit='', algoClOrdId='')[source]
place_algo_order(instId='', tdMode='', side='', ordType='', sz='', ccy='', posSide='', reduceOnly='', tpTriggerPx='', tpOrdPx='', slTriggerPx='', slOrdPx='', triggerPx='', orderPx='', tgtCcy='', pxVar='', pxSpread='', szLimit='', pxLimit='', timeInterval='', tpTriggerPxType='', slTriggerPxType='', callbackRatio='', callbackSpread='', activePx='', tag='', triggerPxType='', closeFraction='', quickMgnType='', algoClOrdId='', cxlOnClosePos='')[source]
place_multiple_orders(orders_data)[source]
place_order(instId, tdMode, side, ordType, sz, ccy='', clOrdId='', tag='', posSide='', px='', reduceOnly='', tgtCcy='', tpTriggerPx='', tpOrdPx='', slTriggerPx='', slOrdPx='', tpTriggerPxType='', slTriggerPxType='', quickMgnType='', stpId='', stpMode='', algoClOrdId='')[source]
Inheritance diagram of pyokx.low_rest_api.Trade