CCXT
interactivebrokers

interactivebrokers

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

🔌 Looking for raw exchange endpoints? See the interactivebrokers implicit API — every endpoint in this exchange's API exposed as an implicit method.

interactivebrokers

Kind: global class
Extends: Exchange

signIn

obtains a live session token via the oauth 1.0a diffie-hellman exchange and opens the brokerage session, must be called prior to using other authenticated methods (called automatically by authenticate)

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

See

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
interactivebrokers.signIn (params?)

fetchBalance

query for balance and get the amount of funds available for trading or funds locked in orders, the cash comes from the ledger, the crypto holdings from the positions and the locked ('used') amounts from the open orders of the current brokerage session

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

See

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIdstringNothe account id, defaults to options["accountId"] or the selected account
params.positionsbooleanNoadd the holdings of options.fetchBalance.positionAssetClasses (crypto by default) as balances, default true
params.openOrdersbooleanNocompute the locked ('used') amounts from the open orders, default true
interactivebrokers.fetchBalance (params?)

fetchMarkets

retrieves data on the market types of options.fetchMarkets.types: stocks of options.fetchMarkets.exchanges.STK, crypto of options.fetchMarkets.cryptoSpotSymbols, fx pairs of options.fetchMarkets.forexCurrencies, coinbase derivatives perp-style futures discovered with the market scanner (as swap, e.g. BTC/USD:USD), dated coinbase derivatives futures (scanned) and CME and CFE crypto futures of options.fetchMarkets.cryptoCmeFutureSymbols (as future, e.g. BTC/USD:USD-261127) and cfds of options.fetchMarkets.cfdExchanges (as swap, e.g. AAPL/USD:USD), bonds of options.fetchMarkets.bondSymbols are loaded only with 'bond' in options.fetchMarkets.types (as spot, e.g. US-T-4.125-270131.SMART/USD), the market id is the IBKR conid

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

See

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

fetchTickers

fetches price tickers for multiple markets, the first snapshot request only subscribes to the market data, so the request is retried until data arrives

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-snapshot

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch the ticker for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.fieldsstringNocomma-separated snapshot field ids, max 50
interactivebrokers.fetchTickers (symbols, params?)

fetchBidsAsks

fetches the bid and ask price and volume for multiple markets

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-snapshot

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch the bids and asks for
paramsobjectNoextra parameters specific to the exchange API endpoint
params.fieldsstringNocomma-separated snapshot field ids, default '84,85,86,88'
interactivebrokers.fetchBidsAsks (symbols, params?)

fetchLastPrices

fetches the last price for multiple markets

Kind: instance method of interactivebrokers
Returns: object - a dictionary of last price structures

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-snapshot

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch the last prices for
paramsobjectNoextra parameters specific to the exchange API endpoint
interactivebrokers.fetchLastPrices (symbols, params?)

fetchMarkPrices

fetches the mark price for multiple markets

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-snapshot

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch the mark prices for
paramsobjectNoextra parameters specific to the exchange API endpoint
interactivebrokers.fetchMarkPrices (symbols, params?)

fetchOpenInterests

retrieves the open interest of multiple futures or swap markets

Kind: instance method of interactivebrokers
Returns: object - a dictionary of open interest structures

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-snapshot

ParamTypeRequiredDescription
symbolsArray<string>Yesunified symbols of the markets to fetch the open interest for
paramsobjectNoextra parameters specific to the exchange API endpoint
interactivebrokers.fetchOpenInterests (symbols, params?)

fetchStatus

the status of the brokerage session, 'ok' when authenticated and connected

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-session/get-brokerage-status

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

fetchOHLCV

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

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-market-data/get-md-history

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, max 1000
paramsobjectNoextra parameters specific to the exchange API endpoint
params.outsideRthbooleanNoinclude data outside regular trading hours
params.sourcestringNo'Last', 'Bid_Ask' or 'Midpoint'
interactivebrokers.fetchOHLCV (symbol, timeframe, since?, limit?, params?)

fetchAccounts

fetch all the accounts associated with a profile

Kind: instance method of interactivebrokers
Returns: Array<object> - a list of account structures

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-all-accounts

ParamTypeRequiredDescription
paramsobjectNoextra parameters specific to the exchange API endpoint
params.methodstringNo'privateGetPortfolioAccounts' (default) or 'privateGetPortfolioSubaccounts'
interactivebrokers.fetchAccounts (params?)

createOrder

create a trade order, order reply prompts are confirmed automatically when options.createOrder.autoConfirmOrderReplies is true

Kind: instance method of interactivebrokers
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.triggerPricefloatNothe stop price, creates a STP (market) or STP LMT (limit) order
params.trailingAmountfloatNothe trailing offset in quote currency, creates a TRAIL or TRAILLMT order
params.trailingPercentfloatNothe trailing offset in percent, creates a TRAIL or TRAILLMT order
params.timeInForcestringNo'DAY', 'IOC', 'GTC', 'OPG' or 'PAX'
params.clientOrderIdstringNoa unique id for the order, sent as cOID
params.outsideRTHbooleanNoallow the order to execute outside regular trading hours
params.accountIdstringNothe account id, defaults to options["accountId"]
interactivebrokers.createOrder (symbol, type, side, amount, price?, params?)

editOrder

edit a trade order

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/modify-open-order

ParamTypeRequiredDescription
idstringYesorder id
symbolstringYesunified symbol of the market to create an order in
typestringYes'market' or 'limit'
sidestringYes'buy' or 'sell'
amountfloatNohow 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, see createOrder
interactivebrokers.editOrder (id, symbol, type, side, amount?, price?, params?)

cancelOrder

cancels an open order

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/cancel-open-order

ParamTypeRequiredDescription
idstringYesorder id
symbolstringNounified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIdstringNothe account id, defaults to options["accountId"]
interactivebrokers.cancelOrder (id, symbol?, params?)

fetchOrder

fetches information on an order made by the user, only orders of the current brokerage session are available

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-order-status

ParamTypeRequiredDescription
idstringYesthe order id
symbolstringNounified symbol of the market the order was made in
paramsobjectNoextra parameters specific to the exchange API endpoint
interactivebrokers.fetchOrder (id, symbol?, params?)

fetchOrders

fetches information on multiple orders of the current brokerage session

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders

ParamTypeRequiredDescription
symbolstringNounified 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.filtersstringNoa single exchange-side status filter, e.g. 'filled'
params.forcebooleanNorefresh the cached order list first, default true
interactivebrokers.fetchOrders (symbol?, since?, limit?, params?)

fetchOpenOrders

fetch all unfilled currently open orders of the current brokerage session

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders

ParamTypeRequiredDescription
symbolstringNounified market symbol
sinceintNothe earliest time in ms to fetch open orders for
limitintNothe maximum number of open order structures to retrieve
paramsobjectNoextra parameters specific to the exchange API endpoint
params.filtersstringNoan exchange-side status filter, by default all orders are fetched and filtered by their unified status
params.forcebooleanNorefresh the cached order list first, default true
interactivebrokers.fetchOpenOrders (symbol?, since?, limit?, params?)

fetchClosedOrders

fetches information on multiple filled orders of the current brokerage session

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders

ParamTypeRequiredDescription
symbolstringNounified market symbol
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.filtersstringNoan exchange-side status filter, by default all orders are fetched and filtered by their unified status
params.forcebooleanNorefresh the cached order list first, default true
interactivebrokers.fetchClosedOrders (symbol?, since?, limit?, params?)

fetchCanceledOrders

fetches information on multiple canceled orders of the current brokerage session

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders

ParamTypeRequiredDescription
symbolstringNounified market symbol
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.filtersstringNoan exchange-side status filter, by default all orders are fetched and filtered by their unified status
params.forcebooleanNorefresh the cached order list first, default true
interactivebrokers.fetchCanceledOrders (symbol?, since?, limit?, params?)

fetchCanceledAndClosedOrders

fetches information on multiple filled and canceled orders of the current brokerage session

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders

ParamTypeRequiredDescription
symbolstringNounified market symbol
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.filtersstringNoan exchange-side status filter, by default all orders are fetched and filtered by their unified status
params.forcebooleanNorefresh the cached order list first, default true
interactivebrokers.fetchCanceledAndClosedOrders (symbol?, since?, limit?, params?)

fetchMyTrades

fetch all trades made by the user, over the last days (max 7) via iserver/account/trades, or for crypto markets (which iserver/account/trades does not return) via pa/transactions

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

See

ParamTypeRequiredDescription
symbolstringNounified market symbol, required for crypto markets
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.daysintNonumber of days to fetch, max 7 for iserver/account/trades, default 90 for pa/transactions
params.methodstringNo'privateGetIserverAccountTrades' or 'privatePostPaTransactions', default is 'privatePostPaTransactions' for crypto markets and 'privateGetIserverAccountTrades' otherwise
params.currencystringNopa/transactions only, the currency to display the amounts in, default 'USD'
params.accountIdstringNopa/transactions only, the account id, defaults to options["accountId"]
interactivebrokers.fetchMyTrades (symbol?, since?, limit?, params?)

fetchPositions

fetch all open positions

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-uncached-positions

ParamTypeRequiredDescription
symbolsArray<string>Nolist of unified market symbols
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIdstringNothe account id, defaults to options["accountId"]
interactivebrokers.fetchPositions (symbols?, params?)

fetchPositionsForSymbol

fetch the open positions of a single market

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

See: https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-position-by-conid

ParamTypeRequiredDescription
symbolstringYesunified market symbol
paramsobjectNoextra parameters specific to the exchange API endpoint
params.accountIdstringNothe account id, defaults to options["accountId"]
interactivebrokers.fetchPositionsForSymbol (symbol, params?)

On this page