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
- fetchBalance
- fetchMarkets
- fetchTickers
- fetchBidsAsks
- fetchLastPrices
- fetchMarkPrices
- fetchOpenInterests
- fetchStatus
- fetchOHLCV
- fetchAccounts
- createOrder
- editOrder
- cancelOrder
- fetchOrder
- fetchOrders
- fetchOpenOrders
- fetchClosedOrders
- fetchCanceledOrders
- fetchCanceledAndClosedOrders
- fetchMyTrades
- fetchPositions
- fetchPositionsForSymbol
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
- https://www.interactivebrokers.com/docs/web-api/api-reference/authentication/oauth-1-0-a/req-live-session-token
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-session/initialize-session
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-portfolio-ledger
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio/get-uncached-positions
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-open-orders
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.accountId | string | No | the account id, defaults to options["accountId"] or the selected account |
| params.positions | boolean | No | add the holdings of options.fetchBalance.positionAssetClasses (crypto by default) as balances, default true |
| params.openOrders | boolean | No | compute 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
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-conids-by-exchange
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-bond-filters
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-info-and-rules
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-future-by-symbol
- https://www.interactivebrokers.com/campus/ibkr-api-page/cpapi-v1/#scanner-run
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-contract-symbols-from-body
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-currency-pairs
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-contracts/get-instrument-definition
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | Yes | unified symbols of the markets to fetch the ticker for |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.fields | string | No | comma-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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | Yes | unified symbols of the markets to fetch the bids and asks for |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.fields | string | No | comma-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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | Yes | unified symbols of the markets to fetch the last prices for |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | Yes | unified symbols of the markets to fetch the mark prices for |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | Yes | unified symbols of the markets to fetch the open interest for |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra 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
| 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, max 1000 |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.outsideRth | boolean | No | include data outside regular trading hours |
| params.source | string | No | '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
| Param | Type | Required | Description |
|---|---|---|---|
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.method | string | No | '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
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/submit-new-order
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/confirm-order-reply
| 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 stop price, creates a STP (market) or STP LMT (limit) order |
| params.trailingAmount | float | No | the trailing offset in quote currency, creates a TRAIL or TRAILLMT order |
| params.trailingPercent | float | No | the trailing offset in percent, creates a TRAIL or TRAILLMT order |
| params.timeInForce | string | No | 'DAY', 'IOC', 'GTC', 'OPG' or 'PAX' |
| params.clientOrderId | string | No | a unique id for the order, sent as cOID |
| params.outsideRTH | boolean | No | allow the order to execute outside regular trading hours |
| params.accountId | string | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | order id |
| 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 | No | how much of the currency you want to trade in units of the 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, 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | order id |
| symbol | string | No | unified symbol of the market the order was made in |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.accountId | string | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | the order id |
| symbol | string | No | unified symbol of the market the order was made in |
| params | object | No | extra 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | unified market symbol of the market 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 |
| params.filters | string | No | a single exchange-side status filter, e.g. 'filled' |
| params.force | boolean | No | refresh 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | 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.filters | string | No | an exchange-side status filter, by default all orders are fetched and filtered by their unified status |
| params.force | boolean | No | refresh 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | unified market symbol |
| 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 |
| params.filters | string | No | an exchange-side status filter, by default all orders are fetched and filtered by their unified status |
| params.force | boolean | No | refresh 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | unified market symbol |
| 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 |
| params.filters | string | No | an exchange-side status filter, by default all orders are fetched and filtered by their unified status |
| params.force | boolean | No | refresh 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | unified market symbol |
| 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 |
| params.filters | string | No | an exchange-side status filter, by default all orders are fetched and filtered by their unified status |
| params.force | boolean | No | refresh 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
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-orders/get-trade-history
- https://www.interactivebrokers.com/docs/web-api/api-reference/trading/trading-portfolio-analyst/get-transactions
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | No | unified market symbol, required for crypto markets |
| since | int | No | the earliest time in ms to fetch trades for |
| limit | int | No | the maximum number of trades structures to retrieve |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.days | int | No | number of days to fetch, max 7 for iserver/account/trades, default 90 for pa/transactions |
| params.method | string | No | 'privateGetIserverAccountTrades' or 'privatePostPaTransactions', default is 'privatePostPaTransactions' for crypto markets and 'privateGetIserverAccountTrades' otherwise |
| params.currency | string | No | pa/transactions only, the currency to display the amounts in, default 'USD' |
| params.accountId | string | No | pa/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
| Param | Type | Required | Description |
|---|---|---|---|
| symbols | Array<string> | No | list of unified market symbols |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.accountId | string | No | the 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
| Param | Type | Required | Description |
|---|---|---|---|
| symbol | string | Yes | unified market symbol |
| params | object | No | extra parameters specific to the exchange API endpoint |
| params.accountId | string | No | the account id, defaults to options["accountId"] |
interactivebrokers.fetchPositionsForSymbol (symbol, params?)