Files
ritmex-bot/docs/ccxt/wiki/exchanges/defx.md
T
2025-10-03 15:28:16 +08:00

41 KiB

defx{docsify-ignore}

Kind: global class
Extends: Exchange

fetchStatus{docsify-ignore}

the latest known information on the availability of the exchange API

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

See: https://api-docs.defx.com/#4b03bb3b-a0fa-4dfb-b96c-237bde0ce9e6

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.fetchStatus ([params])

fetchTime{docsify-ignore}

fetches the current integer timestamp in milliseconds from the exchange server

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

See: https://api-docs.defx.com/#4b03bb3b-a0fa-4dfb-b96c-237bde0ce9e6

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.fetchTime ([params])

fetchMarkets{docsify-ignore}

retrieves data on all markets for defx

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

See

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.fetchMarkets ([params])

fetchTicker{docsify-ignore}

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

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

See: https://api-docs.defx.com/#fe6f81d0-2f3a-4eee-976f-c8fc8f4c5d56

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
defx.fetchTicker (symbol[, params])

fetchTickers{docsify-ignore}

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

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

See: https://api-docs.defx.com/#8c61cfbd-40d9-410e-b014-f5b36eba51d1

Param Type Required Description
symbols Array<string>, undefined Yes unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
params object No extra parameters specific to the exchange API endpoint
defx.fetchTickers (symbols[, params])

fetchOHLCV{docsify-ignore}

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

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

See: https://api-docs.defx.com/#54b71951-1472-4670-b5af-4c2dc41e73d0

Param Type Required Description
symbol string Yes unified symbol of the market to fetch OHLCV data for
timeframe string Yes the length of time each candle represents
since int No timestamp in ms of the earliest candle to fetch
limit int No max=1000, max=100 when since is defined and is less than (now - (999 * (timeframe in ms)))
params object No extra parameters specific to the exchange API endpoint
params.until int No the latest time in ms to fetch orders for
defx.fetchOHLCV (symbol, timeframe[, since, limit, params])

fetchTrades{docsify-ignore}

get the list of most recent trades for a particular symbol

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

See: https://api-docs.defx.com/#5865452f-ea32-4f13-bfbc-03af5f5574fd

Param Type Required Description
symbol string Yes unified symbol of the market to fetch trades for
since int No timestamp in ms of the earliest trade to fetch
limit int No the maximum amount of trades to fetch
params object No extra parameters specific to the exchange API endpoint
defx.fetchTrades (symbol[, since, limit, params])

fetchMyTrades{docsify-ignore}

fetch all trades made by the user

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

See: https://api-docs.defx.com/#06b5b33c-2fc6-48de-896c-fc316f5871a7

Param Type Required Description
symbol string Yes unified symbol of the market to fetch trades for
since int No timestamp in ms of the earliest trade to fetch
limit int No the maximum amount of trades to fetch
params object No extra parameters specific to the exchange API endpoint
defx.fetchMyTrades (symbol[, since, limit, params])

fetchOrderBook{docsify-ignore}

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

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

See: https://api-docs.defx.com/#6c1a2971-8325-4e7d-9962-e0bfcaacf9c4

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the order book for
limit int No the maximum amount of order book entries to return
params object No extra parameters specific to the exchange API endpoint
params.slab string No slab from market.info.depthSlabs
defx.fetchOrderBook (symbol[, limit, params])

fetchMarkPrice{docsify-ignore}

fetches mark price for the market

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

See: https://api-docs.defx.com/#12168192-4e7b-4458-a001-e8b80961f0b7

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
params.subType string No "linear" or "inverse"
defx.fetchMarkPrice (symbol[, params])

fetchFundingRate{docsify-ignore}

fetch the current funding rate

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

See: https://api-docs.defx.com/#12168192-4e7b-4458-a001-e8b80961f0b7

Param Type Required Description
symbol string Yes unified market symbol
params object No extra parameters specific to the exchange API endpoint
defx.fetchFundingRate (symbol[, params])

fetchBalance{docsify-ignore}

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

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

See: https://api-docs.defx.com/#26414338-14f7-40a1-b246-f8ea8571493f

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.fetchBalance ([params])

createOrder{docsify-ignore}

create a trade order

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

See: https://api-docs.defx.com/#ba222d88-8856-4d3c-87a9-7cec07bb2622

Param Type Required Description
symbol string Yes unified symbol of the market to create an order in
type string Yes 'market' or 'limit'
side string Yes 'buy' or 'sell'
amount float Yes how much of currency you want to trade in units of base currency
price float No the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
params object No extra parameters specific to the exchange API endpoint
params.triggerPrice float No The price a trigger order is triggered at
params.reduceOnly string No for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to true or in hedge mode. For spot margin and option reduceOnly is a boolean.
defx.createOrder (symbol, type, side, amount[, price, params])

cancelOrder{docsify-ignore}

cancels an open order

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

See: https://api-docs.defx.com/#09186f23-f8d1-4993-acf4-9974d8a6ddb0

Param Type Required Description
id string Yes order id
symbol string Yes unified symbol of the market the order was made in
params object No extra parameters specific to the exchange API endpoint
defx.cancelOrder (id, symbol[, params])

cancelAllOrders{docsify-ignore}

cancel all open orders

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

See: https://api-docs.defx.com/#db5531da-3692-4a53-841f-6ad6495f823a

Param Type Required Description
symbol string Yes unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
params object No extra parameters specific to the exchange API endpoint
defx.cancelAllOrders (symbol[, params])

fetchPosition{docsify-ignore}

fetch data on a single open contract trade position

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

See: https://api-docs.defx.com/#d89dbb86-9aba-4f59-ac5d-a97ff25ea80e

Param Type Required Description
symbol string Yes unified market symbol of the market the position is held in, default is undefined
params object No extra parameters specific to the exchange API endpoint
defx.fetchPosition (symbol[, params])

fetchPositions{docsify-ignore}

fetch all open positions

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

See: https://api-docs.defx.com/#d89dbb86-9aba-4f59-ac5d-a97ff25ea80e

Param Type Required Description
symbols Array<string> No list of unified market symbols
params object No extra parameters specific to the exchange API endpoint
defx.fetchPositions ([symbols, params])

fetchOrder{docsify-ignore}

fetches information on an order made by the user

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

See: https://api-docs.defx.com/#44f82dd5-26b3-4e1f-b4aa-88ceddd65237

Param Type Required Description
id string Yes the order id
symbol string Yes unified symbol of the market the order was made in
params object No extra parameters specific to the exchange API endpoint
defx.fetchOrder (id, symbol[, params])

fetchOrders{docsify-ignore}

fetches information on multiple orders made by the user

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

See: https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751

Param Type Required Description
symbol string Yes unified market symbol
since int No the earliest time in ms to fetch open orders for
limit int No the maximum number of open order structures to retrieve
params object No extra parameters specific to the exchange API endpoint
params.until int No the latest time in ms to fetch orders for
defx.fetchOrders (symbol[, since, limit, params])

fetchOpenOrders{docsify-ignore}

fetch all unfilled currently open orders

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

See: https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751

Param Type Required Description
symbol string Yes unified market symbol
since int No the earliest time in ms to fetch open orders for
limit int No the maximum number of open order structures to retrieve
params object No extra parameters specific to the exchange API endpoint
params.until int No the latest time in ms to fetch orders for
defx.fetchOpenOrders (symbol[, since, limit, params])

fetchClosedOrders{docsify-ignore}

fetches information on multiple closed orders made by the user

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

See: https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751

Param Type Required Description
symbol string Yes unified market symbol
since int No the earliest time in ms to fetch open orders for
limit int No the maximum number of open order structures to retrieve
params object No extra parameters specific to the exchange API endpoint
params.until int No the latest time in ms to fetch orders for
defx.fetchClosedOrders (symbol[, since, limit, params])

fetchCanceledOrders{docsify-ignore}

fetches information on multiple canceled orders made by the user

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

See: https://api-docs.defx.com/#ab200038-8acb-4170-b05e-4fcb4cc13751

Param Type Required Description
symbol string Yes unified market symbol
since int No the earliest time in ms to fetch open orders for
limit int No the maximum number of open order structures to retrieve
params object No extra parameters specific to the exchange API endpoint
params.until int No the latest time in ms to fetch orders for
defx.fetchCanceledOrders (symbol[, since, limit, params])

closePosition{docsify-ignore}

closes an open position for a market

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

See: https://api-docs.defx.com/#b2c08074-c4d9-4e50-b637-0d6c498fa29e

Param Type Required Description
symbol string Yes unified CCXT market symbol
side string No one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
params object No extra parameters specific to the exchange API endpoint
params.positionId string No the position id you want to close
params.type string No 'MARKET' or 'LIMIT'
params.quantity string No how much of currency you want to trade in units of base currency
params.price string No the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
defx.closePosition (symbol[, side, params])

closeAllPositions{docsify-ignore}

closes all open positions for a market type

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

See: https://api-docs.defx.com/#d6f63b43-100e-47a9-998c-8b6c0c72d204

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.closeAllPositions ([params])

fetchLedger{docsify-ignore}

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

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

See: https://api-docs.defx.com/#38cc8974-794f-48c0-b959-db045a0ee565

Param Type Required Description
code string No unified currency code
since int No timestamp in ms of the earliest ledger entry
limit int No max number of ledger entries to return
params object No extra parameters specific to the exchange API endpoint
params.until int No timestamp in ms of the latest ledger entry
params.paginate boolean No default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the available parameters
defx.fetchLedger ([code, since, limit, params])

withdraw{docsify-ignore}

make a withdrawal

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

See: https://api-docs.defx.com/#2600f503-63ed-4672-b8f6-69ea5f03203b

Param Type Required Description
code string Yes unified currency code
amount float Yes the amount to withdraw
address string Yes the address to withdraw to
tag string Yes
params object No extra parameters specific to the exchange API endpoint
defx.withdraw (code, amount, address, tag[, params])

setLeverage{docsify-ignore}

set the level of leverage for a market

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

See: https://api-docs.defx.com/#4cb4ecc4-6c61-4194-8353-be67faaf7ca7

Param Type Required Description
leverage float Yes the rate of leverage
symbol string Yes unified market symbol
params object No extra parameters specific to the exchange API endpoint
defx.setLeverage (leverage, symbol[, params])

watchOHLCV{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch OHLCV data for
timeframe string Yes the length of time each candle represents
since int No timestamp in ms of the earliest candle to fetch
limit int No the maximum amount of candles to fetch
params object No extra parameters specific to the exchange API endpoint
defx.watchOHLCV (symbol, timeframe[, since, limit, params])

unWatchOHLCV{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch OHLCV data for
timeframe string Yes the length of time each candle represents
params object No extra parameters specific to the exchange API endpoint
defx.unWatchOHLCV (symbol, timeframe[, params])

watchOHLCVForSymbols{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbolsAndTimeframes Array<Array<string>> Yes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example 'BTC/USDT', '1m'], ['LTC/USDT', '5m'
since int No timestamp in ms of the earliest candle to fetch
limit int No the maximum amount of candles to fetch
params object No extra parameters specific to the exchange API endpoint
defx.watchOHLCVForSymbols (symbolsAndTimeframes[, since, limit, params])

unWatchOHLCVForSymbols{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbolsAndTimeframes Array<Array<string>> Yes array of arrays containing unified symbols and timeframes to fetch OHLCV data for, example 'BTC/USDT', '1m'], ['LTC/USDT', '5m'
params object No extra parameters specific to the exchange API endpoint
defx.unWatchOHLCVForSymbols (symbolsAndTimeframes[, params])

watchTicker{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
defx.watchTicker (symbol[, params])

unWatchTicker{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
params.channel string No the channel to subscribe to, tickers by default. Can be tickers, sprd-tickers, index-tickers, block-tickers
defx.unWatchTicker (symbol[, params])

watchTickers{docsify-ignore}

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 defx
Returns: object - a ticker structure

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> No unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
defx.watchTickers ([symbols, params])

unWatchTickers{docsify-ignore}

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 defx
Returns: object - a ticker structure

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> No unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
defx.unWatchTickers ([symbols, params])

watchBidsAsks{docsify-ignore}

watches best bid & ask for symbols

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> Yes unified symbol of the market to fetch the ticker for
params object No extra parameters specific to the exchange API endpoint
defx.watchBidsAsks (symbols[, params])

watchTrades{docsify-ignore}

watches information on multiple trades made in a market

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the ticker for
since int No the earliest time in ms to fetch trades for
limit int No the maximum number of trade structures to retrieve
params object No extra parameters specific to the exchange API endpoint
defx.watchTrades (symbol[, since, limit, params])

unWatchTrades{docsify-ignore}

unWatches from the stream channel

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch trades for
params object No extra parameters specific to the exchange API endpoint
defx.unWatchTrades (symbol[, params])

watchTradesForSymbols{docsify-ignore}

watches information on multiple trades made in a market

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> Yes unified symbol of the market to fetch trades for
since int No the earliest time in ms to fetch trades for
limit int No the maximum number of trade structures to retrieve
params object No extra parameters specific to the exchange API endpoint
defx.watchTradesForSymbols (symbols[, since, limit, params])

unWatchTradesForSymbols{docsify-ignore}

unWatches from the stream channel

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> Yes unified symbol of the market to fetch trades for
params object No extra parameters specific to the exchange API endpoint
defx.unWatchTradesForSymbols (symbols[, params])

watchOrderBook{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified symbol of the market to fetch the order book for
limit int No the maximum amount of order book entries to return
params object No extra parameters specific to the exchange API endpoint
defx.watchOrderBook (symbol[, limit, params])

unWatchOrderBook{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbol string Yes unified array of symbols
params object No extra parameters specific to the exchange API endpoint
defx.unWatchOrderBook (symbol[, params])

watchOrderBookForSymbols{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> Yes unified array of symbols
limit int No the maximum amount of order book entries to return
params object No extra parameters specific to the exchange API endpoint
defx.watchOrderBookForSymbols (symbols[, limit, params])

unWatchOrderBookForSymbols{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/collection/667939a1b5d8069c13d614e9

Param Type Required Description
symbols Array<string> Yes unified array of symbols
params object No extra parameters specific to the exchange API endpoint
defx.unWatchOrderBookForSymbols (symbols[, params])

watchBalance{docsify-ignore}

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

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

See: https://www.postman.com/defxcode/defx-public-apis/ws-raw-request/667939b2f00f79161bb47809

Param Type Required Description
params object No extra parameters specific to the exchange API endpoint
defx.watchBalance ([params])

watchOrders{docsify-ignore}

watches information on multiple orders made by the user

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

See: https://www.postman.com/defxcode/defx-public-apis/ws-raw-request/667939b2f00f79161bb47809

Param Type Required Description
symbol string No unified market symbol of the market the orders were made in
since int No the earliest time in ms to fetch orders for
limit int No the maximum number of order structures to retrieve
params object No extra parameters specific to the exchange API endpoint
defx.watchOrders ([symbol, since, limit, params])

watchPositions{docsify-ignore}

watch all open positions

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

See: https://www.postman.com/defxcode/defx-public-apis/ws-raw-request/667939b2f00f79161bb47809

Param Type Required Description
symbols Array<string>, undefined Yes list of unified market symbols
since number No since timestamp
limit number No limit
params object Yes extra parameters specific to the exchange API endpoint
defx.watchPositions (symbols[, since, limit, params])