A production-grade Excel RTD server for Interactive Brokers TWS.
A drop-in replacement for the Excel RTD server that ships in the IBKR TWS API distribution, with error handling, reconnection, multi-cell deduplication, and a topic schema that covers accounts, positions, orders, and order submission alongside market data.
TwsRtdServer is independent work by David Bookstaber; the intellectual property is held by Wake Yale Holdings, LLC. It is not affiliated with or endorsed by Interactive Brokers.
Interactive Brokers ships a sample Excel RTD application — also named TwsRtdServer — under C:\TWS API\samples\Excel\ as part of the TWS API distribution. The IBKR sample is the right starting point for understanding how the Excel RTD contract plugs into TWS. IBKR's Excel RTD documentation explicitly characterises the sample as a learning aid, noting that it is
not intended to be used as production level trading tools
and that the sample applications do not have robust error handling.
This is a separate, hardened C# implementation of the same IRtdServer COM contract — built for live-trading deployment. The COM contract is identical, the formula syntax is identical, and an optional registry alias maps the IBKR sample's legacy ProgID Tws.TwsRtdServerCtrl onto this server's CLSID so existing workbooks built against the IBKR sample keep working without modification.
What that hardening covers, concretely:
- Topic schema beyond Market Data. Account values (per-currency), Positions (with streaming P&L), Orders (with order monitoring across all clients), and Order submission are all exposed as
=RTD()formulas alongside Market Data. The schema the IBKR sample doesn't cover. - Order submission from Excel. A dedicated
SendOrdertopic family lets a formula submit an order as the side-effect of subscribing — the cell returns a status string (Sending→Sent, orSendOrder Error: <message>). Used in production at Closed-End Trading LLC. - Automatic reconnection with subscription re-establishment. When TWS restarts mid-session, the server reconnects automatically and re-subscribes to every previously-active topic. Non-volatile fields preserve their last-known value through the disconnect window rather than going
#N/A. - Excel UI events don't block subscription updates. Microsoft Excel pauses its RTD pull while a modal dialog is open, while a cell is in edit mode, or while Excel is otherwise busy — IBKR's docs describe this as inherent to Excel's design as a trading application. TwsRtdServer maintains its internal cache independently of Excel's polling cadence, so when Excel returns to a ready state it reads the latest cached value rather than an update that arrived while it was busy and is now lost.
- Multi-instance: per-process TWS connection. Each
EXCEL.EXEprocess that loads TwsRtdServer opens its own TWS API client connection with an auto-allocated client ID (configurable viaTWS_RTD_CLIENT_ID). No cross-instance contention; no shared subscription map. - Subscription deduplication within a process. Duplicate
=RTD()cells referencing the same logical topic share a single upstream subscription. Copy-drag a formula across 200 rows of a chain → one subscription, not 200. Visible to the user asActiveTopicCounton the Status tab.
TwsRtdServer registers itself with the ProgID Tws.Rtd (shorter than the IBKR sample's Tws.TwsRtdServerCtrl; case-insensitive in formulas). Some examples:
=RTD("Tws.Rtd", , "status", "IsConnected")
=RTD("Tws.Rtd", , "AAPL@SMART", "Last")
=RTD("Tws.Rtd", , "account", "U1234567", "NetLiquidation")
=RTD("Tws.Rtd", , "position", "U1234567", "AAPL@SMART", "MarketValue")
=RTD("Tws.Rtd", , "positions", "*", "SymbolsCsv")
=RTD("Tws.Rtd", , "orders", "*", "OpenListCsv")
=RTD("Tws.Rtd", , "SendOrder", "sym=AAPL", "side=BUY", "shares=100", "type=LMT", "limit=150.05", "exch=SMART")
The full topic-string grammar — Market Data, Accounts, Positions, Orders (monitoring + submission), Status — publishes alongside the first Releases drop. Existing workbooks built against the IBKR sample can be migrated either by replacing Tws.TwsRtdServerCtrl with Tws.Rtd or by installing the optional legacy-ProgID alias and leaving the formulas alone.
A short walkthrough — option chain (80 instruments, 7 fields each, 560 =RTD() formulas), a Format Cells dialog held open over the streaming chain, a roundtripped buy order with the new position reflected in Excel as it fills, and two Excel instances each running an independent connection.
| Path | Surface | Coverage | Production-grade? |
|---|---|---|---|
| TWS DDE | Legacy Excel pipe | Market data, limited orders | Legacy / discouraged for new development |
IBKR Excel RTD sample (C:\TWS API\samples\Excel\TwsRtdServer.{xls,dll}) |
Reference C# RTD server | Market data | Per IBKR docs: learning aid, not production |
TWS API client libraries (C# / Java / Python / ib_async) |
General-purpose programmatic clients | Full TWS API surface | Yes, but not Excel-native |
| TwsRtdServer (this project) | Hardened RTD server (drop-in replacement for the sample) | Market Data + Accounts + Positions + Order monitoring + Order submission | Yes (Excel-specific surface) |
Relevant IBKR documentation:
- Excel RTD — IBKR Campus — the official Excel RTD page (source of the production-readiness disclaimer and the Excel UI-priority note)
- TWS API documentation root — IBKR Campus — full TWS API reference
The author runs this server in production at Closed-End Trading LLC, where it underpins portfolios trading over $80 million per month through IBKR. The codebase is approximately 16,000 lines of production C# backed by approximately 29,000 lines of automated tests (~1.75× test-to-source ratio).
- Server runtime: .NET Framework 4.8, COM-registered via
regasm /codebase. - Excel: Microsoft 365 / 2019+, 32-bit or 64-bit (registration bitness must match Excel's bitness).
- Windows: Windows 10 / 11.
- IBKR side: TWS or IB Gateway with the socket API enabled. Standard
Configure → API → Settings → Enable ActiveX and Socket Clientsplus trusted-IP setup; no IBKR-side software extensions required.
- Source: closed. Commercial source-license inquiries are welcome — see
docs/licensing.md. - Binaries: the server runs in production at Closed-End Trading LLC and is verified-by-use on every trading day. Signed public Releases are pending code-signing certificate provisioning under Azure Trusted Signing; the first signed
.msiis expected late May / early June 2026, gated on Trusted Signing identity validation. Verified install and first-run instructions publish alongside that drop. - CI: the GitHub Actions workflow in this repository runs docs lint and link checks on each push. The binary build runs against the private source repository and is gated on the same signing-cert milestone.
The directories examples/, screenshots/, and releases/ currently hold placeholder READMEs and will populate alongside the first signed Releases drop.
Documentation, examples, FAQ, and templates in this repository are released under the MIT License. The TwsRtdServer binary product itself is not open source — it is closed-source commercial software distributed under a separate End-User License Agreement that ships with the installer. See docs/licensing.md.
docs/— architecture overview, design notes, FAQ, licensing posture, install + first runexamples/— Excel workbook examples (placeholder)screenshots/— UI screenshots (placeholder)releases/— release-notes landing (signed binaries publish to the Releases tab; placeholder until cert).github/— issue templates, PR template, CI workflows
Bug reports and feature requests are welcome via GitHub Issues. For commercial inquiries (source license, integration partnership, OEM redistribution), please open a GitHub Discussion in the Commercial inquiries category.