Interactive Brokers live trading and data interface
- Connect to IB TWS or the IB Gateway
- Automated strategy trading
- Order types: Market, Limit, Stop, StopLimit, Market On Close, and Limit On Close
- Historical and Streaming data using your IB Data Subscriptions for quotes, charts, and Strategy Monitor
- TWS Application Offline version recommended
- OR IB Gateway
- Your IB account must have Market Data Permissions for the data you request from WealthLab
One-Time Setup Instructions
It's required that you are logged in and running IB TWS or the IB Gateway to connect with IB. To make the connection you must perform this one-time setup:
Step 1 - Configure IB TWS
Enable the following settings in the TWS Configuration > API > Settings:
- Enable ActiveX and Socket Clients - checked
- Socket Port - default is 7496. You only need to change this number for additional instances of TWS. WealthLab will connect to only one instance at a time.
- Use Account Groups with Allocation Methods - unchecked (if you have multiple linked accounts).
- Allow conections from localhost only - to connect to TWS running on a different virtual machine or network uncheck this and enter the Trusted IP. For example, if you're using the Mac version of TWS, open your Mac's Network app and enter the IP for the wireless/cabled connection here, e.g., 192.168.1.10.
Optional setting in TWS Configuration > API > Precautions
- Bypass Order Precautions for API Orders - check this option if you don't want orders from WealthLab to be delayed or canceled due to exceeding a size limit or another precaution.
Step 2 - Configure Interactive Brokers in WealthLab
Configure the WealthLab connection settings for IB in the Data Manager > Historical (or Streaming) Provider tab or use the Order Manager > Interactive Brokers > Configure. Specify the following:
- Host IP Address - default: 127.0.0.1. Alternatively, enter the IP address you configured in TWS if not the localhost.
- Port - default: 7496. Use the Socket Port configured in TWS.
- Client ID - default: 1. No need to change this unless you have multiple data clients that are connecting to the same instance of TWS. Enter 0 (zero) if you wish to retrieve manual orders from TWS upon connection.
- Delayed Data - check this only if you're evaluating TWS with delayed data.
- Auto Launch IB TWS - check to allow WealthLab to automatically launch IB TWS when 1) IB TWS or Gateway is not detected to be running locally and IB connection is required for data or trading.
- Option Chart WhatToRequest - Trades provides a chart based on option trading, whereas MidPoint provides a chart of the Bid/Ask MidPoint throughout the day. Because option trading most often is illiquid, when developing strategies that do not rely on contract trade volume, MidPoint is recommended. It's not currently possible to see both Trades and MidPoint, so you must decide which data you wish to retain.
The third party data is subject to the availability of the respective provider (website) and may be delayed or inaccessible periodically due to network or technical reasons. As the data is not guaranteed to be accurate, it is your responsibility to confirm that it does not contain errors before utilizing it for any type of backtesting or trading activities. Quantacula LLC is not to be held liable for any errors in market data or its inavailability.
- Update for exchange consolidation changes at IB.
- Fix exception if a bad symbol is passed to IB's GetSymbolDecimals method.
- CBOT exchange consolidation. Any contract records that previously pointed to ECBOT should automatically direct to CBOT.
- Fix the number of decimals used for limit and stop orders (by instrument.)
- Fix: Streaming bars were initializing a bar's open to previous close if no trades occurred in the first 5 seconds of the new interval.
- IBContracts.txt, IBFutures.txt, and IBFuturesMargin.txt updates for exchange consolidations.
- Minor code updates for the exchange consolidation
- Important! To get the updated files, close WealthLab and delete these existing 3 files from your WealthLab User Data folder.
- Fix - System.InvalidOperationException during streaming (occurred rarely)
- Fix - in some cases requesting intraday data for 24-hours markets could have left gaps. This fix will avoid the problem in the future, but you should check histories for gaps and refresh if required.
- Implemented throttling for historic requests (5 max in 2 seconds) to help avoid an IB pacing violation. Collecting large amounts of intraday history is still likely to result in server pacing of 1 request every 6 seconds.
- Fixed a crosstalk issue when reporting batch updates.
- Adapt to futures exchange consolidation - Waves 1, 2, and 3.
- Now uses IB API 10.19 and adapts to requirement to specify the time zone for historic requests.
- Fixes possible gaps in intraday data for 24 hour markets.
- Upgrade Compatibility Required! - Install TWS 10.17 (or later) for compatibility with IB Build 17.
- Fix - the scenario responsible for "duplicate orderID" is solved. Thanks to kls06541 for helping to isolate the issue.
- Change - reduced the batch window for intraday requests for 24-hour markets to minimize data request timeouts.
- New! - Preference to configure the delay for Final Orders. A new feature delays signals on the last bar of the day intended for the next session to avoid immediate order cancellation.
- New! - IBBroker.Instance.GetOptionsSymbol() method supports both stock and futures options. Thanks to wesdutoit for his Concierge Service request that implemented futures options.
- Possible fix and more logging for very intermittent "Duplicate OrderID".
- Manage individual AccountUpdatesMulti subscriptions
- Messaging to troubleshoot duplicate OrderId
- Revert to reqPositions to subscribe to position updates for all accessible accounts
- Show Cash Balances in multiple currencies
- Added a few Log Viewer messages to aid troubleshoot linked accounts
- Fixed base symbol for AUD currency futures in IBFutures.txt
- Fixed contract symbol returned to the Broker Account for Euro futures and contracts whose last trade date is before the front month. (e.g., CL contracts)
- Fixed Accounts tool's Basis Price value for futures
- New! n-Second interval support for 10, 15, and 30-Second bars (only). "Faster" intervals return too many bars for our 1-day increment requests.
- Change! If trading futures using 1-digit year symbols (e.g., ESU2), you must now map these to the 2-digit year symbol for IB in the Order Manager mapping, e.g., ESU2=ESU22. This is required to synchronize Position exits because Order Manager will now always return the 2-digit year symbol format.
- Avoid missing order status updates for new orders after a reconnect if IB doesn't send the openOrderEnd callback.
- Avoid unnecessary requests for expired contracts less than 2 years expired.
- Fix symbol used in request cache for futures and options.
- Skip historical requests for expired option contracts and futures more than 2 years expired.
- Automatic lookup for EUREX Market. If you trade instruments on EUREX, you may need to create a Market named "EUREX".
- StopLimit Order Type support added (Build 13 required).
- Adapt change from DTB to EUREX exchange for some Euro futures.
- Data Providers are now more careful about checking Offline Mode before making web requests (requires WL8 Build 10+).
- Updated API to 10.16. No notable API changes, only internal compatibility.
- Fix: Stop orders for Futures were not triggering outside of regular market hours. "Outside RTH" will always be set true for FUT and CASH stop orders.
- Fix: SymbolInfo for CASH contracts.
- Support for Pre/Post Market orders.
- Fixed a "light-weight" request that wasn't returning an account's buying power.
- New IB Configuration option to return Bid/Ask Midpoint in charts instead of Trades data. Options are most often illiquid contracts, and pricing can move significantly from the last-traded price during the day. Midpoint provides Bid/Ask Midpoint OHLC bars continuously throughout the day, which should be more accurate pricing for backtesting.
- SymbolInfo for BarHistories will automatically "load" with the contract details. In most cases it won't be required to make entries for new IB contracts in Markets & Symbols.
- Resolved some issues around latency in IB Account updates.
- Fix for KeyNotFoundException when using Streaming Bars
- Quick failure return when requesting a contract without data permissions. Previously, requesting a contract without data permissions would "spin" many unnecessary requests.
- Handle TWS not installed at c:\jts, or, just TWS not installed.
- Fix - Cash and Cryptos contracts were defaulting to STK types in Accounts.
- Fixed some data issues for customers with non-USD regional settings.
- Adaptation for new LimitClose Order Type, and IB supports LOC orders if enabled in Trading Preferences.
- Futures and Options - symbol matching and basis price adjustment.
- Initial WL8 release.
- Change: STP LMT orders entered in IB TWS will now appear as Stop instead of Limit orders in Wealth-Lab. (Note: To get open orders entered manually in TWS, you must use Client ID 0 in the IB Configuration.)
- Minor code optimization for streaming.
- New: Option to enable/disable auto launching TWS
- Change: If a symbol record doesn't exist in Markets & Symbols, IB Build 19+ will assign the market using the contract's exchange for all security types (not just futures). If a Market doesn't already exist for a symbol's exchange, you should create one.
- Change: Automatic assignments for the major markets listed in Markets and Symbols are now assigned based on the contract exchange. For example, "Hong Kong Stock Exchange" Market for symbols with contract exchanges HKFE and SEHK; "Brazil Bovespa" for BOVESPA, "Frankfurt Stock Exchange" for IBIS and FWB, etc.
- Internal change: The TWS Time Zone and offsets are calculated in a different way. You shouldn't notice a difference, and charts should continue to display data in the assigned Market's time zone.
- Fix: Don't update a streaming bar with zero volume except for Cash and Index contracts that don't return volume.
- Fix: prefix and extra day for intraday requests for contracts that trade through midnight so that data isn't skipped.
- Work continues to reconnect after a TWS restart. Currently, following a TWS restart, you need to re-initiate the connection in the normal ways (Order Manager Connect button, request chart data, etc.)
- We recommend using Streaming Bars in the Strategy Monitor for Interactive Brokers Streaming. Streaming Bars create a real time replica of intraday historical bars with at least 10 times less processing required than Streaming. (Streaming chart data often results in minor differences from historical bar data because the "ticks" are conflated and updated no faster than 4 times per second.)
- Enabled connecting to a network machine by attempting a connection before checking if TWS or IB Gateway is running locally. TWS or IB Gateway must already be running on the other machine and you must ensure your firewall is configured correctly.
- IB configuration is loaded after a restart
- Load zero volume bars for index (IND) contracts (streaming and historical providers). Initially, you should request data for index contracts using the explicit specification, e.g., SPX;IND;USD;CBOE to create the contract reference. Thereafter you can just use the symbol, e.g., SPX. See Help > Interactive Brokers for more examples.
- 100x volume multiple is for US stocks only. Previously, volume was multiplied by 100 for any instrument assigned to the default U.S. Market, not just STK security types.
- Fix for parameter changes not always sticking.
- Correctly identify option contracts with decimal strikes
- Fix streaming volume for non-stock contracts
- Calculate midpoint for streaming forex charts. Previously, streaming charts were updated with bid prices only.
- Ignore streaming subscribe requests for expired futures or options contracts
- Change IB's heartbeat symbol to BTC.USD for more coverage. EUR.USD will be used on Fridays since Forex closes 1 hour later than PAXOS.
IB Data Provider "Overhaul" with breaking changes.
You must upgrade to TWS Latest version 10.12+ to use Build 16.
Fixes and other changes
- Corrected removal of a bar from the end of each historical batch request made during market hours.
- Trade volume will be far more accurate for streaming charts.
- Corrected volume for non-U.S. stocks in historical charts. You should refresh non-U.S. stock charts to correct the cache for 100x volume
- Ignore zero-volume bars in historical data for non-CASH contracts
- Ignore Closing data returned with negative or zero values; adjust OHL appropriately for neg/zero values.
- Consolidated the "Market data farms OK" messages to a single log message.
- Wealth-Lab will display batch request messages in the Chart Status Bar when making multiple requests for data. We recommend that you limit intraday chart requests by setting a small range (e.g. 2000 bars) in Data Preferences.
- A SecurityName will be displayed for new chart requests. You may need to reload older charts to retrieve the name.
Added data and trading (beta) support for cryptos: BTC.USD, BCH.USD, ETH.USD, LTC.USD
- Trading Cryptos has not been tested with Build 16.
- Extra data permissions are not required for cryptos, but you must upgrade to the TWS Latest v10.12 to access them.
- Simplified specification of U.S. option contracts to this format: [Symbol][yyMMdd][C/P][Strike]. e.g, for ATVI's June 17, 2022 67.5 Call, enter: ATVI220617C67.5
U.S. and Euro Futures
Major upgrade to simplify futures contract specification. An IBFutures.txt file will be loaded in the User data directory that contains many U.S. and European futures contract specifications. When a contract is defined in IBFutures.txt, you only need to type a futures symbol with the symbol-month-year format. e.g. ESH2 or ESH22.
The first time you make a data request for a non-expired futures contract, the Provider will add a record to IBFutureSymbolSpecs.txt in the User data directory. This file contains future specs (margin, point value, min tick, etc.) that can be pasted in Symbols.txt. Futures margin is based on exchange requirements for Initial Margin in December 2021.
Data request dates are automatically controlled for expired futures contracts.
Added support for continuous contracts. Instead of a letter month and year, use #C, e.g., ES#C, CL#C, GC#C, etc. -- Note! Do not use Continuous Contracts for trading.
Let us know if you trade non-U.S. options in the Discussion forum!
- Added an IB-specific Parser for the Trade History Strategy type.
- Changes to adapt to WL7 framework changes in Build 42.
- Fixed order status updates not ocurring issue.
- Avoid requesting entire intraday history when a Max Bars Data Range is selected.
- Minor changes to take advantage of better data loading mechanisms in WL7 Build 37.
- Beefed up error handling and logging.
- When active OCO orders are reloaded, they will show OCO link icon.
- Extend end date requests one day into the future to account for different time zones.
- Active orders will now populate into the Order Manager when IB Broker is connected.
- Provider marked as not supporting parallel updates.
- The VIX futures contract wouldn't come back before. It's required to specify the IB Local Symbol for futures contracts if it's different than the IB Symbol, in this case, VIX and VX.
- Improve performance when canceling Data Requests.
- Connecting will now launch TWS if TWS or IB Gateway is not already open.
- Support for native OCO (One-Cancels-Other) orders.
- Support for MOO (Market on Open) orders.
- Update for new Accounts framework, display accounts and positions info in Accounts window.
- Fixed bug preventing short orders from being placed.
- Fixed historical requests for Forex data.
- Refer to Help > Extension > Interactive Brokers for guidance on entering symbols/contracts.
- Fix: multiple simultaneously placed orders were failing for duplicate order IDs.
- Integrate help topic: Extensions > Interactive Brokers.
- Baseline release.