Level: Intermediate

Interactive Brokers offers the ability to trade, monitor and manage your IBKR account using a single RESTful API.

When authenticating your login session this allows you equivalent access as a read-only user. You can query positions, account details, security definition and portfolio analyst data. Once authenticated, you can then connect to the brokerage session which provides access to market data, scanners and placing orders.

WebSocket is a bidirectional, fully-duplex protocol that is used in the same scenario as client-server communication. It is a stateful protocol, which means the connection between the client and server will keep alive until it is terminated by either the client or server.

Interactive Brokers offers several algorithmic order types that are designed to include user-defined settings to your trades. The endpoint /iserver/contract/{conid}/algos can be used to identify the available strategies for a given contract.

For derivative contracts such as Futures and Options you would initially use the endpoint /iserver/secdef/search to query the underlying. This will relay back a ‘sections’ which lists all derivative contract(s) it has.

To help limit loss and lock in a profit you can bracket an order with additional opposite-side orders. A BUY order is bracketed by a high-side sell limit and a low-side sell stop order. A SELL order is bracketed by a high-side buy stop order and a low side buy limit order.

One-Cancels All (OCA) order type allows an investor to place multiple and possibly unrelated orders assigned to a group. It’s designed to allow investors to submit several orders aimed at taking advantage of the most desirable price within the group. Completion of one piece of the group causes cancellation of the remaining group orders while partial completion causes the group to rebalance.

The market scanner allows you to quickly scan relevant markets and return the top contracts based on a defined set of instrument, parameter, location, and filtering criteria. The endpoint /iserver/scanner/params can be used to determine the available values.

A Currency Conversion Order lets you convert cash from one currency to another. You would send a buy market order and either specify the amount of currency you want to convert from or the amount of currency you want to convert to.

Trading fractional shares (also known as a Cash Quantity Order) allows you to invest in companies which you may not be able to afford the full share price.