How IBrokers Routes Market Data Through Interactive Brokers TWS
Summary
This document explains how the IBrokers R package connects a strategy to Interactive Brokers through Trader Workstation (TWS). It outlines functions for requesting contract details, live quotes, market depth, real-time bars, and historical data, along with helper functions for creating contracts across asset types. TWS acts as the intermediary between the R package and Interactive Brokers’ data centers.
The article focuses on how incoming messages are handled: a callback receives messages, passes them to processMsg, and delegates message-specific work to functions in an eWrapper closure. Users can customize callbacks and wrapper methods to process or store streaming data, including routing error messages separately. A simple example uses a bid-price threshold to generate a buy signal. The document describes software structure and an illustrative rule, but gives no performance evidence, execution safeguards, or guidance on validating a live strategy. It also cautions that the package is provided without warranty and should not be used for actual trading unless the user understands its source.
Key ideas
- IBrokers sends R requests to Interactive Brokers through Trader Workstation, which relays communication to the broker’s data centers.
- The package provides separate functions for contract details, quotes, order book data, real-time bars, and historical data.
- Incoming messages pass through a callback and message processor before the relevant eWrapper handler manages them.
- Custom callbacks and eWrapper methods let users process streaming data and handle errors in ways suited to their strategy.
- The article’s threshold-based buy signal is an implementation example, not evidence of profitability or safe live execution.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.