Skip to content

Latest commit

 

History

History
2698 lines (1939 loc) · 86.7 KB

docs.md

File metadata and controls

2698 lines (1939 loc) · 86.7 KB

Table of Contents

pipmath

constants

__init__

signatures

create_private_key_message_signer

def create_private_key_message_signer(
        wallet_private_key: str) -> MessageSigner

Returns a function which signs a message with the originally provided private key.

Arguments:

  • wallet_private_key - Private key to use when signing messages

Returns:

The message signing function

idex_types

idex_types.websocket.guards

idex_types.websocket.constants

idex_types.websocket.request

WebSocketRequestTickersSubscription Objects

class WebSocketRequestTickersSubscription(TypedDict)

Tickers subscription

Attributes:

  • name - 'tickers'
  • markets - array of market symbols

WebSocketRequestCandlesSubscription Objects

class WebSocketRequestCandlesSubscription(TypedDict)

Candles subscription

Attributes:

  • name - 'candles'
  • markets - array of market symbols
  • interval - candle interval

WebSocketRequestTokenPriceSubscription Objects

class WebSocketRequestTokenPriceSubscription(TypedDict)

Token price subscription

Attributes:

  • name - 'tokenprice'
  • markets - array of market symbols

WebSocketRequestTradesSubscription Objects

class WebSocketRequestTradesSubscription(TypedDict)

Trades subscription

Attributes:

  • name - 'trades'
  • markets - array of market symbols

WebSocketRequestL1OrderBookSubscription Objects

class WebSocketRequestL1OrderBookSubscription(TypedDict)

L1 order book subscription

Attributes:

  • name - 'l1orderbook'
  • markets - array of market symbols

WebSocketRequestL2OrderBookSubscription Objects

class WebSocketRequestL2OrderBookSubscription(TypedDict)

L2 order book subscription

Attributes:

  • name - 'l2orderbook'
  • markets - array of market symbols

WebSocketRequestWallet Objects

class WebSocketRequestWallet(TypedDict)

wallet is required and is only handled by the idex-sdk. It is used to auto generate the required wsToken

idex_types.websocket

idex_types.websocket.response

WebSocketResponseTickerShort Objects

class WebSocketResponseTickerShort(TypedDict)

Attributes:

  • m - (market) Market symbol
  • t - (time) Timestamp when the statistics were computed, the opening time of the period is 24 hours prior
  • o - (open) Price of the first trade in the period in quote terms
  • h - (high) Highest traded price in the period in quote terms
  • l - (low) Lowest traded price in the period in quote terms
  • c - (close) Price of the last trade in the period in quote terms
  • Q - (closeQuantity) Quantity of the last trade in th period in base terms
  • v - (baseVolume) Trailing 24-hour trading volume in base terms
  • q - (quoteVolume) Trailing 24-hour trading volume in quote terms
  • P - (percentChange) Percentage change from open price to close price
  • n - (numTrades) Number of trades in the period
  • a - (ask) Best ask price on the order book in quote terms
  • b - (bid) Best bid price on the order book in quote terms
  • u - (sequence) Fill sequence number of the last trade in the period

WebSocketResponseCandleShort Objects

class WebSocketResponseCandleShort(TypedDict)

Attributes:

  • m - (market) Market symbol
  • t - (time) Timestamp when the statistics were computed, time is always between the start and end timestamps of the interval
  • i - (interval) Interval duration, see Interval Values
  • s - (start) Timestamp of the start of the interval
  • e - (end) Timestamp of the end of the interval
  • o - (open) Price of the first trade in the interval in quote terms
  • h - (high) Highest traded price in the interval in quote terms
  • l - (low) Lowest traded price in the interval in quote terms
  • c - (close) Price of the last trade in the interval in quote terms
  • v - (volume) Trading volume in the interval in base terms
  • n - (numTrades) Number of trades in the candle
  • u - (sequence) Fill sequence number of the last trade in the interval

WebSocketResponseCandleLong Objects

class WebSocketResponseCandleLong(rest_response.RestResponseCandle)

Attributes:

  • market - Market symbol
  • time - Timestamp when the statistics were computed, time is always between the start and end timestamps of the interval
  • interval - Interval duration, see Interval Values
  • start - Timestamp of the start of the interval
  • end - Timestamp of the end of the interval
  • open - Price of the first trade in the interval in quote terms
  • high - Highest traded price in the interval in quote terms
  • low - Lowest traded price in the interval in quote terms
  • close - Price of the last trade in the interval in quote terms
  • volume - Trading volume in the interval in base terms
  • numTrades - Number of trades in the candle
  • sequence - Fill sequence number of the last trade in the interval

WebSocketResponseTradeShort Objects

class WebSocketResponseTradeShort(TypedDict)

Attributes:

  • y - (type) orderBook, pool, or hybrid
  • m - (market) Market symbol
  • i - (fillId) Trade identifier
  • p - (price) Price of the trade in quote terms
  • q - (quantity) Quantity of the trade in base terms
  • Q - (quoteQuantity) Quantity of the trade in quote terms
  • t - (time) Timestamp of the trade
  • s - (makerSide) Maker side of the trade, buy or sell
  • u - (sequence) Fill sequence number of the trade

WebSocketResponseLiquidityPoolShort Objects

class WebSocketResponseLiquidityPoolShort(TypedDict)

Attributes:

  • q - (baseReserveQuantity) quantity of base asset held in the liquidity pool
  • Q - (quoteReserveQuantity) quantity of quote asset held in the liquidity pool

WebSocketResponseLiquidityPoolLong Objects

class WebSocketResponseLiquidityPoolLong(TypedDict)

Attributes:

  • baseReserveQuantity - quantity of base asset held in the liquidity pool
  • quoteReserveQuantity - quantity of quote asset held in the liquidity pool

WebSocketResponseL1OrderBookShort Objects

class WebSocketResponseL1OrderBookShort(TypedDict)

Attributes:

  • m - (market) Market symbol
  • t - (time) Timestamp of the order book update
  • b - (bidPrice) Best bid price
  • B - (bidQuantity) Quantity available at the best bid price
  • a - (askPrice) Best ask price
  • A - (askQuantity) Quantity available at the best ask price
  • p - Liquidity pool reserves for this market

WebSocketResponseL1OrderBookLong Objects

class WebSocketResponseL1OrderBookLong(TypedDict)

Attributes:

  • market - Market symbol
  • time - Timestamp of the order book update
  • bidPrice - Best bid price
  • bidQuantity - Quantity available at the best bid price
  • askPrice - Best ask price
  • askQuantity - Quantity available at the best ask price
  • pool - Liquidity pool reserves for this market

WebSocketResponseL2OrderBookShort Objects

class WebSocketResponseL2OrderBookShort(TypedDict)

Attributes:

  • m - (market) Market symbol
  • t - (time) Timestamp of the order book update
  • u - (sequence) Order book update sequence number of the update
  • b - (bids) Array of bid price level updates
  • a - (asks) Array of ask price level updates
  • p - Liquidity pool reserves for this market

WebSocketResponseL2OrderBookLong Objects

class WebSocketResponseL2OrderBookLong(TypedDict)

Attributes:

  • market - Market symbol
  • time - Timestamp of the order book update
  • sequence - Order book update sequence number of the update
  • bids - Array of bid price level updates
  • asks - Array of ask price level updates
  • pool - liquidity pool reserves
  • p - Liquidity pool reserves for this market

WebSocketResponseBalanceShort Objects

class WebSocketResponseBalanceShort(TypedDict)

Attributes:

  • w - (wallet) Target wallet address
  • a - (asset) Asset symbol
  • q - (quantity) Total quantity of the asset held by the wallet on the exchange
  • f - (availableForTrade) Quantity of the asset available for trading; quantity: locked
  • l - (locked) Quantity of the asset held in trades on the order book
  • d - (usdValue) Total value of the asset held by the wallet on the exchange in USD

WebSocketResponseBalanceLong Objects

class WebSocketResponseBalanceLong(TypedDict)

Attributes:

  • wallet - Target wallet address
  • asset - Asset symbol
  • quantity - Total quantity of the asset held by the wallet on the exchange
  • availableForTrade - Quantity of the asset available for trading; quantity: locked
  • locked - Quantity of the asset held in trades on the order book
  • usdValue - Total value of the asset held by the wallet on the exchange in USD

WebSocketResponseOrderFillShort Objects

class WebSocketResponseOrderFillShort(
        _WebSocketResponseOrderFillShortRequiredAttribs)

Attributes:

  • i - (fillId) Fill identifier
  • p - (price) Price of the fill in quote terms
  • q - (quantity) Quantity of the fill in base terms
  • Q - (quoteQuantity) Quantity of the fill in quote terms
  • oq - Quantity of the fill in base terms supplied by order book liquidity, omitted for pool fills
  • oQ - Quantity of the fill in quote terms supplied by order book liquidity, omitted for pool fills
  • pq - Quantity of the fill in base terms supplied by pool liquidity, omitted for orderBook fills
  • pQ - Quantity of the fill in quote terms supplied by pool liquidity, omitted for orderBook fills
  • t - (time) Timestamp of the fill
  • s - (makerSide) Maker side of the fill, buy or sell
  • u - (sequence) Fill sequence number
  • f - (fee) Fee amount collected on the fill
  • a - (feeAsset) Symbol of asset in which fees collected
  • g - (gas) Amount collected to cover trade settlement gas costs, only present for taker
  • l - (liquidity) Whether the fill is the maker or taker in the trade from the perspective of the requesting user account, maker or taker
  • T - (txId) Ethereum ID of the trade settlement transaction
  • S - (txStatus) Status of the trade settlement transaction, see values

WebSocketResponseOrderShort Objects

class WebSocketResponseOrderShort(_WebSocketResponseOrderShortRequiredAttribs)

Attributes:

  • m - (market) Market symbol
  • i - (orderId) Exchange-assigned order identifier
  • c - (clientOrderId) Client-specified order identifier w : (wallet) Ethereum address of placing wallet
  • t - (executionTime) Timestamp of the most recent update
  • T - (time) Timestamp of initial order processing by the matching engine
  • x - (update) Type of order update, see values
  • X - (status) Order status, see values
  • u - (sequence) order book update sequence number, only included if update type triggers an order book update
  • o - (type) Order type, see values
  • S - (side) Order side, buy or sell
  • q - (originalQuantity) Original quantity specified by the order in base terms, omitted for market orders specified in quote terms
  • Q - (originalQuoteQuantity) Original quantity specified by the order in quote terms, only present for market orders specified in quote term
  • z - (executedQuantity) Quantity that has been executed in base terms
  • Z - (cumulativeQuoteQuantity) Cumulative quantity that has been spent (buy orders) or received (sell orders) in quote terms, omitted if unavailable for historical orders
  • v - (avgExecutionPrice) Weighted average price of fills associated with the order; only present with fills
  • p - (price) Original price specified by the order in quote terms, omitted for all market orders
  • P - (stopPrice) Stop loss or take profit price, only present for stopLoss, stopLossLimit, takeProfit, and takeProfitLimit orders
  • f - (timeInForce) Time in force policy, see values, only present for limit orders
  • V - (selfTradePrevention) Self-trade prevention policy, see values
  • F - (fills) Array of order fill objects

WebSocketResponseOrderLong Objects

class WebSocketResponseOrderLong(_WebSocketResponseOrderLongRequiredAttribs)

Attributes:

  • market - Market symbol
  • orderId - Exchange-assigned order identifier
  • clientOrderId - Client-specified order identifier
  • wallet - Ethereum address of placing wallet
  • executionTime - Timestamp of the most recent update
  • time - Timestamp of initial order processing by the matching engine
  • update - Type of order update, see values
  • status - Order status, see values
  • sequence - order book update sequence number, only included if update type triggers an order book update
  • type - Order type, see values
  • side - Order side, buy or sell
  • originalQuantity - Original quantity specified by the order in base terms, omitted for market orders specified in quote terms
  • originalQuoteQuantity - Original quantity specified by the order in quote terms, only present for market orders specified in quote terms
  • executedQuantity - Quantity that has been executed in base terms
  • cumulativeQuoteQuantity - Cumulative quantity that has been spent (buy orders) or received (sell orders) in quote terms, omitted if unavailable for historical orders
  • avgExecutionPrice - Weighted average price of fills associated with the order; only present with fills
  • price - Original price specified by the order in quote terms, omitted for all market orders
  • stopPrice - Stop loss or take profit price, only present for stopLoss, stopLossLimit, takeProfit, and takeProfitLimit orders
  • timeInForce - Time in force policy, see values, only present for limit orders
  • selfTradePrevention - Self-trade prevention policy, see values
  • fills - Array of order fill objects

WebSocketResponseTokenPriceShort Objects

class WebSocketResponseTokenPriceShort(TypedDict)

Attributes:

  • t - (token) Token symbol
  • p - (price) Current price of token relative to the native asset

WebSocketResponseTokenPriceLong Objects

class WebSocketResponseTokenPriceLong(TypedDict)

Attributes:

  • token - Token symbol
  • price - Current price of token relative to the native asset

WebSocketResponseError Objects

class WebSocketResponseError(_WebSocketResponseErrorRequiredAttribs)

Error response

Attributes:

cid error data

  • data.code - error short code
  • data.message - human readable error message

WebSocketResponseSubscriptions Objects

class WebSocketResponseSubscriptions(
        _WebSocketResponseSubscriptionsRequiredAttribs)

Subscriptions response

Attributes:

cid

  • type - subscriptions subscriptions
  • Subscription.name - subscription name
  • Subscription.markets - markets
  • Subscription.interval - candle interval
  • Subscription.wallet - wallet address

idex_types.enums

idex_types.order_book

OrderBookFeesAndMinimums Objects

class OrderBookFeesAndMinimums(TypedDict)

Attributes:

  • takerIdexFeeRate - Taker trade fee rate collected by IDEX; used in computing synthetic price levels for real-time order book
  • takerLiquidityProviderFeeRate - Taker trade fee rate collected by liquidity providers; used in computing synthetic price levels for real-time order book
  • takerTradeMinimum - Minimum order size that is accepted by the matching engine for execution in MATIC, applies to both MATIC and token

idex_types.errors

idex_types.rest.guards

idex_types.rest.request

RestRequestFindLiquidityPools Objects

class RestRequestFindLiquidityPools(TypedDict)

Attributes:

  • market - Target market
  • tokenA - Address of one reserve token
  • tokenB - Address of one reserve token

RestRequestAddLiquidity Objects

class RestRequestAddLiquidity(TypedDict)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • tokenA - Asset by address
  • tokenB - Asset by address
  • amountADesired - Maximum amount of tokenA to add to the liquidity pool
  • amountBDesired - Maximum amount of tokenB to add to the liquidity pool
  • amountAMin - Minimum amount of tokenA to add to the liquidity pool
  • amountBMin - Minimum amount of tokenB to add to the liquidity pool
  • to - Wallet to credit LP tokens, or the custodian contract address to leave on exchange

RestRequestRemoveLiquidity Objects

class RestRequestRemoveLiquidity(TypedDict)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • tokenA - Asset by address
  • tokenB - Asset by address
  • liquidity - LP tokens to burn
  • amountAMin - Minimum amount of tokenA to add to the liquidity pool
  • amountBMin - Minimum amount of tokenB to add to the liquidity pool
  • to - Wallet to credit LP tokens, or the custodian contract address to leave on exchange

RestRequestFindLiquidityAddition Objects

class RestRequestFindLiquidityAddition(RestRequestFindLiquidityChange,
                                       RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • liquidityAdditionId - Single liquidityAdditionId to return; exclusive with initiatingTxId
  • initiatingTxId - Transaction id of the Exchange contract addLiquidity or addLiquidityETH call transaction, only applies to chain-initiated liquidity additions; exclusive with liquidityAdditionId
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Liquidity additions created at the same timestamp or after fromId

RestRequestFindLiquidityRemoval Objects

class RestRequestFindLiquidityRemoval(RestRequestFindLiquidityChange,
                                      RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • liquidityRemovalId - Single liquidityRemovalId to return; exclusive with initiatingTxId
  • initiatingTxId - Transaction id of the Exchange contract removeLiquidity or removeLiquidityETH call transaction, only applies to chain-initiated liquidity removals; exclusive with liquidityRemovalId
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Liquidity additions created at the same timestamp or after fromId

RestRequestFindLiquidityChanges Objects

class RestRequestFindLiquidityChanges(
        _RestRequestFindLiquidityChangesRequiredAttribs)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Deposits created at the same timestamp or after fromId

RestRequestCancelOrders Objects

class RestRequestCancelOrders(RestRequestCancelOrdersBase)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • market - Base-quote pair e.g. 'IDEX-ETH'

RestRequestFindBalances Objects

class RestRequestFindBalances(RestRequestFindByWallet)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • assets - Asset symbols

RestRequestFindCandles Objects

class RestRequestFindCandles(RestRequestFindWithPagination)

Attributes:

  • market - Base-quote pair e.g. 'IDEX-ETH'
  • interval - Time interval for data
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000

RestRequestFindDeposit Objects

class RestRequestFindDeposit(RestRequestFindByWallet)

Attributes:

  • nonce - UUIDv1 wallet depositId

RestRequestFindDeposits Objects

class RestRequestFindDeposits(RestRequestFindByWallet,
                              RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1 wallet
  • asset - Asset by symbol
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Deposits created at the same timestamp or after fromId

RestRequestFindFill Objects

class RestRequestFindFill(RestRequestFindByWallet)

Attributes:

  • nonce - UUIDv1 wallet fillId

RestRequestFindFills Objects

class RestRequestFindFills(RestRequestFindByWallet,
                           RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1
  • wallet - Ethereum wallet address
  • market - Base-quote pair e.g. 'IDEX-ETH'
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Fills created at the same timestamp or after fillId

RestRequestFindMarkets Objects

class RestRequestFindMarkets(TypedDict)

Attributes:

  • market - Target market, all markets are returned if omitted

RestRequestFindOrder Objects

class RestRequestFindOrder(RestRequestFindByWallet)

Attributes:

  • nonce - UUIDv1 wallet
  • orderId - Single orderId or clientOrderId to cancel; prefix client-provided ids with client

RestRequestFindOrders Objects

class RestRequestFindOrders(RestRequestFindByWallet,
                            RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1 wallet
  • market - Base-quote pair e.g. 'IDEX-ETH'
  • closed - false only returns active orders on the order book; true only returns orders that are no longer on the order book and resulted in at least one fill; only applies if orderId is absent
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - order_id of the earliest (oldest) order, only applies if orderId is absent

RestRequestFindTrades Objects

class RestRequestFindTrades(RestRequestFindWithPagination)

Attributes:

  • market - Base-quote pair e.g. 'IDEX-ETH'
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Trades created at the same timestamp or after from_id

RestRequestFindWithdrawal Objects

class RestRequestFindWithdrawal(RestRequestFindByWallet)

Attributes:

  • nonce - UUIDv1 wallet withdrawalId

RestRequestFindWithdrawals Objects

class RestRequestFindWithdrawals(RestRequestFindByWallet,
                                 RestRequestFindWithPagination)

Attributes:

  • nonce - UUIDv1 wallet
  • asset - Asset by symbol
  • assetContractAddress - Asset by contract address
  • start - Starting timestamp (inclusive)
  • end - Ending timestamp (inclusive)
  • limit - Max results to return from 1-1000
  • fromId - Withdrawals created after the fromId

RestRequestAssociateWallet Objects

class RestRequestAssociateWallet(TypedDict)

Attributes:

  • nonce - UUIDv1
  • wallet - The wallet to associate with the authenticated account

idex_types.rest

idex_types.rest.response

RestResponseBalance Objects

class RestResponseBalance(TypedDict)

Attributes:

  • asset - Asset symbol
  • quantity - Total quantity of the asset held by the wallet on the exchange
  • availableForTrade - Quantity of the asset available for trading; quantity: locked
  • locked - Quantity of the asset held in trades on the order book
  • usdValue - Total value of the asset held by the wallet on the exchange in USD

RestResponseCandle Objects

class RestResponseCandle(TypedDict)

Attributes:

  • start - Time of the start of the interval
  • open - Price of the first fill of the interval in quote terms
  • high - Price of the highest fill of the interval in quote terms
  • low - Price of the lowest fill of the interval in quote terms
  • close - Price of the last fill of the interval in quote terms
  • volume - Total volume of the period in base terms
  • sequence - Fill sequence number of the last trade in the interval

RestResponseDeposit Objects

class RestResponseDeposit(TypedDict)

Asset deposits into smart contract

Attributes:

  • depositId - IDEX-issued deposit identifier
  • asset - Asset by symbol
  • quantity - Deposit amount in asset terms
  • txId - Ethereum transaction hash
  • txTime - Timestamp of the Ethereum deposit transaction
  • confirmationTime - Timestamp of credit on IDEX including block confirmations

RestResponseExchangeInfo Objects

class RestResponseExchangeInfo(TypedDict)

Attributes:

  • timeZone - Server time zone, always UTC
  • serverTime - Current server time
  • maticDepositContractAddress - Polygon address of the exchange smart contract for deposits
  • maticCustodyContractAddress - Polygon address of the custody smart contract for certain add and remove liquidity calls
  • maticUsdPrice - Current price of MATIC in USD
  • gasPrice - Current gas price used by the exchange for trade settlement and withdrawal transactions in Gwei
  • volume24hUsd - Total exchange trading volume for the trailing 24 hours in USD
  • totalVolumeUsd - Total exchange trading volume for IDEX v3 on Polygon in USD
  • totalTrades - Total number of trade executions for IDEX v3 on Polygon
  • totalValueLockedUsd - Total value locked in IDEX v3 on Polygon in USD
  • idexTokenAddress - Token contract address for the IDEX token on Polygon
  • idexUsdPrice - Current price of the IDEX token in USD
  • idexMarketCapUsd - Market capitalization of the IDEX token in USD
  • makerFeeRate - Maker trade fee rate
  • takerFeeRate - Total taker trade fee rate
  • takerIdexFeeRate - Taker trade fee rate collected by IDEX; used in computing synthetic price levels for real-time order books
  • takerLiquidityProviderFeeRate - Taker trade fee rate collected by liquidity providers; used in computing synthetic price levels for real-time order books
  • makerTradeMinimum - Minimum size of an order that can rest on the order book in MATIC, applies to both MATIC and tokens
  • takerTradeMinimum - Minimum order size that is accepted by the matching engine for execution in MATIC, applies to both MATIC and tokens
  • withdrawMinimum - Minimum withdrawal amount in MATIC, applies to both MATIC and tokens
  • liquidityAdditionMinimum - Minimum liquidity addition amount in MATIC, applies to both MATIC and tokens
  • liquidityRemovalMinimum - Minimum withdrawal amount in MATIC, applies to both MATIC and tokens
  • blockConfirmationDelay - Minimum number of block confirmations before on-chain transactions are processed

RestResponseOrderFill Objects

class RestResponseOrderFill(_RestResponseOrderFillRequiredAttribs)

Attributes:

  • fillId - Internal ID of fill
  • price - Executed price of fill in quote terms
  • quantity - Executed quantity of fill in base terms
  • quoteQuantity - Executed quantity of trade in quote terms
  • orderBookQuantity - Quantity of the fill in base terms supplied by order book liquidity, omitted for pool fills
  • orderBookQuoteQuantity - Quantity of the fill in quote terms supplied by order book liquidity, omitted for pool fills
  • poolQuantity - Quantity of the fill in base terms supplied by pool liquidity, omitted for orderBook fills
  • poolQuoteQuantity - Quantity of the fill in quote terms supplied by pool liquidity, omitted for orderBook fills
  • time - Fill timestamp
  • makerSide - Which side of the order the liquidity maker was on
  • sequence - Last trade sequence number for the market
  • fee - Fee amount on fill
  • feeAsset - Which token the fee was taken in gas liquidity
  • type - orderBook, pool, or hybrid
  • txId - Ethereum transaction ID, if available
  • txStatus - Ethereum transaction status

RestResponseFill Objects

class RestResponseFill(_RestResponseFillRequiredAttribs)

Attributes:

  • fillId - Internal ID of fill
  • price - Executed price of fill in quote terms
  • quantity - Executed quantity of fill in base terms
  • quoteQuantity - Executed quantity of fill in quote terms
  • orderBookQuantity - Quantity of the fill in base terms supplied by order book liquidity, omitted for pool fills
  • orderBookQuoteQuantity - Quantity of the fill in quote terms supplied by order book liquidity, omitted for pool fills
  • poolQuantity - Quantity of the fill in base terms supplied by pool liquidity, omitted for orderBook fills
  • poolQuoteQuantity - Quantity of the fill in quote terms supplied by pool liquidity, omitted for orderBook fills
  • time - Fill timestamp
  • makerSide - Which side of the order the liquidity maker was on
  • sequence - Last trade sequence number for the market
  • market - Base-quote pair e.g. 'IDEX-ETH'
  • orderId - Internal ID of order
  • clientOrderId - Client-provided ID of order
  • side - Orders side, buy or sell
  • fee - Fee amount on fill
  • feeAsset - Which token the fee was taken in
  • gas - Amount collected to cover trade settlement gas costs, only present for taker
  • liquidity - Whether the fill is the maker or taker in the trade from the perspective of the requesting API account, maker or taker
  • type - Fill type
  • txId - Ethereum transaction ID, if available
  • txStatus - Ethereum transaction status

RestResponseLiquidityPool Objects

class RestResponseLiquidityPool(TypedDict)

Attributes:

  • tokenA - Address of one reserve token
  • tokenB - Address of one reserve token
  • reserveA - Quantity of token A held as reserve in token precision, not pips
  • reserveB - Quantity of token B held as reserve in token precision, not pips
  • liquidityToken - Address of the liquidity provider (LP) token
  • totalLiquidity - Total quantity of liquidity provider (LP) tokens minted in token precision, not pips
  • reserveUsd - Total value of reserves in USD
  • market - Market symbol of pool's associated hybrid market

RestResponseLiquidityAddition Objects

class RestResponseLiquidityAddition(RestResponseLiquidityBase)

Attributes:

  • liquidityAdditionId - Internal ID of liquidity addition
  • tokenA - Asset symbol
  • tokenB - Asset symbol
  • amountA - Amount of tokenA added to the liquidity pool
  • amountB - Amount of tokenB added to the liquidity pool
  • liquidity - Amount of liquidity provided (LP) tokens minted
  • time - Liquidity addition timestamp
  • initiatingTxId - On chain initiated transaction ID, if available
  • errorCode - Error short code present on liquidity addition error
  • errorMessage - Human-readable error message present on liquidity addition error
  • feeTokenA - Amount of tokenA collected as fees
  • feeTokenB - Amount of tokenB collected as fees
  • txId - Ethereum transaction ID, if available
  • txStatus - Ethereum transaction status

RestResponseLiquidityPoolReserves Objects

class RestResponseLiquidityPoolReserves(TypedDict)

Attributes:

  • baseReserveQuantity - reserve quantity of base asset in pool
  • quoteReserveQuantity - reserve quantity of quote asset in pool

RestResponseLiquidityRemoval Objects

class RestResponseLiquidityRemoval(RestResponseLiquidityBase)

Attributes:

  • liquidityRemovalId - Internal ID of liquidity removal
  • tokenA - Asset symbol
  • tokenB - Asset symbol
  • amountA - Amount of tokenA added to the liquidity pool
  • amountB - Amount of tokenB added to the liquidity pool
  • liquidity - Amount of liquidity provided (LP) tokens minted
  • time - Liquidity addition timestamp
  • initiatingTxId - On chain initiated transaction ID, if available
  • errorCode - Error short code present on liquidity addition error
  • errorMessage - Human-readable error message present on liquidity addition error
  • feeTokenA - Amount of tokenA collected as fees
  • feeTokenB - Amount of tokenB collected as fees
  • txId - Ethereum transaction ID, if available
  • txStatus - Ethereum transaction status

RestResponseMarket Objects

class RestResponseMarket(TypedDict)

Attributes:

  • market - Market symbol
  • type - Market type
  • status - Market trading status
  • baseAsset - Base asset symbol
  • baseAssetPrecision - Exchange decimal precision of the base asset, always 8 due to precision normalization
  • quoteAsset - Quote asset symbol
  • quoteAssetPrecision - Exchange decimal precision of the base asset, always 8 due to precision normalization
  • makerFeeRate - Maker trade fee rate
  • takerFeeRate - Total taker trade fee rate
  • takerIdexFeeRate - Taker trade fee rate collected by IDEX; used in computing synthetic price levels for real-time order books
  • takerLiquidityProviderFeeRate - Taker trade fee rate collected by liquidity providers; used in computing synthetic price levels for real-time order books
  • tickSize - Market tick size (minimum change in order price)

RestResponseOrder Objects

class RestResponseOrder(_RestResponseOrderRequiredAttribs)

Attributes:

  • market - Market symbol as base-quote pair e.g. 'IDEX-ETH'
  • orderId - Exchange-assigned order identifier
  • clientOrderId - Client-specified order identifier
  • wallet - Ethereum address of placing wallet
  • time - Time of initial order processing by the matching engine
  • status - Current order status
  • errorCode - Error short code explaining order error or failed batch cancel
  • errorMessage - Error description explaining order error or failed batch cancel
  • type - Order type
  • side - Order side
  • originalQuantity - Original quantity specified by the order in base terms, omitted for market orders specified in quote terms
  • originalQuoteQuantity - Original quantity specified by the order in quote terms, only present for market orders specified in quote terms
  • executedQuantity - Quantity that has been executed in base terms
  • cumulativeQuoteQuantity - Cumulative quantity that has been spent (buy orders) or received (sell orders) in quote terms, omitted if unavailable for historical orders
  • avgExecutionPrice - Weighted average price of fills associated with the order; only present with fills price - Original price specified by the order in quote terms, omitted for all market orders
  • stopPrice - Stop loss or take profit price, only present for stopLoss, stopLossLimit, takeProfit, and takeProfitLimit orders
  • timeInForce - Time in force policy, see values, only present for limit orders
  • selfTradePrevention - Self-trade prevention policy, see values
  • fills - Array of order fill objects

RestResponseTicker Objects

class RestResponseTicker(TypedDict)

Attributes:

  • market - Base-quote pair e.g. 'IDEX-ETH'
  • time - Time when data was calculated, open and change is assumed to be trailing 24h
  • open - Price of the first trade for the period in quote terms
  • high - Highest traded price in the period in quote terms
  • low - Lowest traded price in the period in quote terms
  • close - Same as last
  • closeQuantity - Quantity of the last period in base terms
  • baseVolume - 24h volume in base terms
  • quoteVolume - 24h volume in quote terms
  • percentChange - % change from open to close
  • numTrades - Number of fills for the market in the period
  • ask - Best ask price on the order book
  • bid - Best bid price on the order book
  • sequence - Last trade sequence number for the market

RestResponseTrade Objects

class RestResponseTrade(TypedDict)

Attributes:

  • fillId - Internal ID of fill
  • price - Executed price of trade in quote terms
  • quantity - Executed quantity of trade in base terms
  • quoteQuantity - Executed quantity of trade in quote terms
  • time - Fill timestamp
  • makerSide - Which side of the order the liquidity maker was on
  • type - orderBook, pool, or hybrid
  • sequence - Last trade sequence number for the market

RestResponseUser Objects

class RestResponseUser(TypedDict)

Attributes:

  • depositEnabled - Deposits are enabled for the user account
  • orderEnabled - Placing orders is enabled for the user account
  • cancelEnabled - Cancelling orders is enabled for the user account
  • withdrawEnabled - Withdrawals are enabled for the user account
  • totalPortfolioValueUsd - Total value of all holdings deposited on the exchange, for all wallets associated with the user account, in USD
  • makerFeeRate - User-specific maker trade fee rate
  • takerFeeRate - User-specific taker trade fee rate
  • takerIdexFeeRate - User-specific liquidity pool taker IDEX fee rate
  • takerLiquidityProviderFeeRate - User-specific liquidity pool taker LP provider fee rate

RestResponseWallet Objects

class RestResponseWallet(TypedDict)

Attributes:

  • address - Ethereum address of the wallet
  • totalPortfolioValueUsd - Total value of all holdings deposited on the exchange for the wallet in USD
  • time - Timestamp of association of the wallet with the user account

RestResponseWithdrawal Objects

class RestResponseWithdrawal(RestResponseWithdrawalBase)

Attributes:

  • withdrawalId - Exchange-assigned withdrawal identifier
  • asset - Symbol of the withdrawn asset, exclusive with assetContractAddress
  • assetContractAddress] - Token contract address of withdrawn asset, exclusive with asset
  • quantity - Quantity of the withdrawal
  • time - Timestamp of withdrawal API request
  • fee - Amount deducted from withdrawal to cover IDEX-paid gas
  • txId - Ethereum transaction ID, if available
  • txStatus - Ethereum transaction status

RestResponseAssociateWallet Objects

class RestResponseAssociateWallet(TypedDict)

Attributes:

  • address - Ethereum address of the wallet
  • totalPortfolioValueUsd - Total value of all holdings deposited on the exchange for the wallet in USD
  • time - Timestamp of association of the wallet with the user account

order_book

order_book.api_conversions

order_book.hybrid

l2_limit_order_book_to_hybrid_order_books

def l2_limit_order_book_to_hybrid_order_books(
        order_book: L2OrderBook,
        idex_fee_rate: int,
        pool_fee_rate: int,
        include_minimum_taker_levels: bool,
        minimum_taker_in_quote: Optional[int],
        tick_size: int,
        visible_levels: int = 10,
        visible_slippage: int = 100) -> L1AndL2OrderBook

Convert a limit-order orderbook and a liquidity pool to a hybrid order book representation

Arguments:

  • order_book - L2 book, e.g. from GET /v1/orderbook?level=2&limitOrderOnly=true
  • visible_levels - number of price levels to calculate, default = 10 asks, 10 bids
  • visible_slippage - price slippage per level, in increments of 0.001%, default = 100 (0.1%)
  • idex_fee_rate - trade fee rate charged by IDEX, expressed in pips
  • pool_fee_rate - pool fee rate chared by liquidity pool, expressed in pips
  • include_minimum_taker_levels - if true, calculate a synthetic price level at twice the minimum trade size
  • minimum_taker_in_quote - minimum trade size expressed in pips, or null if none available
  • tick_size - minimum price movement expressed in pips (10^-8)

order_book.quantities

calculate_gross_base_quantity

def calculate_gross_base_quantity(base_asset_quantity: int,
                                  quote_asset_quantity: int, target_price: int,
                                  idex_fee_rate: int,
                                  pool_fee_rate: int) -> int

Helper function to calculate gross base quantity available at a bid price. See quantities_available_from_pool_at_bid_price.

calculate_gross_base_value_of_buy_quantities

def calculate_gross_base_value_of_buy_quantities(
        base_asset_quantity: int, quote_asset_quantity: int,
        gross_quote_quantity: int) -> int

Helper function to convert from quote to base quantities. See quantities_available_from_pool_at_ask_price.

calculate_gross_quote_quantity

def calculate_gross_quote_quantity(base_asset_quantity: int,
                                   quote_asset_quantity: int,
                                   target_price: int, idex_fee_rate: int,
                                   pool_fee_rate: int) -> int

Helper function to calculate gross quote available at a bid price. See quantities_available_from_pool_at_bid_price.

calculate_gross_quote_value_of_sell_quantities

def calculate_gross_quote_value_of_sell_quantities(
        base_asset_quantity: int, quote_asset_quantity: int,
        gross_base_quantity: int) -> int

Helper function to convert from base to quote quantities. See quantities_available_from_pool_at_bid_price.

calculate_base_quantity_out

def calculate_base_quantity_out(base_asset_quantity: int,
                                quote_asset_quantity: int,
                                gross_quote_quantity_in: int,
                                idex_fee_rate: int, pool_fee_rate: int) -> int

Given a taker order size expressed in quote, how much base is received from the pool. See l1or_l2_best_available_prices.

calculate_quote_quantity_out

def calculate_quote_quantity_out(base_asset_quantity: int,
                                 quote_asset_quantity: int,
                                 gross_base_quantity_in: int,
                                 idex_fee_rate: int,
                                 pool_fee_rate: int) -> int

Given a taker order size expressed in base, how much quote is received from the pool. See l1_or_l2_best_available_prices.

calculate_synthetic_price_levels

def calculate_synthetic_price_levels(
        base_asset_quantity: int,
        quote_asset_quantity: int,
        visible_levels: int,
        visible_slippage: int,
        idex_fee_rate: int = 0,
        pool_fee_rate: int = 0,
        tick_size: int = 1) -> SyntheticL2OrderBook

Generates a synthetic orderbook consisting of price levels for pool liquidity only

Arguments:

  • base_asset_quantity - pool reserve in base asset, must be at least 1.0 expressed in pips (10^-8)
  • quote_asset_quantity - pool reserve in quote asset, must be at least 1.0 expressed in pips (10^-8)
  • visible_levels - how many ask and bid price levels to generate (of each)
  • visible_slippage - how much slippage per price level, in 1/1000th of a percent (100 = 0.1%)
  • idex_fee_rate - the idex fee rate to use for calculations (query /v1/exchange for current global setting)
  • pool_fee_rate - the liquidity pool fee rate to use for calculations (query /v1/exchange for current global setting)
  • tick_size - minimum price movement expressed in pips (10^-8)

Returns:

A level 2 order book with synthetic price levels only

recalculate_hybrid_level_amounts

def recalculate_hybrid_level_amounts(orderbook: L2OrderBook,
                                     idex_fee_rate: int,
                                     pool_fee_rate: int) -> L2OrderBook

Recalculate price level quantities for a book previously sorted with sort_and_merge_levels_unadjusted

Arguments:

  • orderbook - an unadjusted level 2 order book as returned by {sortAndMergeLevelsUnadjusted}
  • idex_fee_rate - idex fee rate to use in pool quantity calculations
  • pool_fee_rate - pool fee rate to use in pool quantity calculations

sort_and_merge_levels_unadjusted

def sort_and_merge_levels_unadjusted(
    limit_order_levels: List[OrderBookLevelL2],
    synthetic_levels: List[OrderBookLevelL2],
    is_before: Callable[[OrderBookLevelL2, OrderBookLevelL2], bool]
) -> List[OrderBookLevelL2]

Combines limit orders and synthetic price levels into an intermediate sorted state IMPORTANT: this function does not update price level quantities after merging

Arguments:

  • limit_order_levels - a level 2 orderbook with only limit orders
  • synthetic_levels - a level 2 orderbook with only synthetic orders
  • is_before - comparison function for sorting price levels

Returns:

Level 2 order book with synthetic price levels only

quantities_available_from_pool_at_ask_price

def quantities_available_from_pool_at_ask_price(
        base_asset_quantity: int, quote_asset_quantity: int, ask_price: int,
        idex_fee_rate: int, pool_fee_rate: int) -> PriceLevelQuantities

Helper function to calculate the asset quantities available at a given price level (pool liquidity only)

Arguments:

  • base_asset_quantity - pool reserve in base asset, must be at least 1.0 expressed in pips (10^-8)
  • quote_asset_quantity - pool reserve in quote asset, must be at least 1.0 expressed in pips (10^-8)
  • ask_price - the ask price level to calculate quantities for
  • idex_fee_rate - the idex fee rate to use for calculations (query /v1/exchange for current global setting)
  • pool_fee_rate - the liquidity pool fee rate to use for calculations (query /v1/exchange for current global setting)

Returns:

Level 2 order book with synthetic price levels only

quantities_available_from_pool_at_bid_price

def quantities_available_from_pool_at_bid_price(
        base_asset_quantity: int, quote_asset_quantity: int, bid_price: int,
        idex_fee_rate: int, pool_fee_rate: int) -> PriceLevelQuantities

Helper function to calculate the asset quantities available at a given price level (pool liquidity only)

Arguments:

  • base_asset_quantity - pool reserve in base asset, must be at least 1.0 expressed in pips (10^-8)
  • quote_asset_quantity - pool reserve in quote asset, must be at least 1.0 expressed in pips (10^-8)
  • bid_price - the bid price level to calculate quantities for
  • idex_fee_rate - the idex fee rate to use for calculations (query /v1/exchange for current global setting)
  • pool_fee_rate - the liquidity pool fee rate to use for calculations (query /v1/exchange for current global setting)

Returns:

Level 2 order book with synthetic price levels only

aggregate_l2_order_book_at_tick_size

def aggregate_l2_order_book_at_tick_size(input_book: L2OrderBook,
                                         tick_size: int) -> L2OrderBook

Helper function to re-aggregate L2 orderbook price levels at a larger (more zeroes) tick size

l1_or_l2_best_available_prices

def l1_or_l2_best_available_prices(pool: PoolReserveQuantities,
                                   idex_fee_rate: int, pool_fee_rate: int,
                                   taker_minimum_in_base: int,
                                   taker_minimum_in_quote: int,
                                   tick_size: int) -> BestAvailablePriceLevels

Given a minimum taker order size, calculate the best achievable price level using pool liquidity only.

Arguments:

  • pool - pool reserve quantities for the orderbook in question
  • idex_fee_rate - the idex fee rate to use for pool calculations
  • pool_fee_rate - the pool fee rate to use for pool calculations
  • taker_minimum_in_base - the minimum taker order size, expressed in base asset units
  • taker_minimum_in_quote - the minimum taker order size, expressed in quote asset units

l1_l2_order_books_with_minimum_taker

def l1_l2_order_books_with_minimum_taker(l2: L2OrderBook, idex_fee_rate: int,
                                         pool_fee_rate: int,
                                         taker_minimum_in_quote: int,
                                         tick_size: int) -> L1AndL2OrderBook

Modifies an existing level 2 order book to include better price levels at the desired taker order size, if available from pool reserves.

Arguments:

  • pool - pool reserve quantities for the orderbook in question
  • idexFeeRate - the idex fee rate to use for pool calculations
  • poolFeeRate - the pool fee rate to use for pool calculations
  • takerMinimumInQuote - the minimum taker order size, expressed in quote asset units

Returns:

The resulting level 1 and level 2 orderbooks

validate_synthetic_price_level_inputs

def validate_synthetic_price_level_inputs(base_asset_quantity: int,
                                          quote_asset_quantity: int,
                                          target_price: int,
                                          is_buy: bool) -> None

Validates assumptions for reserve quantities and pricing required for quantity calculations

Arguments:

  • base_asset_quantity - pool reserve in base asset, must be at least 1.0 expressed in pips (10^-8)
  • quote_asset_quantity - pool reserve in quote asset, must be at least 1.0 expressed in pips (10^-8)
  • target_price - price expressed in pips, must be 0 < price < 2^64-1 and on the correct side of the spread
  • is_buy - if true, the price is targeting buy orders (bids), otherwise sell orders (asks)

Returns:

None, validation always succeeds or raises an exception

adjust_price_to_tick_size

def adjust_price_to_tick_size(
        price: int,
        tick_size: int,
        rounding_mode: RoundingMode = DEFAULT_ROUNDING_MODE) -> int

Adjusts prices in pips to account for tick size by discarding insignificant digits using specified rounding mode. Ex price 123456789 at tick size 1 is 123456789, at tick size 10 123456780, at 100 123456700, etc

order_book.utils

l2_to_l1_order_book

def l2_to_l1_order_book(l2: L2OrderBook) -> L1OrderBook

Derive the level 1 orderbook from a level 2 orderbook

client

client.websocket.client

WebSocketClient Objects

class WebSocketClient()

WebSocket API client

When apiKey and apiSecret are provided, the client will automatically handle WebSocket authentication token generation and refresh. Omit when using only public WebSocket subscriptions.

__init__

def __init__(api_key: Optional[str] = None,
             api_secret: Optional[str] = None,
             should_reconnect_automatically: bool = False,
             connect_timeout: Optional[int] = None,
             sandbox: bool = False,
             multiverse_chain: MultiverseChain = MultiverseChain.MATIC,
             base_url: Optional[str] = None,
             websocket_auth_token_fetch: Optional[Callable[[str],
                                                           str]] = None)

Arguments:

  • api_key - Used to authenticate user when automatically refreshing WS token
  • api_secret - Used to compute HMAC signature when automatically refreshing WS token receiving push updates. Eg. {market}@{subscription}_{option}
  • should_reconnect_automatically - If true, automatically reconnects when connection is closed by the server or network errors
  • connect_timeout - Timeout (in milliseconds) before failing when trying to connect to the WebSocket. Defaults to 5000.
  • sandbox - If true, client will point to API sandbox
  • multiverse_chain - Which multiverse chain the client will point to

connect

async def connect() -> None

Establish a WebSocket connection to the API and start listening for messages

subscribe_authenticated

async def subscribe_authenticated(subscriptions: Sequence[
    AuthTokenWebSocketRequestAuthenticatedSubscription],
                                  markets: List[str] = None,
                                  cid: str = None) -> None

Strictly typed subscribe which only can be used on authenticated subscriptions.

See https://api-docs-v3.idex.io/`websocket`-subscriptions

Arguments:

subscriptions

  • markets - Optionally provide top level markets
  • cid - Optional custom identifier to identify the matching response

subscribe_unauthenticated

async def subscribe_unauthenticated(
        subscriptions: Sequence[WebSocketRequestUnauthenticatedSubscription],
        markets: List[str] = None,
        cid: str = None) -> None

Strictly typed subscribe which only can be used on non-authenticated subscriptions.

See https://api-docs-v3.idex.io/`websocket`-subscriptions

Arguments:

subscriptions

  • markets - Optionally provide top level markets
  • cid - Optional custom identifier to identify the matching response

subscribe

async def subscribe(subscriptions: Sequence[
    Union[WebSocketRequestSubscription,
          WebSocketRequestUnauthenticatedSubscriptionNameOnly, ]],
                    markets: List[str] = None,
                    cid: str = None) -> None

Subscribe to a given set of subscriptions, optionally providing a list of top level markets or a cid property.

See https://api-docs-v3.idex.io/`websocket`-subscriptions

Arguments:

subscriptions

  • markets - Optionally provide top level markets
  • cid - Optional custom identifier to identify the matching response

reconnect

async def reconnect() -> None

Reconnect with exponential backoff

client.websocket

client.websocket.utils

client.websocket.transform

client.utils

client.order_book

client.order_book.real_time

OrderBookRealTimeClient Objects

class OrderBookRealTimeClient(AsyncIOEventEmitter)

start

async def start(markets: List[str]) -> None

Loads initial state from REST API and begin listening to orderbook updates.

stop

async def stop() -> None

Stop the order book client, and reset internal state. Call this when you are no longer using the client, to release memory and network resources.

set_fees_and_minimums_override

def set_fees_and_minimums_override(override: OrderBookFeesAndMinimums) -> None

Set custom fee rates for synthetic price level calculations. Use this if your wallet has custom fees set.

get_order_book_l1

def get_order_book_l1(market: str,
                      tick_size: Optional[int] = None
                      ) -> RestResponseOrderBook

Load the current state of the level 1 orderbook for this market.

Arguments:

market

  • tick_size - minimum price movement expressed in pips (10^-8), defaults to market setting

get_order_book_l2

def get_order_book_l2(
        market: str,
        limit: int = 100,
        tick_size: Optional[int] = None) -> RestResponseOrderBook

Load the current state of the level 2 orderbook for this market.

Arguments:

market

  • limit - Total number of price levels (bids + asks) to return, between 2 and 1000
  • tickSize - minimum price movement expressed in pips (10^-8)

client.order_book.utils

l1_equal

def l1_equal(before_l1: L1OrderBook, after_l1: L1OrderBook) -> bool

Determine whether two level 1 order books are equal, including pool reserves

update_l2_side

def update_l2_side(is_ascending: bool, side: List[OrderBookLevelL2],
                   updates: List[OrderBookLevelL2]) -> List[OrderBookLevelL2]

Applies a changeset to a single side of the orderbook

Params: is_ascending: true for asks, false for bids (ordering of price levels) side updates

Returns:

Updated order book side

update_l2_levels

def update_l2_levels(book: L2OrderBook, updated_levels: L2OrderBook) -> None

Updates a level 2 orderbook using a partial "diff" received over websockets

Arguments:

  • book - level 2 orderbook to update
  • updated_levels - level 2 orderbook containing only limit order price levels that have changed

client.rest.public

RestPublicClient Objects

class RestPublicClient()

ping

def ping() -> Dict

Test connectivity to the REST API See https://api-docs-v3.idex.io/`get`-ping

get_server_time

def get_server_time() -> int

Returns the current server time See https://api-docs-v3.idex.io/`get`-time

get_exchange_info

def get_exchange_info() -> RestResponseExchangeInfo

Returns basic information about the exchange See https://api-docs-v3.idex.io/`get`-exchange

get_assets

def get_assets() -> List[RestResponseAsset]

Returns information about assets supported by the exchange See https://api-docs-v3.idex.io/`get`-assets

get_markets

def get_markets(
    find_markets: Optional[RestRequestFindMarkets] = None
) -> List[RestResponseMarket]

Returns information about the currently listed markets See https://api-docs-v3.idex.io/`get`-markets

get_liquidity_pools

def get_liquidity_pools(
    find_liquidity_pools: Optional[RestRequestFindLiquidityPools] = None
) -> List[RestResponseLiquidityPool]

Returns information about liquidity pools supported by the exchange See https://api-docs-v3.idex.io/`get`-liquidity-pools

get_tickers

def get_tickers(market: Optional[str] = None) -> List[RestResponseTicker]

Returns market statistics for the trailing 24-hour period

get_candles

def get_candles(
        find_candles: RestRequestFindCandles) -> List[RestResponseCandle]

Returns candle (OHLCV) data for a market See https://api-docs-v3.idex.io/`get`-candles

get_trades

def get_trades(find_trades: RestRequestFindTrades) -> List[RestResponseTrade]

Returns public trade data for a market See https://api-docs-v3.idex.io/`get`-trades

get_order_book_level1

def get_order_book_level1(
        market: str,
        limit_order_only: bool = False) -> List[RestResponseOrderBook]

Get current top bid/ask price levels of order book for a market See https://api-docs-v3.idex.io/`get`-order-books

get_order_book_level2

def get_order_book_level2(
        market: str,
        limit: int = 50,
        limit_order_only: bool = False) -> RestResponseOrderBook

Get current order book price levels for a market See https://api-docs-v3.idex.io/`get`-order-books

client.rest

client.rest.authenticated

RestAuthenticatedClient Objects

class RestAuthenticatedClient()

add_liquidity

def add_liquidity(
    req: request.RestRequestAddLiquidity,
    signer: Optional[sig.MessageSigner] = None,
    dependent_transactions: Optional[List[str]] = None
) -> response.RestResponseLiquidityAddition

Add liquidity to a hybrid liquidity pool from assets held by a wallet on the exchange

remove_liquidity

def remove_liquidity(
    req: request.RestRequestRemoveLiquidity,
    signer: Optional[sig.MessageSigner] = None,
    dependent_transactions: Optional[List[str]] = None
) -> response.RestResponseLiquidityRemoval

Remove liquidity from a hybrid liquidity pool represented by LP tokens held by a wallet on the exchange

get_liquidity_addition

def get_liquidity_addition(
    req: request.RestRequestFindLiquidityAddition
) -> Union[response.RestResponseLiquidityAddition,
           List[response.RestResponseLiquidityAddition]]

Returns information about a single liquidity addition from a wallet

get_liquidity_additions

def get_liquidity_additions(
    req: request.RestRequestFindLiquidityChanges
) -> List[response.RestResponseLiquidityAddition]

Returns information about multiple liquidity additions from a wallet

get_liquidity_removal

def get_liquidity_removal(
    req: request.RestRequestFindLiquidityRemoval
) -> response.RestResponseLiquidityRemoval

Returns information about a single liquidity removal from a wallet

get_liquidity_removals

def get_liquidity_removals(
    req: request.RestRequestFindLiquidityChanges
) -> List[response.RestResponseLiquidityRemoval]

Returns information about multiple liquidity removals from a wallet

get_user

def get_user(nonce: str) -> response.RestResponseUser

Get account details for the API key's user See https://api-docs-v3.idex.io/`get`-user-account

Arguments:

  • nonce - UUIDv1

Returns:

Information about the user

get_wallets

def get_wallets(nonce: str) -> List[response.RestResponseWallet]

Get account details for the API key's user See https://api-docs-v3.idex.io/`get`-wallets

Arguments:

  • nonce - UUIDv1

Returns:

The user's wallets

get_balances

def get_balances(
    req: request.RestRequestFindBalances
) -> List[response.RestResponseBalance]

Get asset quantity data (positions) held by a wallet on the exchange

associate_wallet

def associate_wallet(
    req: request.RestRequestAssociateWallet,
    signer: Optional[sig.MessageSigner] = None
) -> response.RestResponseAssociateWallet

Associate a wallet with the authenticated account See https://api-docs-v3.idex.io/`associate`-wallet

create_order

def create_order(
        req: request.RestRequestOrder,
        signer: Optional[sig.MessageSigner] = None
) -> response.RestResponseOrder

Create and submit an order to the matching engine See https://api-docs-v3.idex.io/`create`-order

create_test_order

def create_test_order(
        req: request.RestRequestOrder,
        signer: Optional[sig.MessageSigner] = None
) -> response.RestResponseOrder

Tests order creation and validation without submitting an order to the matching engine See https://api-docs-v3.idex.io/`test`-create-order

cancel_order

def cancel_order(
    req: request.RestRequestCancelOrder,
    signer: Optional[sig.MessageSigner] = None
) -> List[response.RestResponseCanceledOrder]

Cancel a single order See https://api-docs-v3.idex.io/`cancel`-order

cancel_orders

def cancel_orders(
    req: request.RestRequestCancelOrder,
    signer: Optional[sig.MessageSigner] = None
) -> List[response.RestResponseCanceledOrder]

Cancel multiple orders See https://api-docs-v3.idex.io/`cancel`-order

get_order

def get_order(req: request.RestRequestFindOrder) -> response.RestResponseOrder

Get an order See https://api-docs-v3.idex.io/`get`-orders

get_orders

def get_orders(
        req: request.RestRequestFindOrders
) -> List[response.RestResponseOrder]

Get multiple orders See https://api-docs-v3.idex.io/`get`-orders

get_fill

def get_fill(req: request.RestRequestFindFill) -> response.RestResponseFill

Get a fill See https://api-docs-v3.idex.io/`get`-fills

get_fills

def get_fills(
        req: request.RestRequestFindFills) -> List[response.RestResponseFill]

Get multiple fills See https://api-docs-v3.idex.io/`get`-fills

get_deposit

def get_deposit(
        req: request.RestRequestFindDeposit) -> response.RestResponseDeposit

Get a fill See https://api-docs-v3.idex.io/`get`-deposits

get_deposits

def get_deposits(
    req: request.RestRequestFindDeposits
) -> List[response.RestResponseDeposit]

Get a fill See https://api-docs-v3.idex.io/`get`-deposits

withdraw

def withdraw(
    req: request.RestRequestWithdrawal,
    signer: Optional[sig.MessageSigner] = None
) -> response.RestResponseWithdrawal

Create a new withdrawal See https://api-docs-v3.idex.io/[`withdraw`](#client.rest.authenticated.RestAuthenticatedClient.withdraw)-funds

get_withdrawal

def get_withdrawal(
        req: request.RestRequestFindWithdrawal
) -> response.RestResponseWithdrawal

Get a withdrawal See https://api-docs-v3.idex.io/`get`-withdrawals

get_withdrawals

def get_withdrawals(
    req: request.RestRequestFindWithdrawals
) -> List[response.RestResponseWithdrawal]

Get multiple withdrawals See https://api-docs-v3.idex.io/`get`-withdrawals

get_ws_token

def get_ws_token(nonce: str, wallet: str) -> str

Get multiple withdrawals See https://api-docs-v3.idex.io/`get`-withdrawals