by QMatix

Delivering the Stock Market to Excel

XLQ2 - Interactive Brokers

Interactive Brokers

Introducing Interactive Brokers

Using xlq2 with your Interactive Brokers account allows you to work with market data, options and your own account and positions data directly in Excel. Type a formula such as =xlqPrice("msft","ib") in a cell and it updates in real time from Trader Workstation (TWS) or IB Gateway. There are no additional fees, and no third-party service: xlq2 connects directly to TWS on your own computer.

Try xlq2Lite free for 3 weeks

Live Interactive Brokers prices in Excel

Streaming realtime prices, including pre- and post-market, for anything IB has a symbol for: stocks, ETFs, futures, forex, cryptos, bonds and more.

=xlqPrice("msft","ib")last traded price for Microsoft, streaming in real time
=xlqBid("msft","ib")the current bid
=xlqChangePercent("msft","ib")the day's change in percent
=xlqPrice("EUR.USD[IDEALPRO,CASH,USD]","ib")the euro / US dollar rate
=xlqPrice("NQZ6[CME,FUT,USD]","ib")the Nasdaq-100 E-mini future, December 2026
=xlqPrice("BTC.USD[PAXOS,CRYPTO,USD]","ib")Bitcoin in US dollars

Symbols other than US equities use the format symbol[exchange,type,currency] (see symbols section below)

Interactive Brokers options and Greeks in Excel

Realtime option prices and Greeks from IB, ready for your own spreads, hedges and screens (as well as historic and intraday)

=xlqPrice("AAPL 261218C00200000[SMART,OPT,USD]","ib")last price of the Apple $200 call expiring 18 December 2026
=xlqDelta("AAPL 261218C00200000[SMART,OPT,USD]","ib")its delta (also xlqGamma, xlqTheta, xlqVega)
=xlqImpliedVolatility("AAPL 261218C00200000[SMART,OPT,USD]","ib")its implied volatility

Tip: enter the option symbol in a cell, e.g. A2, and use =xlqDelta(A2,"ib"). Option symbols can also be built with formulae such as xlq2OptionSymbolBuildCall.

Interactive Brokers historic and intraday bars in Excel

Daily, weekly and monthly history (split adjusted), hundreds of calculations and indicators, and intraday bars that keep updating through the current day.

=xlqhClose("msft",-1,"ib")Microsoft's previous close
=xlqhwOpen("csco",-2,"ib")Cisco's opening price for last week
=xlqxhMean("aapl",0,20,4,"ib")20-day average of Apple's typical price (high + low + close) / 3, up to and including the latest price
=xlqhiOpen("aapl",-1,-1,5,1,"ib")open of the last 5-minute bar of the previous day's post-market trading (historic intraday needs xlq2)

See the historic and historic intraday formulae for the full lists.

Your Interactive Brokers account and positions in Excel

With xlq2 you can list your IB accounts and positions in the portfolio view, and work with them in Excel with realtime updates: cash balance, margin, buying power, maintenance requirements and more.

=xlqpAccountNetLiquidation(-1,"ib")Returns the net liquidation balance from first account from ib (may also specify account number)
=xlqpCash(-1,"ib")Available cash for the account
=xlqpMargin(-1,"ib")Margin for the account
=xlqpSymbol(,,"ib")Symbol of the first position (alphabetic order) from first account

Your account data stays private: xlq2 will only request it if enabled in preferences (which also disables crash reporting), and everything passes only between your computer and Interactive Brokers over TWS's own encrypted connection.

  • IBKR Lite accounts will not work (no API available)
  • Data available depends on the data subscriptions associated with the account. Delayed data may be available without a data subscription but in general a realtime data subscription is needed for both realtime and historic data, which is usually the case if already using via TWS.
  • Number of streaming symbols depend on your account subscription/ commission and subscriptions (booster packs etc.). Limits do not apply to historic data
  • Use of TraderWorkstation (TWS) or gateway is required (as xlq2 connects with it.)

For full support and functionality an xlq2 license is required however the Interactive day and historic data sources are also available to xlq2lite users. xlq2 would be required for account data and xlq2 functionality such as historic intraday.

To start working with Interactive Brokers via xlq2, in addition to an xlq2 / xlq2lite license you would require an Interactive Brokers account. If you do not already have one you may find more info here: https://ndcdyn.interactivebrokers.com/Universal/Application

Interactive Brokers is available in many countries so ensure you connect with your local site.

Setup, symbols and data details:

To work with IB via TWS you need to install the latest version for windows from here: https://www.interactivebrokers.com/en/trading/tws.php

You would need to be signed into the account you want to use, as xlq2 connects directly with it.

On first use you should ensure that it is configured correctly by clicking Configure in TWS and choosing API / Settings.

  • "Enable ActiveX and Sockets Clients" must be checked
  • The socket port must correspond with the setting in xlq2 preferences (usually 7496)
  • Set 127.0.0.1 as a trusted IP (avoids confirming connections from your computer)
  • Enable "Request Account Info" in xlq2 preferences if you wish to work with account data

 

To work with IB via the Gateway you need to install the latest version for windows from here: https://www.interactivebrokers.com/en/trading/ibgateway-latest.php

You would need to be signed into the account you want to use.

On first use you should ensure that it is configured correctly by clicking Configure and choosing API / Settings.

  • The socket port must correspond with the setting in xlq2 preferences (usually 4001)
  • Ensure 127.0.0.1 is set as a trusted IP
  • Enable "Request Account Info" in xlq2 preferences if you wish to work with account data

 

As Interactive Brokers covers markets worldwide, providing data for many different products and even from individual exchanges their symbols are not always simple, but in general, once you know one, the rest follow.

All IB symbols in xlq2 use the syntax symbol[exchange,type,currency]. If [exchange,type,currency] is not provided they default to [smart,stk,usd] for US equities, so will always need to be provided for other products. e.g. msft and msft[smart,stk,usd] are identical. If you wanted msft from the Toronto stock exchange it would be msft[smart,stk,cad] or even more precisely msft[tse,stk,cad].

Smart as exchange signifies best pricing for the product and would cover the listed as well as other exchanges including ECNs. For a price from a specific exchange you may provide that instead / as well e.g. msft[iex,stk,usd] from iex, or msft[nasdaq,stk,usd] for Nasdaq quotes only.

When using smart, if the same symbol is listed on multiple exchanges with the same currency you may receive an ambiguity error in that case you may still request a smart quote by further specifying the symbol's listed exchange as follows msft[smart&nasdaq,stk,usd]

All errors from IB are shown in the xlq status views.

Certain symbols also contain spaces, primarily when root symbol is a fixed length such as for options (6 character) and anything shorter requires spaces padded to the end, i.e. msft will require 2 spaces, ups 3, e.g. MSFT   261113C00270000[SMART,OPT,USD] (Option symbol may also be constructed using formulae such as xlq2OptionSymbolBuildCall)

If you are uncertain of a symbol, the simplest is to enter it into tws, then right click it, select Financial Instrument Info / Description (or double click the symbol) and you will be able to extract the required info (including spaces), see screenshots below

Interactive Brokers security types for xlq2 symbols: SYMBOL[EXCHANGE,TYPE,CURRENCY]
Type IB code Example xlq symbol
Stocks and ETFs STK INTC[SMART,STK,USD]
Options OPT AAPL 261218C00200000[SMART,OPT,USD]
Futures FUT NQZ6[CME,FUT,USD]
Futures (metals) FUT GCZ6[COMEX,FUT,USD]
Futures options FOP ESM7 C7850[CME,FOP,USD]
Indices IND DJI[CME,IND,USD]
INVIX[NSE,IND,INR]
Forex (currency pairs) CASH EUR.USD[IDEALPRO,CASH,USD]
Bonds BOND 86038AAA0[SMART,BOND,USD] (CUSIP)
Treasury bills BILL 912797UX3[SMART,BILL,USD]
Warrants WAR LPBBW[SMART,WAR,USD]
MN8GPZ[SWB,WAR,EUR]
Commodities (spot metals) CMDTY XAUUSD[SMART,CMDTY,USD]
Crypto CRYPTO BTC.USD[PAXOS,CRYPTO,USD]
Mutual funds FUND VFIAX[FUNDSERV,FUND,USD]
CFDs CFD IBDE40[SMART,CFD,EUR]

The type code is IB's own and is written in upper case. Stocks (STK) and mutual funds (FUND) use the plain symbol; every other type uses IB's local symbol, the name TWS shows in the contract details (for example NQZ6 for a future).

 

Streaming Realtime and historic split adjusted data (day, week and month) are available for almost all symbols from IB including for stocks, options, etfs, indexes, mutual funds, currencies, futures, bonds etc.

 

Streaming realtime tick data including for extended hours for all available symbols.

 

 

Work with your account and portfolio data directly via the xlq2 portfolio view or via excel

 

Try it with your own IB account. xlq2Lite covers IB realtime and historic data and is free for 3 weeks; account data and historic intraday need xlq2.

Download the free trial Compare xlq2 and xlq2Lite
New Tips and Tricks Page
  • A quick reference guide to using xlq2 with excel including shortcuts, tips etc.

  • Examples and explanations for all user levels.
Also available via the Resource menu above, along with references for formulae, symbols etc.

LATEST NEWS:

4 December 2026

XLQ2 26.3 released

  • Major technical update
  • New dashboard
  • New range formulae
  • More. >>

Current Offers

1 year of upgrades included
Purchase xlq2Lite for $159
Purchase xlq2 for $299

Pleased with the service and support
or feel extra has been earned?

Your acknowledgement is appreciated.
Thank you

User Comments

It is so uncommon in this day and age to receive top-level, human support and I appreciate that immensely. The quality, breadth and utility of your product is incredible, but even more impressive is the level of support you provided to me, just one individual customer. You may quote me on that. Thank you.

- C.B.

Wow, you did a lot of work on this version. New interface and other things as well. I must give you credit for being the most responsive software engineer that I've ever encountered. Every question that I've sent you over the many years (since 2003!!!) has been answered quickly and professionally. I just wanted to let you know that it is appreciated.

- M.N.

I have to say Leo that the last two versions have made some tremendous improvements to what has been for years an outstanding application. Thank you for your continued efforts.

- C.A.

Just to let you know that, the new version works much better & faster than the older one. I like it a lot, fantastic job you did!!!

- R.S.

Many thanks indeed for your clear and very rapid reply. I am not used to this type of quality service - I thought it went out of fashion years ago !!

- P.G.

In only 40 some days XLQ has helped me with a number of research projects I couldn't possibly have done without it and I'm now using it to help manage and track current trades and to alert me to potential new trades.

- D.P.

I just wanted to take a moment and thank you for creating XLQ. I use it regularly for scanning/monitoring securities in Excel 2007.  I have programmed in trailing stops for securities I own and numerous techniques using indicators for securities on my watch list. The combination of Excel 2007 and XLQ has opened up nearly an unlimited capability that is only constrained by my imagination.

- E.H.

Thank you for the amazing package -- I use it daily and it's ridiculously useful! Others (.....) have added some of the features you have, but none of them even comes close to matching what you've built.

- R.B.

Your product is fantastic, amazing, and really strong. It has real enabling capability. Thank you for putting this into the market!

- R.G.

You have an exceptional customer service, you have always answered my questions, I thank you for that, made it really easy to use this software, will be your long term customer. Thanks.

- A.D.

I was halfway resigned to have to program something like this myself. Only it would have taken me forever, and I couldn't have done it half as well. Thanks!

- M.S.

I also want to thank you for making the XLQ program. It is something that is very useful and incredible helpful. Like it was made for my needs.

- J.T.

I have already modified your demo sheet to fit my needs.  Your program allows me to turn my excel spreadsheet into a total information center that updates automatically. It's elegant.

- W.H.

First, I want to say that your program is probably the finest piece of work I have ever seen. The depth is simply amazing. Congratulations and thanks.

- D.B.

Thanx, Leo.  You're a great sport.  By the way, partially because of the application of xlq in my screen, I have passed 30% up in the market this year!!!!

- B.H.

This is a wonderful product -- simple to use and just plain useful!

- C.B.

I want to say you have created THE ULTIMATE data interface software for traders like me who prefer to use Excel for everything. Thanks a bunch.

- M.Y.

I just wanted to say, that I very much like your xlq package. I have tried many similar products and this is by far the best I have come across. Simple, fuss-free setup, integrates well with Excel, and has its own stand alone interface to track your portfolio throughout the day. Since I am from Europe, and trade US, European and Japanese securities, the ability to use a variety of feeds simultaneously and transparently is particularly valuable to me.

- H.S.

I really appreciate your quick responses. And your program is terrific. The Plus version adds a lot with it‘s AAII interface. I’ll definitely register it since in the last week it has become an indispensable part of my stock analysis.

- R.S.

I found XLQ yesterday afternoon – and I am blown away by how useful it is. You really need to market this thing because it is AWESOME!!!

- D.B.

Your explanation was very good. I understand now and find it very useful. If you always reply so quickly to questions, I will have to believe that you supply the best and fastest support of any software company.

- D.H.

I have “dabbled” for several years creating many of the things you present in this great program. I first began using the “*.iqy” external query (update times horrendous), then Excel VBA and lately attempting to learn “C” or “C++” in order to have smoother, faster updates as well as a great appearing “front end”. Your program certainly is, by far, the leader and has the greater edge over any I have seen, or tried to accomplish. Thank you for such a great program.

- R.H.

You are a very special person to reply so quickly and I want to thank you again. I enjoy your program. It gives me everything I need, and I know there is so much more functionality that I'm not even exploiting.

- F.D.

I love your program. XLQ combined with the power of Excel brings limitless possibilities to manipulate data for better trading. I recommend it to everyone I know interested in trading.

- P.S.

Thanks for such a great program. I have no programming experience and was trying to find a way to do just what you have done. Only you did much more. It’s fantastic and reasonably priced too!

- D.T.

Thank you so much for your help and your phenomenal programming. XLQ is awesome.

- T.K.

I use your XLQ product all the time. Some of the best money I've ever spent on software.

- L.S.

First, a thank you for the excellent and useful adjunct to EXCEL. I seem to discover a new use every day – and I’m sure I haven’t even scratched the surface to utilize XLQ’s full potential. The new version is really great.

- W.H.

First let me say that I feel XLQ is terrific. I really appreciate the versatility you have made possible with this package. I have set up a few worksheets and find it easy to learn and use with the aid of the included demo sheets. This application has the potential in my opinion to be unmatched in power, efficiency and productivity.

- C.A.

Your software is on its way to becoming the only window that I need to the market’s numbers. With the ability to arrange thing EXACTLY the way I want them, and the use of conditional formatting to trigger alarms and display changes to suit my needs, I am gradually replacing all of the other market tools I’ve been using. I can’t be a more enthusiastic supporter of what you are doing. Thanks.

- W.G.

I'm wowed by your software!! I used to enter data in my spreadsheet for two hours for each update, and therefore only did it once or twice a week. Now I do it with the close each day - in about 30 seconds!!! And I've added some data points to help with my analysis that I just could not manage to maintain before. Thanks again for a great program, a great deal, and great support!!!!!

- R.K.

Your software is great. I'm hooked on the info I can generate for stock purchasing and selling using your program. In two weeks I've become an XLQ junkie.

- V.D.

Please let me tell you how much I have come to depend on XLQ in a short period. This is a great product!! You have made my job significantly more streamlined, and my tasks simpler and more elegant. Many, many thanks!

- L.D.

I have been evaluating XLQ for the past few weeks and am thoroughly impressed with the product. It is versatile, easy to use, accurate and very intuitive. It is a real bargain compared to competitive products plus it runs right from within Excel. Based on this I just entered my purchase order.

- M.M.

I ADORE your program. It has really helped me to learn about how the markets work, and building my own system indicator by indicator is the best way to learn.

- B.K.

Leo: count me as a satisfied customer. I gave it a good workout for a month, decided to buy it when it saved me 5 hours of administration the first week, and helped me do some studies I had been postponing for months due to slow data retrieval. Your product is smooth, fast and elegant with a very clean presentation. Well done!

- K.L.

The more I work with XLQ, the more I like it. It is fast! And so rich... I like it so much I have decided to adopt it as my #1 tool for the long term.

- S.C.

Thanks very much for writing XLQ - I like it very much as it gives me the opportunity to manipulate data as I want without a very steep learning curve.

- T.B.

I just downloaded a trial of XLQ and have been "playing" with it for hours. I am so impressed. I wish I would have known about your program years ago.

- D.F.

I just purchased your software and think it is the next best thing since the spreadsheet.

- R.D.

Thanks for the best (and least complicated) investing software out there!!

- F.B.

Your software is simply brilliant, for the last week that I have been trying it, I have been impressed no end.

- G.R.

Thanks, Xlq is a great piece of software, its actually saving me a heap of time and time is the precious commodity in these hectic days.

- J.P.

The XLQ interface with Excel is excellent. I have been waiting for this capability for years.

- H.A.

Please accept my thanks for your wonderful product - it is a pleasure to use.

- D.L.

Your software is just what I have needed. It provides me with the capability to customize data and construct charts which give me the views I like - not just what someone thinks I would like.

- D.E.

Firstly, let me say that the philosophy and idea behind XLQ is exactly what I am looking for.

- S.P.

The more I use XLQ the more I appreciate what can be done with it.

- S.M.

Just like to say, excellent work. A potentially good bit of software for me.

- M.C.

I love your product so far. ... Thank you for making such product available.

- A.T.

Thanks for the Tip. You know, your program is really super.

- P.B.

Great software! Simple, elegant, well-thought-out and fast.

- R.M.

I am always finding new ways to use your program in my investment / speculative Market endeavors.

- S.S

Thanks for such a wonderful product. It certainly does handle my most precious need which is to monitor the market realtime..

- W.B

It is a pleasure doing business with such a responsive person who obviously understands the value of good customer service. I have just registered and intend to make good use of this program.

- E.D.

Your fast and thorough answer is more than what I expected. Your service is awesome and your product is very stable. Keep up with your good work. Sincerely appreciated :)

- V.P.

Just a note to let you know that I really like you software. It's a wonderful interface that has been of great utility to me.

- J.B.

Join the XLQ2 Users Group

Books

xlq2 has been recommended in the following:

Definitive Guide to Position Sizing

Van Tharp

Paul King's book, on pmkingtrading.com

Paul King