Skip to content

Excel

OptionsRealTime includes an Excel RTD (Real-Time Data) API that streams live portfolio data, PnL and Greeks from your Interactive Brokers accounts into spreadsheets.

Excel Dashboard

The Excel integration subscribes directly to the same NATS data stream as the web UI, with full access to all fields and accounts. Where the web UI provides pre-built views for analyzing risk, Excel is the path for users who want to build their own dashboards and analytics in a spreadsheet, driven by RTD formulas.

The API is self-discoverable: functions exist to enumerate accounts, account names, tables, fields, and values. Workbooks can be built to discover the connected account and adapt automatically.

Excel runs as an independent client. It can run on the same machine as the web UI or on any other machine that can reach the NATS server, and does not require the web UI to be running.

Excel receives the values as the publisher sends them. Position and Underlying values are in the contract currency. Fields ending in _BASE and the values of the account-level Portfolio row are in the base currency of the account. The Base currency selector of the web UI does not apply to Excel. To show an account in another currency, pass a currency code with _BASE to ort_portfolio_value (see Real-Time Data). The BASE_CURRENCY field gives the base currency of the account on each row, so a formula can filter rows by base currency.

  1. Ensure OptionsRealTime Rover is running and connected to TWS (no user interfaces need to be running)
  2. Open the provided OptionsRealTime.xlsx template or create a new workbook
  3. RTD functions automatically connect to the NATS data stream

The Excel RTD add-in reads its settings from OptionsRealTime.ini, located in the installation folder (typically C:\Users\<username>\AppData\Local\OptionsRealTime\).

You can edit this file using the shortcut: OptionsRealTime → Advanced → Edit Excel RTD Config

[Addin]
LogLevel="trace"
LogPopupLevel="error"
DateFormats=["%Y-%m-%d", "%Y%b%d"]
[OptionsRealTime]
NatsUrl="nats://localhost:4222"
RtdThrottleMs=250
MaskSize=4
SettingDescription
NatsUrlNATS server address. Default is localhost:4222.
RtdThrottleMsMinimum interval between Excel updates in milliseconds. Lower = more responsive, higher = less CPU usage.
MaskSizeNumber of characters to mask in account IDs (for privacy when sharing screenshots).

If you’re running Excel on a different machine than NATS and Rover, you need to point Excel to the NATS server’s IP address:

  1. Open OptionsRealTime → Advanced → Edit Excel RTD Config
  2. Change NatsUrl from localhost to your NATS server’s IP:
    NatsUrl="nats://192.168.1.100:4222"
  3. Save and restart Excel

See the Multi-Machine Setup guide for complete instructions.

Every function that takes an account accepts any of three forms:

  • The real account ID (U1234567)
  • A masked account ID (U123****)
  • The account name assigned in Rover (IRA_1)

Resolution order is always: exact account ID, then mask, then name. Account names are the recommended way to build spreadsheets that never display a real account ID.

These functions return live values from the four core tables.

FunctionDescriptionArguments
ort_portfolio_valueReturns live portfolio field valueaccount ID or name, field name, [currency]
ort_system_valueReturns live system field valueaccount ID or name, field name
ort_position_valueReturns live position field valueaccount ID or name, contract ID or symbol, field name, [currency]
ort_underlying_valueReturns live underlying field valueaccount ID or name, contract ID or underlying, field name, [currency]

The currency argument of ort_portfolio_value picks the Portfolio row and the currency of the values. Upper or lower case gives the same result.

CurrencyRowValues
BASE, blank or missingAccount-level rowThe whole account in its base currency: IBKR account values, such as NET_LIQUIDATION, the margin fields, BUYING_POWER and account PnL, and the sums of the positions, such as VALUE and DELTA_DLRS. Each currency’s sum is converted at the IBKR exchange rate. The contract counts are not converted.
A currency code, such as USD or CADRow of that currencySums of the positions in that currency, in that currency. IBKR cash and market values for that currency, such as CASH_BALANCE, STOCK_MARKET_VALUE and NET_LIQ_BY_CURRENCY. EXCHANGE_RATE converts a value of the row to the base currency. Account-level fields, such as NET_LIQUIDATION, the margin fields, BUYING_POWER, account PnL and the _BASE fields, return #N/A.
A currency code with _BASE, such as USD_BASE or CAD_BASEAccount-level rowThe values of BASE, with the money fields converted from the base currency of the account to that currency at the rate of ort_fx_rate. Accounts with different base currencies then show their values in one currency, so a sheet can add them. The contract counts, percentages, times and text are not converted. The money fields return #N/A while the base currency of the account has no rate.

A currency row exists for each currency in which the account holds positions or cash. A currency code with no row in the account returns #N/A. A currency with no IBKR exchange rate yet is left out of the account-level sums until the rate arrives. The web Contract currency selector shows the same currency rows.

ort_position_value, ort_underlying_value and the metric functions read any row, including rows with a POSITION of 0. The BID and ASK of a watch-list contract are available by symbol or contract ID.

ort_position_value, ort_underlying_value and the list functions take an optional last argument, the currency. Upper or lower case gives the same result.

CurrencyContracts in the listsValues
Blank or missingEach currencyAs published, each contract in its own currency
BASEEach currencyThe money fields converted from the contract currency to the base currency of the account
A currency code, such as USD or CADOnly the contracts in that currencyAs published. A contract in another currency returns #N/A.
A currency code with _BASE, such as USD_BASE or CAD_BASEEach currencyThe money fields converted to that currency

The money fields are PnL, value, cost basis, notional, intrinsic and extrinsic value, THETA, VEGA, RHO, DELTA_DLRS, GAMMA_DLRS, and the tag group risk fields RISK_MAX_GAIN and RISK_MAX_LOSS. Quotes and contract terms (BID, ASK, LAST, CLOSE, CHANGE, STRIKE), DELTA and GAMMA in shares, counts, IV and percentages stay as published. The _BASE fields, such as THETA_BASE, are already in the base currency of the account, and a code with _BASE converts them from there. A money field returns #N/A while its currency has no rate. The metric functions do not take a currency, so their values stay in the contract currency.

In a list function the currency follows include flat, for example ort_position_symbol_at(B1, 1, FALSE, "CAD"). Give a _size function and its _at function the same currency.

FunctionDescriptionArguments
ort_portfolio_currencies_sizeReturns count of currencies with a Portfolio row for accountaccount ID or name
ort_portfolio_currency_atReturns currency code at 1-based index (sorted), for the currency argument of ort_portfolio_valueaccount ID or name, index

The list holds the currencies of the positions and of the IBKR cash balances of the account.

FunctionDescriptionArguments
ort_fx_rateReturns the exchange rate from one currency to anotherfrom currency, to currency
ort_fx_currencies_sizeReturns count of currencies that have an exchange rate(none)
ort_fx_currency_atReturns currency code at 1-based index (sorted) of the currencies that have an exchange rateindex

A value in the from currency multiplied by ort_fx_rate gives the value in the to currency. ort_fx_rate("CAD", "USD") is the number of US dollars in one Canadian dollar. The rates are IBKR exchange rates. The web Base currency selector and a currency code with _BASE use the same rates. The rates update every few minutes.

A currency with no rate returns #N/A. To add a rate for that currency, check its USD cross on the web Currencies tab.

Access the 9×9 implied volatility and price move scenario grid.

FunctionDescriptionArguments
ort_position_metricReturns metric value from scenario grid for a positionaccount ID or name, contract ID or symbol, metric field, IV label, move label
ort_underlying_metricReturns metric value from scenario grid for an underlyingaccount ID or name, contract ID or underlying, metric field, IV label, move label
ort_underlying_metric_priceReturns underlying price at specified move scenarioaccount ID or name, underlying, move label
FunctionDescriptionArguments
ort_accounts_sizeReturns count of connected accounts(none)
ort_account_atReturns account ID at 1-based indexindex
ort_account_names_sizeReturns count of connected account names (same as ort_accounts_size)(none)
ort_account_name_atReturns account name at 1-based index (same order as ort_account_at)index
ort_account_nameReturns the account name for an accountaccount ID or name
ort_account_idReturns the real account ID for an account name or masked account IDaccount ID or name
ort_accounts_masked_sizeReturns count of connected accounts(none)
ort_account_masked_atReturns masked account ID at 1-based indexindex

Notes:

  • Account names are assigned per account in Rover and arrive via the System table (ACCOUNT_NAME).
  • ort_account_name_at uses the same sort order as ort_account_at, so index i refers to the same account in both.
  • Until the name for a connected account has arrived, name functions return the obfuscated placeholder U00000001, U00000002, … based on the account’s 1-based position in the sorted-by-ID account list. Cells update automatically when the name arrives.
  • Renaming an account in Rover updates name-based formulas live.

The list functions below (Position Discovery, Position Filter by Underlying, Position Filter by Expiration and Underlying Discovery) return open positions and positions closed today. An open position has a POSITION other than 0. A position closed today has a POSITION of 0 and a PNL_REALIZED that is not 0 when rounded to two decimal places. The underlying functions return the underlyings of these positions.

The Position table also has rows with a POSITION of 0 and no realized PnL: watch-list contracts, the underlying stock of an option position when the account has no position in that stock, and the USD crosses checked on the web Currencies tab. The lists leave these rows out by default.

Set the optional argument include flat to TRUE to list these rows too. Give a _size function and its _at function the same include flat value, or the count and the list disagree. The optional currency argument follows include flat (see Position and Underlying Currency).

FunctionDescriptionArguments
ort_position_conids_sizeReturns count of positions for accountaccount ID or name, [include flat], [currency]
ort_position_conid_atReturns contract ID at 1-based index (sorted by contract ID)account ID or name, index, [include flat], [currency]
ort_position_symbols_sizeReturns count of position symbols for accountaccount ID or name, [include flat], [currency]
ort_position_symbol_atReturns symbol at 1-based index (sorted by symbol)account ID or name, index, [include flat], [currency]
ort_position_expirations_sizeReturns count of unique expiration datesaccount ID or name, [include flat], [currency]
ort_position_expiration_atReturns expiration date at 1-based index (sorted ascending)account ID or name, index, [include flat], [currency]
FunctionDescriptionArguments
ort_position_conids_by_underlying_sizeReturns count of positions for a given underlyingaccount ID or name, underlying, [include flat], [currency]
ort_position_conid_by_underlying_atReturns contract ID at index for underlying (sorted by expiration, type, strike)account ID or name, underlying, index, [include flat], [currency]
ort_position_symbols_by_underlying_sizeReturns count of positions for a given underlyingaccount ID or name, underlying, [include flat], [currency]
ort_position_symbol_by_underlying_atReturns symbol at index for underlying (sorted by expiration, type, strike)account ID or name, underlying, index, [include flat], [currency]
FunctionDescriptionArguments
ort_position_conids_by_expiration_sizeReturns count of positions for a given expiration dateaccount ID or name, expiration, [include flat], [currency]
ort_position_conid_by_expiration_atReturns contract ID at index for expiration (sorted by underlying, type, strike)account ID or name, expiration, index, [include flat], [currency]
ort_position_symbols_by_expiration_sizeReturns count of positions for a given expiration dateaccount ID or name, expiration, [include flat], [currency]
ort_position_symbol_by_expiration_atReturns symbol at index for expiration (sorted by underlying, type, strike)account ID or name, expiration, index, [include flat], [currency]
FunctionDescriptionArguments
ort_underlying_conids_sizeReturns count of underlyings for accountaccount ID or name, [include flat], [currency]
ort_underlying_conid_atReturns underlying contract ID at indexaccount ID or name, index, [sort field], [sort order], [include flat], [currency]
ort_underlying_symbols_sizeReturns count of underlying symbols for accountaccount ID or name, [include flat], [currency]
ort_underlying_symbol_atReturns underlying symbol at indexaccount ID or name, index, [sort field], [sort order], [include flat], [currency]
ort_underlying_symbols_size_by_metricReturns count of underlying symbols (metric-sorted)account ID or name, metric field, IV label, move label, [include flat], [currency]
ort_underlying_symbol_at_by_metricReturns underlying symbol at index, sorted by metric valueaccount ID or name, index, metric field, IV label, move label, [sort order], [include flat], [currency]

Notes:

  • Parameters in [brackets] are optional
  • Metric field: DELTA_DLRS_METRICS, DELTA_METRICS, EXTRINSIC_VAL_METRICS, GAMMA_DLRS_METRICS, GAMMA_METRICS, PNL_METRICS, PNL_UNREALIZED_METRICS, THETA2_ORT_METRICS, THETA_LIN_METRICS, THETA_METRICS, TM_VAL_METRICS (position table only), VALUE_METRICS, VEGA_METRICS
  • IV label: MKT, IV10, IV25, IV50, IV75, MKT-5, MKT-2, MKT+2, MKT+5
  • Move label: -20%, -10%, -5%, -1%, 0%, +1%, +5%, +10%, +20%
  • Sort field: an Underlying table field name. The default is UNDERLYING.
  • Sort order: ASC (lowest first) or DESC (highest first). The default is ASC for ort_underlying_conid_at and ort_underlying_symbol_at, and DESC for ort_underlying_symbol_at_by_metric.
  • Include flat: TRUE also lists the rows with a POSITION of 0 and no realized PnL (see Rows in the Lists). The default is FALSE.
  • _by_metric functions sort underlyings by a specific cell in the 9×9 metric grid (e.g., PNL at MKT/0% or DELTA at IV25/+5%)

Enumerate available fields for each table.

FunctionDescriptionArguments
ort_system_fieldsReturns array of valid System table field names(none)
ort_system_fields_sizeReturns count of System table fields(none)
ort_system_field_atReturns System field name at 1-based indexindex
ort_portfolio_fieldsReturns array of valid Portfolio table field names(none)
ort_portfolio_fields_sizeReturns count of Portfolio table fields(none)
ort_portfolio_field_atReturns Portfolio field name at 1-based indexindex
ort_position_fieldsReturns array of valid Position table field names(none)
ort_position_fields_sizeReturns count of Position table fields(none)
ort_position_field_atReturns Position field name at 1-based indexindex
ort_underlying_fieldsReturns array of valid Underlying table field names(none)
ort_underlying_fields_sizeReturns count of Underlying table fields(none)
ort_underlying_field_atReturns Underlying field name at 1-based indexindex
FunctionDescriptionArguments
ort_move_labelsReturns array: -20%, -10%, -5%, -1%, 0%, +1%, +5%, +10%, +20%(none)
ort_move_labels_sizeReturns count of move scenario labels (9)(none)
ort_move_label_atReturns move label at 1-based indexindex
ort_iv_labelsReturns array: MKT, IV10, IV25, IV50, IV75, MKT-5, MKT-2, MKT+2, MKT+5(none)
ort_iv_labels_sizeReturns count of IV scenario labels (9)(none)
ort_iv_label_atReturns IV label at 1-based indexindex
ort_metric_fieldsReturns array of valid metric field names. TM_VAL_METRICS is only available for positions (ort_position_metric), not underlyings.(none)
ort_metric_fields_sizeReturns count of metric field names (13)(none)
ort_metric_field_atReturns metric field name at 1-based indexindex

Account names (see Account Discovery) are the recommended way to keep real account IDs out of shared spreadsheets. Masking remains available for ID-based workflows.

FunctionDescriptionArguments
ort_get_mask_sizeReturns current account mask size (number of asterisks)(none)
ort_set_mask_sizeSets account mask size (0-8) and returns actual valuesize
ort_mask_accountMasks an account ID (e.g., U1234567 → U123****)account ID
ort_unmask_accountConverts a masked account ID or account name to the real account IDmasked account ID or name
FunctionDescriptionArguments
ort_nats_stateReturns live NATS connection state(none)
ort_nats_startStarts NATS connection(none)
ort_nats_stopStops NATS connection(none)
ort_nats_initStarts or stops NATS connectionstart (TRUE/FALSE)
ort_request_refreshRequest full data refresh for an accountaccount ID or name
ort_request_refresh_allRequest full data refresh for all known accounts(none)
FunctionDescriptionArguments
ort_config_urlReturns configured NATS URL from ini file(none)
ort_config_throttleReturns current RTD throttle interval in ms(none)
ort_set_rtd_throttle_msecSets RTD throttle interval (50-60000 ms)milliseconds
FunctionDescriptionArguments
ort_versionReturns ORT version and build info(none)
ort_utc_nowReturns current UTC date/time (YYYY-MM-DD HH:MM:SS)(none)
ort_utc_now_rtdReturns live UTC time (RTD)(none)

OptionsRealTime includes a template workbook (OptionsRealTime.xlsx) with pre-built tabs demonstrating common use cases. Every tab selects its account by name from a dropdown; no real account IDs appear anywhere in the workbook.

  • Accounts: Portfolio summary across all accounts. Cell B3 is the currency argument of every formula on the tab: BASE, a currency code, or a currency code with _BASE (see Real-Time Data). The TOTAL column adds the accounts when their values are in one currency: always for a currency code or a code with _BASE, and for BASE only when all the accounts have the same base currency. Contract counts are always added. An account whose values are blank is left out of TOTAL.
  • Underlying: Underlying-level aggregated data for a selected account
  • Positions (Account): Per-position detail for a selected account
  • Positions (Underlying): Positions filtered to a single underlying
  • Positions (Expiry): Positions grouped by expiration date
  • Vol Scenario: Metrics across IV and price scenarios for a single underlying
  • VolExposure: Underlying risk metrics across volatility scenarios
  • System: Connection health and diagnostics
  • Cross Rates: The exchange rate between each pair of currencies that have a rate, from ort_fx_rate. Each cell converts the row currency to the column currency.
  • Documentation: Quick reference for all RTD functions

The Underlying and Positions tabs have a CURRENCY cell next to the account, set to BASE. The cell is the currency argument of the account row and of each position or underlying row on the tab (see Position and Underlying Currency).

No Visual Basic for Applications (VBA) is required. This is a pure .xlsx workbook consisting mostly of simple Real Time Data (RTD) formulas. No macros, no security warnings, no code to maintain.

Aggregated Greeks and PnL by underlying Portfolio Accounts

Detailed position view Securities

View of positions for a single underlying Underlying Detail

View of positions at a selected expiration Maturity View

Underlying metrics across price and IV scenarios Vol Exposure View

Metrics across IV and price scenarios for a single aggregated underlying Vol Scenario View

System health and data throughput System Health