CCXT

okx

okx cryptocurrency exchange — CCXT unified API: methods, parameters and endpoints.

okx

Kind: global class
Extends: Exchange

fetchStatus

the latest known information on the availability of the exchange API

Kind: instance method of okx
Returns: object - a status structure

See: https://www.okx.com/docs-v5/en/#status-get-status

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchStatus (params?)

fetchTime

fetches the current integer timestamp in milliseconds from the exchange server

Kind: instance method of okx
Returns: int - the current integer timestamp in milliseconds from the exchange server

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-system-time

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchTime (params?)

fetchAccounts

fetch all the accounts associated with a profile

Kind: instance method of okx
Returns: object - a dictionary of account structures indexed by the account type

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-configuration

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchAccounts (params?)

fetchMarkets

retrieves data on all markets for okx

Kind: instance method of okx
Returns: Array<object> - an array of objects representing market data

See: https://www.okx.com/docs-v5/en/#rest-api-public-data-get-instruments

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchMarkets (params?)

fetchCurrencies

fetches all available currencies on an exchange

Kind: instance method of okx
Returns: object - an associative dictionary of currencies

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchCurrencies (params?)

fetchOrderBook

fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of okx
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-order-book

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.methodstringNo'publicGetMarketBooksFull' or 'publicGetMarketBooks' default is 'publicGetMarketBooks'
okx.fetchOrderBook (symbol, limit?, params?)

fetchTicker

fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchTicker (symbol, params?)

fetchTickers

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

Kind: instance method of okx
Returns: object - a dictionary of ticker structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchTickers (symbols?, params?)

fetchMarkPrice

fetches mark price for the market

Kind: instance method of okx
Returns: object - a dictionary of ticker structures

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchMarkPrice (symbol, params?)

fetchMarkPrices

fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market

Kind: instance method of okx
Returns: object - a dictionary of ticker structures

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchMarkPrices (symbols?, params?)

fetchTrades

get the list of most recent trades for a particular symbol

Kind: instance method of okx
Returns: Array<Trade> - a list of trade structures

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.methodstringNo'publicGetMarketTrades' or 'publicGetMarketHistoryTrades' default is 'publicGetMarketTrades'
params.paginatebooleanNoonly applies to publicGetMarketHistoryTrades default false, when true will automatically paginate by calling this endpoint multiple times
okx.fetchTrades (symbol, since?, limit?, params?)

fetchOHLCV

fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of okx
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.pricestringNo"mark" or "index" for mark price and index price candles
params.untilintNotimestamp in ms of the latest candle to fetch
params.typestringNo"Candles" or "HistoryCandles", default is "Candles" for recent candles, "HistoryCandles" for older candles
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
okx.fetchOHLCV (symbol, timeframe, since?, limit?, params?)

fetchFundingRateHistory

fetches historical funding rate prices

Kind: instance method of okx
Returns: Array<object> - a list of funding rate structures

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate-history

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the funding rate history for
sinceintNotimestamp in ms of the earliest funding rate to fetch
limitintNothe maximum amount of funding rate structures to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
okx.fetchFundingRateHistory (symbol, since?, limit?, params?)

fetchTradingFee

fetch the trading fees for a market

Kind: instance method of okx
Returns: object - a fee structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-fee-rates

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchTradingFee (symbol, params?)

fetchBalance

query for balance and get the amount of funds available for trading or funds locked in orders

Kind: instance method of okx
Returns: object - a balance structure

See

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.typestringNowallet type, ['funding' or 'trading'] default is 'trading'
okx.fetchBalance (params?)

createMarketBuyOrderWithCost

create a market buy order by providing the symbol and cost

Kind: instance method of okx
Returns: object - an order structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
costfloatYeshow much you want to trade in units of the quote currency
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.createMarketBuyOrderWithCost (symbol, cost, params?)

createMarketSellOrderWithCost

create a market buy order by providing the symbol and cost

Kind: instance method of okx
Returns: object - an order structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-order

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
costfloatYeshow much you want to trade in units of the quote currency
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.createMarketSellOrderWithCost (symbol, cost, params?)

createOrder

create a trade order

Kind: instance method of okx
Returns: object - an order structure

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of currency you want to trade in units of base currency
pricefloatNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.reduceOnlyboolNoa mark to reduce the position size for margin, swap and future orders
params.postOnlyboolNotrue to place a post only order
params.takeProfitobjectNotakeProfit object in params containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
params.takeProfit.triggerPricefloatNotake profit trigger price
params.takeProfit.pricefloatNoused for take profit limit orders, not used for take profit market price orders
params.takeProfit.typestringNo'market' or 'limit' used to specify the take profit price type
params.stopLossobjectNostopLoss object in params containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
params.stopLoss.triggerPricefloatNostop loss trigger price
params.stopLoss.pricefloatNoused for stop loss limit orders, not used for stop loss market price orders
params.stopLoss.typestringNo'market' or 'limit' used to specify the stop loss price type
params.positionSidestringNoif position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
params.trailingPercentstringNothe percent to trail away from the current market price
params.tpOrdKindstringNo'condition' or 'limit', the default is 'condition'
params.hedgedboolNoswap and future only true for hedged mode, false for one way mode
params.marginModestringNo'cross' or 'isolated', the default is 'cross'
okx.createOrder (symbol, type, side, amount, price?, params?)

createOrders

create a list of trade orders

Kind: instance method of okx
Returns: object - an order structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-place-multiple-orders

ParamTypeRequiredDescription
ordersArrayYeslist of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.createOrders (orders, params?)

editOrder

edit a trade order

Kind: instance method of okx
Returns: object - an order structure

See

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of the currency you want to trade in units of the base currency
pricefloatNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.clientOrderIdstringNoclient order id, uses id if not passed
params.stopLossPricefloatNostop loss trigger price
params.newSlOrdPxfloatNothe stop loss order price, set to stopLossPrice if the type is market
params.newSlTriggerPxTypestringNo'last', 'index' or 'mark' used to specify the stop loss trigger price type, default is 'last'
params.takeProfitPricefloatNotake profit trigger price
params.newTpOrdPxfloatNothe take profit order price, set to takeProfitPrice if the type is market
params.newTpTriggerPxTypestringNo'last', 'index' or 'mark' used to specify the take profit trigger price type, default is 'last'
params.stopLossobjectNostopLoss object in params containing the triggerPrice at which the attached stop loss order will be triggered
params.stopLoss.triggerPricefloatNostop loss trigger price
params.stopLoss.pricefloatNoused for stop loss limit orders, not used for stop loss market price orders
params.stopLoss.typestringNo'market' or 'limit' used to specify the stop loss price type
params.takeProfitobjectNotakeProfit object in params containing the triggerPrice at which the attached take profit order will be triggered
params.takeProfit.triggerPricefloatNotake profit trigger price
params.takeProfit.pricefloatNoused for take profit limit orders, not used for take profit market price orders
params.takeProfit.typestringNo'market' or 'limit' used to specify the take profit price type
params.newTpOrdKindstringNo'condition' or 'limit', the default is 'condition'
okx.editOrder (id, symbol, type, side, amount, price?, params?)

cancelOrder

cancels an open order

Kind: instance method of okx
Returns: object - An order structure

See

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerbooleanNotrue if trigger orders
params.trailingbooleanNoset to true if you want to cancel a trailing order
okx.cancelOrder (id, symbol, params?)

cancelOrders

cancel multiple orders

Kind: instance method of okx
Returns: object - an list of order structures

See

ParamTypeRequiredDescription
idsArray<string>Yesorder ids
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerbooleanNowhether the order is a stop/trigger order
params.trailingbooleanNoset to true if you want to cancel trailing orders
okx.cancelOrders (ids, symbol, params?)

cancelOrdersForSymbols

cancel multiple orders for multiple symbols

Kind: instance method of okx
Returns: object - an list of order structures

See

ParamTypeRequiredDescription
ordersArray<CancellationRequest>Yeseach order should contain the parameters required by cancelOrder namely id and symbol, example [{"id": "a", "symbol": "BTC/USDT"}, {"id": "b", "symbol": "ETH/USDT"}]
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerbooleanNowhether the order is a stop/trigger order
params.trailingbooleanNoset to true if you want to cancel trailing orders
okx.cancelOrdersForSymbols (orders, params?)

cancelAllOrdersAfter

dead man's switch, cancel all orders after the given timeout

Kind: instance method of okx
Returns: object - the api result

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after

ParamTypeRequiredDescription
timeoutnumberYestime in milliseconds, 0 represents cancel the timer
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.cancelAllOrdersAfter (timeout, params?)

fetchOrder

fetch an order by the id

Kind: instance method of okx
Returns: an order structure

See

ParamTypeRequiredDescription
idstringYesthe order id
symbolstringYesunified market symbol
paramsobjectNoextra and exchange specific parameters
params.triggerbooleanNotrue if fetching trigger orders
okx.fetchOrder (id, symbol, params?)

fetchOpenOrders

fetch all unfilled currently open orders

Kind: instance method of okx
Returns: Array<Order> - a list of order structures

See

ParamTypeRequiredDescription
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch open orders for
limitintNothe maximum number of open orders structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerboolNoTrue if fetching trigger or conditional orders
params.ordTypestringNo"conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
params.algoIdstringNoAlgo ID "'433845797218942976'"
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
params.trailingbooleanNoset to true if you want to fetch trailing orders
okx.fetchOpenOrders (symbol, since?, limit?, params?)

fetchCanceledOrders

fetches information on multiple canceled orders made by the user

Kind: instance method of okx
Returns: object - a list of order structures

See

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNotimestamp in ms of the earliest order, default is undefined
limitintNomax number of orders to return, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerboolNoTrue if fetching trigger or conditional orders
params.ordTypestringNo"conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
params.algoIdstringNoAlgo ID "'433845797218942976'"
params.untilintNotimestamp in ms to fetch orders for
params.trailingbooleanNoset to true if you want to fetch trailing orders
okx.fetchCanceledOrders (symbol, since?, limit?, params?)

fetchClosedOrders

fetches information on multiple closed orders made by the user

Kind: instance method of okx
Returns: Array<Order> - a list of order structures

See

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerboolNoTrue if fetching trigger or conditional orders
params.ordTypestringNo"conditional", "oco", "trigger", "move_order_stop", "iceberg", or "twap"
params.algoIdstringNoAlgo ID "'433845797218942976'"
params.untilintNotimestamp in ms to fetch orders for
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
params.methodstringNomethod to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
params.trailingbooleanNoset to true if you want to fetch trailing orders
okx.fetchClosedOrders (symbol, since?, limit?, params?)

fetchMyTrades

fetch all trades made by the user

Kind: instance method of okx
Returns: Array<Trade> - a list of trade structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-months

ParamTypeRequiredDescription
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trades structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNoTimestamp in ms of the latest time to retrieve trades for
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
okx.fetchMyTrades (symbol, since?, limit?, params?)

fetchOrderTrades

fetch all the trades made from a single order

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-months

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trades to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchOrderTrades (id, symbol, since?, limit?, params?)

fetchLedger

fetch the history of changes, actions done by the user or operations that altered balance of the user

Kind: instance method of okx
Returns: object - a ledger structure

See

ParamTypeRequiredDescription
codestringNounified currency code, default is undefined
sinceintNotimestamp in ms of the earliest ledger entry, default is undefined
limitintNomax number of ledger entries to return, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
params.marginModestringNo'cross' or 'isolated'
params.untilintNothe latest time in ms to fetch entries for
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the available parameters
okx.fetchLedger (code?, since?, limit?, params?)

fetchDepositAddressesByNetwork

fetch a dictionary of addresses for a currency, indexed by network

Kind: instance method of okx
Returns: object - a dictionary of address structures indexed by the network

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address

ParamTypeRequiredDescription
codestringYesunified currency code of the currency for the deposit address
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchDepositAddressesByNetwork (code, params?)

fetchDepositAddress

fetch the deposit address for a currency associated with this account

Kind: instance method of okx
Returns: object - an address structure

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-deposit-address

ParamTypeRequiredDescription
codestringYesunified currency code
paramsobjectNoextra parameters specific to the exchange API endpoint
params.networkstringNothe network name for the deposit address
okx.fetchDepositAddress (code, params?)

withdraw

make a withdrawal

Kind: instance method of okx
Returns: object - a transaction structure

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-withdrawal

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesthe amount to withdraw
addressstringYesthe address to withdraw to
tagstringYes
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.withdraw (code, amount, address, tag, params?)

fetchDeposits

fetch all deposits made to an account

Kind: instance method of okx
Returns: Array<object> - a list of transaction structures

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-history

ParamTypeRequiredDescription
codestringYesunified currency code
sinceintNothe earliest time in ms to fetch deposits for
limitintNothe maximum number of deposits structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch entries for
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
okx.fetchDeposits (code, since?, limit?, params?)

fetchDeposit

fetch data on a currency deposit via the deposit id

Kind: instance method of okx
Returns: object - a transaction structure

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-deposit-history

ParamTypeRequiredDescription
idstringYesdeposit id
codestringYesfilter by currency code
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchDeposit (id, code, params?)

fetchWithdrawals

fetch all withdrawals made from an account

Kind: instance method of okx
Returns: Array<object> - a list of transaction structures

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-withdrawal-history

ParamTypeRequiredDescription
codestringYesunified currency code
sinceintNothe earliest time in ms to fetch withdrawals for
limitintNothe maximum number of withdrawals structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNothe latest time in ms to fetch entries for
params.paginatebooleanNodefault false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the availble parameters
okx.fetchWithdrawals (code, since?, limit?, params?)

fetchWithdrawal

fetch data on a currency withdrawal via the withdrawal id

Kind: instance method of okx
Returns: object - a transaction structure

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-withdrawal-history

ParamTypeRequiredDescription
idstringYeswithdrawal id
codestringYesunified currency code of the currency withdrawn, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchWithdrawal (id, code, params?)

fetchLeverage

fetch the set leverage for a market

Kind: instance method of okx
Returns: object - a leverage structure

See: https://www.okx.com/docs-v5/en/#rest-api-account-get-leverage

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.marginModestringNo'cross' or 'isolated'
okx.fetchLeverage (symbol, params?)

fetchPosition

fetch data on a single open contract trade position

Kind: instance method of okx
Returns: object - a position structure

See: https://www.okx.com/docs-v5/en/#rest-api-account-get-positions

ParamTypeRequiredDescription
symbolstringYesunified market symbol of the market the position is held in, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
params.instTypestringNoMARGIN, SWAP, FUTURES, OPTION
okx.fetchPosition (symbol, params?)

fetchPositions

fetch all open positions

Kind: instance method of okx
Returns: Array<object> - a list of position structure

See

ParamTypeRequiredDescription
symbolsArray<string>, undefinedYeslist of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
params.instTypestringNoMARGIN, SWAP, FUTURES, OPTION
okx.fetchPositions (symbols, params?)

fetchPositionsForSymbol

fetch all open positions for specific symbol

Kind: instance method of okx
Returns: Array<object> - a list of position structure

See: https://www.okx.com/docs-v5/en/#rest-api-account-get-positions

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.instTypestringNoMARGIN (if needed)
okx.fetchPositionsForSymbol (symbol, params?)

transfer

transfer currency internally between wallets on the same account

Kind: instance method of okx
Returns: object - a transfer structure

See: https://www.okx.com/docs-v5/en/#rest-api-funding-funds-transfer

ParamTypeRequiredDescription
codestringYesunified currency code
amountfloatYesamount to transfer
fromAccountstringYesaccount to transfer from
toAccountstringYesaccount to transfer to
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.transfer (code, amount, fromAccount, toAccount, params?)

fetchTransfers

fetch a history of internal transfers made on an account

Kind: instance method of okx
Returns: Array<object> - a list of transfer structures

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months

ParamTypeRequiredDescription
codestringYesunified currency code of the currency transferred
sinceintNothe earliest time in ms to fetch transfers for
limitintNothe maximum number of transfers structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchTransfers (code, since?, limit?, params?)

fetchFundingInterval

fetch the current funding rate interval

Kind: instance method of okx
Returns: object - a funding rate structure

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchFundingInterval (symbol, params?)

fetchFundingRate

fetch the current funding rate

Kind: instance method of okx
Returns: object - a funding rate structure

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchFundingRate (symbol, params?)

fetchFundingRates

fetches the current funding rates for multiple symbols

Kind: instance method of okx
Returns: object - a dictionary of funding rates structure

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-funding-rate

ParamTypeRequiredDescription
symbolsArray<string>Yesunified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchFundingRates (symbols, params?)

fetchFundingHistory

fetch the history of funding payments paid and received on this account

Kind: instance method of okx
Returns: object - a funding history structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-bills-details-last-3-months

ParamTypeRequiredDescription
symbolstringYesunified market symbol
sinceintNothe earliest time in ms to fetch funding history for
limitintNothe maximum number of funding history structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchFundingHistory (symbol, since?, limit?, params?)

setLeverage

set the level of leverage for a market

Kind: instance method of okx
Returns: object - response from the exchange

See: https://www.okx.com/docs-v5/en/#rest-api-account-set-leverage

ParamTypeRequiredDescription
leveragefloatYesthe rate of leverage
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.marginModestringNo'cross' or 'isolated'
params.posSidestringNo'long' or 'short' or 'net' for isolated margin long/short mode on futures and swap markets, default is 'net'
okx.setLeverage (leverage, symbol, params?)

fetchPositionMode

fetchs the position mode, hedged or one way, hedged for binance is set identically for all linear markets or all inverse markets

Kind: instance method of okx
Returns: object - an object detailing whether the market is in hedged or one-way mode

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-account-configuration

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIdstringNoif you have multiple accounts, you must specify the account id to fetch the position mode
okx.fetchPositionMode (symbol, params?)

setPositionMode

set hedged to true or false for a market

Kind: instance method of okx
Returns: object - response from the exchange

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode

ParamTypeRequiredDescription
hedgedboolYesset to true to use long_short_mode, false for net_mode
symbolstringYesnot used by okx setPositionMode
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.setPositionMode (hedged, symbol, params?)

setMarginMode

set margin mode to 'cross' or 'isolated'

Kind: instance method of okx
Returns: object - response from the exchange

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-leverage

ParamTypeRequiredDescription
marginModestringYes'cross' or 'isolated'
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.leverageintNoleverage
okx.setMarginMode (marginMode, symbol, params?)

fetchCrossBorrowRates

fetch the borrow interest rates of all currencies

Kind: instance method of okx
Returns: object - a list of borrow rate structures

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-rate

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchCrossBorrowRates (params?)

fetchCrossBorrowRate

fetch the rate of interest to borrow a currency for margin trading

Kind: instance method of okx
Returns: object - a borrow rate structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-interest-rate

ParamTypeRequiredDescription
codestringYesunified currency code
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchCrossBorrowRate (code, params?)

fetchBorrowRateHistories

retrieves a history of a multiple currencies borrow interest rate at specific time slots, returns all currencies if no symbols passed, default is undefined

Kind: instance method of okx
Returns: object - a dictionary of borrow rate structures indexed by the market symbol

See: https://www.okx.com/docs-v5/en/#financial-product-savings-get-public-borrow-history-public

ParamTypeRequiredDescription
codesArray<string>, undefinedYeslist of unified currency codes, default is undefined
sinceintNotimestamp in ms of the earliest borrowRate, default is undefined
limitintNomax number of borrow rate prices to return, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchBorrowRateHistories (codes, since?, limit?, params?)

fetchBorrowRateHistory

retrieves a history of a currencies borrow interest rate at specific time slots

Kind: instance method of okx
Returns: Array<object> - an array of borrow rate structures

See: https://www.okx.com/docs-v5/en/#financial-product-savings-get-public-borrow-history-public

ParamTypeRequiredDescription
codestringYesunified currency code
sinceintNotimestamp for the earliest borrow rate
limitintNothe maximum number of borrow rate structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchBorrowRateHistory (code, since?, limit?, params?)

reduceMargin

remove margin from a position

Kind: instance method of okx
Returns: object - a margin structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesthe amount of margin to remove
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.reduceMargin (symbol, amount, params?)

addMargin

add margin

Kind: instance method of okx
Returns: object - a margin structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-increase-decrease-margin

ParamTypeRequiredDescription
symbolstringYesunified market symbol
amountfloatYesamount of margin to add
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.addMargin (symbol, amount, params?)

fetchMarketLeverageTiers

retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market

Kind: instance method of okx
Returns: object - a leverage tiers structure

See: https://www.okx.com/docs-v5/en/#rest-api-public-data-get-position-tiers

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.marginModestringNo'cross' or 'isolated'
okx.fetchMarketLeverageTiers (symbol, params?)

fetchBorrowInterest

fetch the interest owed b the user for borrowing currency for margin trading

Kind: instance method of okx
Returns: Array<object> - An list of borrow interest structures

See: https://www.okx.com/docs-v5/en/#rest-api-account-get-interest-accrued-data

ParamTypeRequiredDescription
codestringYesthe unified currency code for the currency of the interest
symbolstringYesthe market symbol of an isolated margin market, if undefined, the interest for cross margin markets is returned
sinceintNotimestamp in ms of the earliest time to receive interest records for
limitintNothe number of borrow interest structures to retrieve
paramsobjectNoexchange specific parameters
params.typeintNoLoan type 1 - VIP loans 2 - Market loans Default is Market loans
params.marginModestringNo'cross' or 'isolated'
okx.fetchBorrowInterest (code, symbol, since?, limit?, params?)

borrowCrossMargin

create a loan to borrow margin (need to be VIP 5 and above)

Kind: instance method of okx
Returns: object - a margin loan structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-vip-loans-borrow-and-repay

ParamTypeRequiredDescription
codestringYesunified currency code of the currency to borrow
amountfloatYesthe amount to borrow
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.borrowCrossMargin (code, amount, params?)

repayCrossMargin

repay borrowed margin and interest

Kind: instance method of okx
Returns: object - a margin loan structure

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-vip-loans-borrow-and-repay

ParamTypeRequiredDescription
codestringYesunified currency code of the currency to repay
amountfloatYesthe amount to repay
paramsobjectNoextra parameters specific to the exchange API endpoint
params.idstringNothe order ID of borrowing, it is necessary while repaying
okx.repayCrossMargin (code, amount, params?)

fetchOpenInterest

Retrieves the open interest of a currency

Kind: instance method of okx
Returns: object - an open interest structure/docs/manual#open-interest-structure

See: https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest

ParamTypeRequiredDescription
symbolstringYesUnified CCXT market symbol
paramsobjectNoexchange specific parameters
okx.fetchOpenInterest (symbol, params?)

fetchOpenInterests

Retrieves the open interests of some currencies

Kind: instance method of okx
Returns: object - an dictionary of open interest structures

See: https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest

ParamTypeRequiredDescription
symbolsArray<string>YesUnified CCXT market symbols
paramsobjectNoexchange specific parameters
params.instTypestringYesInstrument type, options: 'SWAP', 'FUTURES', 'OPTION', default to 'SWAP'
params.ulystringYesUnderlying, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
params.instFamilystringYesInstrument family, Applicable to FUTURES/SWAP/OPTION, if instType is 'OPTION', either uly or instFamily is required
okx.fetchOpenInterests (symbols, params?)

fetchOpenInterestHistory

Retrieves the open interest history of a currency

Kind: instance method of okx
Returns: An array of open interest structures

See

ParamTypeRequiredDescription
symbolstringYesUnified CCXT currency code or unified symbol
timeframestringYes"5m", "1h", or "1d" for option only "1d" or "8h"
sinceintNoThe time in ms of the earliest record to retrieve as a unix timestamp
limitintNoNot used by okx, but parsed internally by CCXT
paramsobjectNoExchange specific parameters
params.untilintNoThe time in ms of the latest record to retrieve as a unix timestamp
okx.fetchOpenInterestHistory (symbol, timeframe, since?, limit?, params?)

fetchDepositWithdrawFees

fetch deposit and withdraw fees

Kind: instance method of okx
Returns: Array<object> - a list of fees structures

See: https://www.okx.com/docs-v5/en/#rest-api-funding-get-currencies

ParamTypeRequiredDescription
codesArray<string>, undefinedYeslist of unified currency codes
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchDepositWithdrawFees (codes, params?)

fetchSettlementHistory

fetches historical settlement records

Kind: instance method of okx
Returns: Array<object> - a list of settlement history objects

See: https://www.okx.com/docs-v5/en/#rest-api-public-data-get-delivery-exercise-history

ParamTypeRequiredDescription
symbolstringYesunified market symbol to fetch the settlement history for
sinceintNotimestamp in ms
limitintNonumber of records
paramsobjectNoexchange specific params
okx.fetchSettlementHistory (symbol, since?, limit?, params?)

fetchUnderlyingAssets

fetches the market ids of underlying assets for a specific contract market type

Kind: instance method of okx
Returns: Array<object> - a list of underlying assets

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-underlying

ParamTypeRequiredDescription
paramsobjectNoexchange specific params
params.typestringNothe contract market type, 'option', 'swap' or 'future', the default is 'option'
okx.fetchUnderlyingAssets (params?)

fetchGreeks

fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

Kind: instance method of okx
Returns: object - a greeks structure

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch greeks for
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchGreeks (symbol, params?)

fetchAllGreeks

fetches all option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract

Kind: instance method of okx
Returns: object - a greeks structure

See: https://www.okx.com/docs-v5/en/#public-data-rest-api-get-option-market-data

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbols of the markets to fetch greeks for, all markets are returned if not assigned
paramsobjectNoextra parameters specific to the exchange API endpoint
params.ulystringYesUnderlying, either uly or instFamily is required
params.instFamilystringYesInstrument family, either uly or instFamily is required
okx.fetchAllGreeks (symbols?, params?)

closePosition

closes open positions for a market

Kind: instance method of okx
Returns: Array<object> - A list of position structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-close-positions

ParamTypeRequiredDescription
symbolstringYesUnified CCXT market symbol
sidestringNo'buy' or 'sell', leave as undefined in net mode
paramsobjectNoextra parameters specific to the okx api endpoint
params.clientOrderIdstringNoa unique identifier for the order
params.marginModestringNo'cross' or 'isolated', default is 'cross;
params.codestringNorequired in the case of closing cross MARGIN position for Single-currency margin margin currency EXCHANGE SPECIFIC PARAMETERS
params.autoCxlbooleanNowhether any pending orders for closing out needs to be automatically canceled when close position via a market order. false or true, the default is false
params.tagstringNoorder tag a combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters
okx.closePosition (symbol, side?, params?)

fetchOption

fetches option data that is commonly found in an option chain

Kind: instance method of okx
Returns: object - an option chain structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-ticker

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchOption (symbol, params?)

fetchOptionChain

fetches data for an underlying asset that is commonly found in an option chain

Kind: instance method of okx
Returns: object - a list of option chain structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-tickers

ParamTypeRequiredDescription
codestringYesbase currency to fetch an option chain for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.ulystringNothe underlying asset, can be obtained from fetchUnderlyingAssets ()
okx.fetchOptionChain (code, params?)

fetchConvertQuote

fetch a quote for converting from one currency to another

Kind: instance method of okx
Returns: object - a conversion structure

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-estimate-quote

ParamTypeRequiredDescription
fromCodestringYesthe currency that you want to sell and convert from
toCodestringYesthe currency that you want to buy and convert into
amountfloatNohow much you want to trade in units of the from currency
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchConvertQuote (fromCode, toCode, amount?, params?)

createConvertTrade

convert from one currency to another

Kind: instance method of okx
Returns: object - a conversion structure

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-convert-trade

ParamTypeRequiredDescription
idstringYesthe id of the trade that you want to make
fromCodestringYesthe currency that you want to sell and convert from
toCodestringYesthe currency that you want to buy and convert into
amountfloatNohow much you want to trade in units of the from currency
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.createConvertTrade (id, fromCode, toCode, amount?, params?)

fetchConvertTrade

fetch the data for a conversion trade

Kind: instance method of okx
Returns: object - a conversion structure

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-convert-history

ParamTypeRequiredDescription
idstringYesthe id of the trade that you want to fetch
codestringNothe unified currency code of the conversion trade
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchConvertTrade (id, code?, params?)

fetchConvertTradeHistory

fetch the users history of conversion trades

Kind: instance method of okx
Returns: Array<object> - a list of conversion structures

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-convert-history

ParamTypeRequiredDescription
codestringNothe unified currency code
sinceintNothe earliest time in ms to fetch conversions for
limitintNothe maximum number of conversion structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest conversion to fetch
okx.fetchConvertTradeHistory (code?, since?, limit?, params?)

fetchConvertCurrencies

fetches all available currencies that can be converted

Kind: instance method of okx
Returns: object - an associative dictionary of currencies

See: https://www.okx.com/docs-v5/en/#funding-account-rest-api-get-convert-currencies

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.fetchConvertCurrencies (params?)

fetchMarginAdjustmentHistory

fetches the history of margin added or reduced from contract isolated positions

Kind: instance method of okx
Returns: Array<object> - a list of margin structures

See

ParamTypeRequiredDescription
symbolstringNonot used by okx fetchMarginAdjustmentHistory
typestringNo"add" or "reduce"
sinceintNothe earliest time in ms to fetch margin adjustment history for
limitintNothe maximum number of entries to retrieve
paramsobjectYesextra parameters specific to the exchange api endpoint
params.autobooleanNotrue if fetching auto margin increases
okx.fetchMarginAdjustmentHistory (symbol?, type?, since?, limit?, params)

fetchPositionsHistory

fetches historical positions

Kind: instance method of okx
Returns: Array<object> - a list of position structures

See: https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history

ParamTypeRequiredDescription
symbolsstringNounified market symbols
sinceintNotimestamp in ms of the earliest position to fetch
limitintNothe maximum amount of records to fetch, default=100, max=100
paramsobjectYesextra parameters specific to the exchange api endpoint
params.marginModestringNo"cross" or "isolated" EXCHANGE SPECIFIC PARAMETERS
params.instTypestringNomargin, swap, futures or option
params.typestringNothe type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
params.posIdstringNoposition id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
params.beforestringNotimestamp in ms of the earliest position to fetch based on the last update time of the position
params.afterstringNotimestamp in ms of the latest position to fetch based on the last update time of the position
okx.fetchPositionsHistory (symbols?, since?, limit?, params)

fetchLongShortRatioHistory

fetches the long short ratio history for a unified market symbol

Kind: instance method of okx
Returns: Array<object> - an array of long short ratio structures

See: https://www.okx.com/docs-v5/en/#trading-statistics-rest-api-get-contract-long-short-ratio

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the long short ratio for
timeframestringNothe period for the ratio
sinceintNothe earliest time in ms to fetch ratios for
limitintNothe maximum number of long short ratio structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.untilintNotimestamp in ms of the latest ratio to fetch
okx.fetchLongShortRatioHistory (symbol, timeframe?, since?, limit?, params?)

watchTrades

get the list of most recent trades for a particular symbol

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

See

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchTrades (symbol, since?, limit?, params?)

watchTradesForSymbols

get the list of most recent trades for a particular symbol

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

See

ParamTypeRequiredDescription
symbolsstringYes
sinceintNotimestamp in ms of the earliest trade to fetch
limitintNothe maximum amount of trades to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, trades by default. Can be 'trades' and 'trades-all'
okx.watchTradesForSymbols (symbols, since?, limit?, params?)

unWatchTradesForSymbols

unWatches from the stream channel

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

ParamTypeRequiredDescription
symbolsArray<string>Yes
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, trades by default. Can be trades, trades-all
okx.unWatchTradesForSymbols (symbols, params?)

unWatchTrades

unWatches from the stream channel

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch trades for
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.unWatchTrades (symbol, params?)

watchFundingRate

watch the current funding rate

Kind: instance method of okx
Returns: object - a funding rate structure

See: https://www.okx.com/docs-v5/en/#public-data-websocket-funding-rate-channel

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchFundingRate (symbol, params?)

watchFundingRates

watch the funding rate for multiple markets

Kind: instance method of okx
Returns: object - a dictionary of funding rates structures, indexed by market symbols

See: https://www.okx.com/docs-v5/en/#public-data-websocket-funding-rate-channel

ParamTypeRequiredDescription
symbolsArray<string>Yesa list of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchFundingRates (symbols, params?)

watchTicker

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.watchTicker (symbol, params?)

unWatchTicker

unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.unWatchTicker (symbol, params?)

watchTickers

watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.watchTickers (symbols?, params?)

watchMarkPrice

watches a mark price

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.watchMarkPrice (symbol, params?)

watchMarkPrices

watches mark prices

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#public-data-websocket-mark-price-channel

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.watchMarkPrices (symbols?, params?)

unWatchTickers

unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

ParamTypeRequiredDescription
symbolsArray<string>Nounified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.channelstringNothe channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
okx.unWatchTickers (symbols?, params?)

watchBidsAsks

watches best bid & ask for symbols

Kind: instance method of okx
Returns: object - a ticker structure

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-tickers-channel

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbol of the market to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchBidsAsks (symbols, params?)

watchLiquidationsForSymbols

watch the public liquidations of a trading pair

Kind: instance method of okx
Returns: object - an array of liquidation structures

See: https://www.okx.com/docs-v5/en/#public-data-websocket-liquidation-orders-channel

ParamTypeRequiredDescription
symbolsstringYes
sinceintNothe earliest time in ms to fetch liquidations for
limitintNothe maximum number of liquidation structures to retrieve
paramsobjectNoexchange specific parameters for the okx api endpoint
okx.watchLiquidationsForSymbols (symbols, since?, limit?, params?)

watchMyLiquidationsForSymbols

watch the private liquidations of a trading pair

Kind: instance method of okx
Returns: object - an array of liquidation structures

See: https://www.okx.com/docs-v5/en/#trading-account-websocket-balance-and-position-channel

ParamTypeRequiredDescription
symbolsArray<string>Yes
sinceintNothe earliest time in ms to fetch liquidations for
limitintNothe maximum number of liquidation structures to retrieve
paramsobjectNoexchange specific parameters for the okx api endpoint
okx.watchMyLiquidationsForSymbols (symbols, since?, limit?, params?)

watchOHLCV

watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of okx
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchOHLCV (symbol, timeframe, since?, limit?, params?)

unWatchOHLCV

watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of okx
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch OHLCV data for
timeframestringYesthe length of time each candle represents
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.unWatchOHLCV (symbol, timeframe, params?)

watchOHLCVForSymbols

watches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of okx
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

ParamTypeRequiredDescription
symbolsAndTimeframesArray<Array<string>>Yesarray of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
sinceintNotimestamp in ms of the earliest candle to fetch
limitintNothe maximum amount of candles to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchOHLCVForSymbols (symbolsAndTimeframes, since?, limit?, params?)

unWatchOHLCVForSymbols

unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market

Kind: instance method of okx
Returns: Array<Array<int>> - A list of candles ordered as timestamp, open, high, low, close, volume

ParamTypeRequiredDescription
symbolsAndTimeframesArray<Array<string>>Yesarray of arrays containing unified symbols and timeframes to fetch OHLCV data for, example [['BTC/USDT', '1m'], ['LTC/USDT', '5m']]
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.unWatchOHLCVForSymbols (symbolsAndTimeframes, params?)

watchOrderBook

watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of okx
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to fetch the order book for
limitintNothe maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.depthstringNookx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
okx.watchOrderBook (symbol, limit?, params?)

watchOrderBookForSymbols

watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of okx
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

ParamTypeRequiredDescription
symbolsArray<string>Yesunified array of symbols
limitintNo1,5, 400, 50 (l2-tbt, vip4+) or 40000 (vip5+) the maximum amount of order book entries to return
paramsobjectNoextra parameters specific to the exchange API endpoint
params.depthstringNookx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
okx.watchOrderBookForSymbols (symbols, limit?, params?)

unWatchOrderBookForSymbols

unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of okx
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

ParamTypeRequiredDescription
symbolsArray<string>Yesunified array of symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
params.limitintNothe maximum amount of order book entries to return
params.depthstringNookx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
okx.unWatchOrderBookForSymbols (symbols, params?)

unWatchOrderBook

unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data

Kind: instance method of okx
Returns: object - A dictionary of order book structures indexed by market symbols

See: https://www.okx.com/docs-v5/en/#order-book-trading-market-data-ws-order-book-channel

ParamTypeRequiredDescription
symbolstringYesunified array of symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
params.limitintNothe maximum amount of order book entries to return
params.depthstringNookx order book depth, can be books, books5, books-l2-tbt, books50-l2-tbt, bbo-tbt
okx.unWatchOrderBook (symbol, params?)

watchBalance

watch balance and get the amount of funds available for trading or funds locked in orders

Kind: instance method of okx
Returns: object - a balance structure

See: https://www.okx.com/docs-v5/en/#trading-account-websocket-account-channel

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchBalance (params?)

watchMyTrades

watches information on multiple trades made by the user

Kind: instance method of okx
Returns: Array<object> - a list of trade structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel

ParamTypeRequiredDescription
symbolstringNounified market symbol of the market trades were made in
sinceintNothe earliest time in ms to fetch trades for
limitintNothe maximum number of trade structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerboolNotrue if fetching trigger or conditional trades
params.typestringNo'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
params.marginModestringNo'cross' or 'isolated', for automatically setting the type to spot margin
okx.watchMyTrades (symbol?, since?, limit?, params?)

watchPositions

watch all open positions

Kind: instance method of okx
Returns: Array<object> - a list of position structure

See: https://www.okx.com/docs-v5/en/#trading-account-websocket-positions-channel

ParamTypeRequiredDescription
symbolsArray<string>Nolist of unified market symbols
sinceintNotimestamp in ms of the earliest position to fetch
limitintNothe maximum number of positions to fetch
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.watchPositions (symbols?, since?, limit?, params?)

watchOrders

watches information on multiple orders made by the user

Kind: instance method of okx
Returns: Array<object> - a list of order structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-order-channel

ParamTypeRequiredDescription
symbolstringNounified market symbol of the market the orders were made in
sinceintNothe earliest time in ms to fetch orders for
limitintNothe maximum number of order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.triggerboolNotrue if fetching trigger or conditional orders
params.typestringNo'spot', 'swap', 'future', 'option', 'ANY', 'SPOT', 'MARGIN', 'SWAP', 'FUTURES' or 'OPTION'
params.marginModestringNo'cross' or 'isolated', for automatically setting the type to spot margin
okx.watchOrders (symbol?, since?, limit?, params?)

createOrderWs

create a trade order

Kind: instance method of okx
Returns: object - an order structure

See: https://www.okx.com/docs-v5/en/#websocket-api-trade-place-order

ParamTypeRequiredDescription
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of currency you want to trade in units of base currency
pricefloat, undefinedNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
params.testbooleanYestest order, default false
okx.createOrderWs (symbol, type, side, amount, price?, params?)

editOrderWs

edit a trade order

Kind: instance method of okx
Returns: object - an order structure

See

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatYeshow much of the currency you want to trade in units of the base currency
pricefloat, undefinedNothe price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.editOrderWs (id, symbol, type, side, amount, price?, params?)

cancelOrderWs

cancel multiple orders

Kind: instance method of okx
Returns: object - an list of order structures

See: https://okx-docs.github.io/apidocs/websocket_api/en/#cancel-order-trade

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified market symbol, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
params.clOrdIdstringNoclient order id
okx.cancelOrderWs (id, symbol, params?)

cancelOrdersWs

cancel multiple orders

Kind: instance method of okx
Returns: object - an list of order structures

See: https://www.okx.com/docs-v5/en/#order-book-trading-trade-ws-mass-cancel-order

ParamTypeRequiredDescription
idsArray<string>Yesorder ids
symbolstringYesunified market symbol, default is undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.cancelOrdersWs (ids, symbol, params?)

cancelAllOrdersWs

cancel all open orders of a type. Only applicable to Option in Portfolio Margin mode, and MMP privilege is required.

Kind: instance method of okx
Returns: Array<object> - a list of order structures

See: https://docs.okx.com/websockets/#message-cancelAll

ParamTypeRequiredDescription
symbolstringYesunified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
paramsobjectNoextra parameters specific to the exchange API endpoint
okx.cancelAllOrdersWs (symbol, params?)

On this page

okxfetchStatusfetchTimefetchAccountsfetchMarketsfetchCurrenciesfetchOrderBookfetchTickerfetchTickersfetchMarkPricefetchMarkPricesfetchTradesfetchOHLCVfetchFundingRateHistoryfetchTradingFeefetchBalancecreateMarketBuyOrderWithCostcreateMarketSellOrderWithCostcreateOrdercreateOrderseditOrdercancelOrdercancelOrderscancelOrdersForSymbolscancelAllOrdersAfterfetchOrderfetchOpenOrdersfetchCanceledOrdersfetchClosedOrdersfetchMyTradesfetchOrderTradesfetchLedgerfetchDepositAddressesByNetworkfetchDepositAddresswithdrawfetchDepositsfetchDepositfetchWithdrawalsfetchWithdrawalfetchLeveragefetchPositionfetchPositionsfetchPositionsForSymboltransferfetchTransfersfetchFundingIntervalfetchFundingRatefetchFundingRatesfetchFundingHistorysetLeveragefetchPositionModesetPositionModesetMarginModefetchCrossBorrowRatesfetchCrossBorrowRatefetchBorrowRateHistoriesfetchBorrowRateHistoryreduceMarginaddMarginfetchMarketLeverageTiersfetchBorrowInterestborrowCrossMarginrepayCrossMarginfetchOpenInterestfetchOpenInterestsfetchOpenInterestHistoryfetchDepositWithdrawFeesfetchSettlementHistoryfetchUnderlyingAssetsfetchGreeksfetchAllGreeksclosePositionfetchOptionfetchOptionChainfetchConvertQuotecreateConvertTradefetchConvertTradefetchConvertTradeHistoryfetchConvertCurrenciesfetchMarginAdjustmentHistoryfetchPositionsHistoryfetchLongShortRatioHistorywatchTradeswatchTradesForSymbolsunWatchTradesForSymbolsunWatchTradeswatchFundingRatewatchFundingRateswatchTickerunWatchTickerwatchTickerswatchMarkPricewatchMarkPricesunWatchTickerswatchBidsAskswatchLiquidationsForSymbolswatchMyLiquidationsForSymbolswatchOHLCVunWatchOHLCVwatchOHLCVForSymbolsunWatchOHLCVForSymbolswatchOrderBookwatchOrderBookForSymbolsunWatchOrderBookForSymbolsunWatchOrderBookwatchBalancewatchMyTradeswatchPositionswatchOrderscreateOrderWseditOrderWscancelOrderWscancelOrdersWscancelAllOrdersWs