IB-Matlab documentation

Documentation

Click to view the Realtime Trading in Matlab presentation webinar video

Click to view the presentation webinar video

Usage syntax

Click to view the full IB-Matlab User Guide (PDF)

Click to view the IB-Matlab User Guide (PDF)

Multiple usage examples are provided here; many more examples and detailed information are available in the IB-Matlab User Guide.

The general syntax (quick help reference; detailed user guide) is:

[orderId,ibConnectionObject,contract,order] = IBMatlab(varargin)

Possible inputs parameters:

  • varargin = Matlab struct or fieldname/value pairs with the following optional fields:
  • Connection: ClientId, Host, Port, AccountName
  • Contract data: Symbol, LocalSymbol, SecType, Exchange, Currency, Multiplier, Expiry, Strike, Right
  • Action: one of Buy, Sell, SShort, Close, Exercise, Lapse, Query, Cancel, Account, Portfolio, History, Realtime, Scanner, Contract, Fundamental, License, or Version
  • Query type: either OPEN [for the list of open orders], or EXECUTIONS [for the list of today’s executions]
  • Order type: one of MKT, MKTCLS, LMT, LMTCLS, PEGMKT, STP, STPLMT, MIT, TRAIL, REL, TWAP, VWAP, GuarranteedVWAP, TRAILLIMIT, etc. – see full list here and detailed explanations here; note that IB prevents some combinations of orders and securities
  • Order data: Action, Quantity, TIF, LimitPrice, AuxPrice, OCAGroup, ParentId, TrailingPercent, TrailStopPrice, GoodAfterTime, GoodTillDate, BracketDelta, BracketTypes, TriggerMethod, OutsideRTH, OrderId, Hold, Timeout, HedgeType, HedgeParam
  • TWAP/VWAP order data: StrategyType, MaxPctVol, StartTime, EndTime, AllowPastEndTime, NoTakeLiq
  • Combo order data: ComboActions, ComboRatios, ComboBagSymbol
  • Automated order data: LimitBasis, LimitDelta, LimitRepeatEvery, LimitUpdateMode, LimitChangeTime, LimitChangeType, Tick
  • Historic/intra-day data: EndDateTime, DurationValue, DurationUnits, BarSize, WhatToShow, UseRTH, FormatDate, IncludeExpired (note IB’s pace limitations)
  • Streaming quotes data: QuotesNumber, QuotesBufferSize, ReconnectEvery, GenericTickList
  • Market depth (order book) data: NumberOfRows, QuotesNumber
  • Scanner parameters: Type, ParametersType, AbovePrice, AboveVolume, AverageOptionVolumeAbove, BelowPrice, CouponRateAbove, CouponRateBelow, ExcludeConvertible, Instrument, LocationCode, MarketCapAbove, MarketCapBelow, MaturityDateAbove, MaturityDateBelow, MoodyRatingAbove, MoodyRatingBelow, NumberOfRows, ScanCode, ScannerSettingPairs, SPRatingAbove, SPRatingBelow, StockTypeFilter
  • Financial advisors: FAProfile, FAGroup, FAMethod, FAPercentage
  • Event callbacks: CallbackFunction, CallbackAccountDownloadEnd, CallbackAccountSummary, CallbackAccountSummaryEnd, CallbackBondContractDetails, CallbackCommissionReport, CallbackConnectionClosed, CallbackContractDetails, CallbackContractDetailsEnd, CallbackCurrentTime, CallbackDeltaNeutralValidation, CallbackExecDetails, CallbackExecDetailsEnd, CallbackFundamentalData, CallbackHistoricalData, CallbackManagedAccounts, CallbackMarketDataType, CallbackMessage, CallbackNextValidId, CallbackOpenOrder, CallbackOpenOrderEnd, CallbackOrderStatus, CallbackPosition, CallbackPositionEnd, CallbackTickPrice, CallbackTickSize, CallbackTickString, CallbackTickGeneric, CallbackTickEFP, CallbackTickOptionComputation, CallbackTickSnapshotEnd, CallbackRealtimeBar, CallbackReceiveFA, CallbackScannerData, CallbackScannerDataEnd, CallbackScannerParameters, CallbackUpdateAccountTime, CallbackUpdateAccountValue, CallbackUpdateMktDepth, CallbackUpdateMktDepthL2, CallbackUpdateNewsBulletin, CallbackUpdatePortfolio
  • General: LogFileName, MsgDisplayLevel

IB-Matlab free trial

Outputs:

  • orderId = -1 if unsuccessful, otherwise the ID of the placed order, or data for ‘QUERY’ actions
  • ibConnectionObject = reference of Java object that interfaces with IB
  • contract = object that holds contract info for Buy/Sell actions when Hold=1 (see example 10 below)
  • order = object that holds order info for Buy/Sell actions when Hold=1 (see example 10 below)

Usage examples

Representative usage examples of IB-Matlab are available here. The following examples are available:

  1. Buy a security
  2. Sell a security
  3. Get portfolio data
  4. Get account data
  5. Get market data (snapshot) for a security
  6. Get historic/intra-day data
  7. Get streaming quotes data
  8. Get realtime bars data
  9. Get detailed contract information
  10. Get options-chain information
  11. Get scanner filter data
  12. Access, modify and cancel open orders
  13. Get executions data
  14. Specify event callback – ExecDetails
  15. Specify event callback – TickGeneric
  16. Use the underlying Java connector to cancel or customize an order

Many more examples and detailed information are available in the IB-Matlab User Guide. Contact us if you have any questions.

Professional reviews

AutomatedTrader magazineSo, do we like it? Well, IB-MATLAB is robust, very easy to learn how to use and does exactly what it claims to do – namely provide a simple and efficient order interface between MATLAB and Interactive Brokers’ API. It also costs peanuts…
So yes, we like it – a lot.

– Andy Webb, Automated Trader magazine, Q3 2011 (“The Virtue of Simplicity” article online; or downloadable PDF)

All told, we regarded the enhancements to IB-MATLAB since we last reviewed it as significant. The order submission process was rock solid as before, but the new capabilities really open up the possibilities – especially for trading that is analytically intensive but not high frequency. We were able to deploy multiple models in real time to IB’s trading platform without any difficulties or glitches. …
IB-MATLAB effectively contradicts the declaration we’ve seen on more than a few web sites that “MATLAB is not for real time trading”.

– Andy Webb, Automated Trader magazine, Q1 2012 (“Mashup!” article online; or downloadable PDF)

Click to view the Algorithmic Trading System presentation video

Click to view the presentation video

Easy integration with IB through IB-Matlab… The * Toolbox isn’t very robust, it’s really buggy, … I would love to get the * Toolbox up and running, but I think that Yair has got it covered for Interactive Brokers, I just use his program…
IB-Matlab is our wrapper for the IB API, so that we don’t have to write our own Java connector. IB-Matlab is a robust Java connector, complete wrapper for the IB API. A cheap investment, it’s definitely worth it. I can’t even stress enough how much time it will save you. Don’t build from scratch, it is cheaper and faster to buy from 3rd-party vendors. If I was to build IB-Matlab it would take me several weeks and for only $400 I could have a turnkey solution, I mean it’s a no-brainer there… It’s better than those retail trading platforms. This is the cheapest professional-grade system that you can get. IB connected to IB-Matlab connected to Matlab connected to the Data-Feed Toolbox connected to IQFeed is the cheapest technology stack that will give you trading robustness.
Yair is extremely helpful, provides great customer support.

– Chris Reeves, A2X Capital, Feb 27, 2015 (“Algorithmic Trading System” video)

Also quoted: IB-Matlab is the most robust wrapper for the IB API I have come across. Amazing value for the price!

– creeves, Feb 23, 2015 (comment posted about IB-Matlab on IB’s Marketplace)

…At that point I turned to Yair Altman’s IB-Matlab product. Happily, this uses IB’s Java api, which is a great deal more robust than the ActiveX platform. It’s been some time since I last used IB-Matlab and was pleased to see that Yair has been very busy over the intervening period, building the capabilities of the system and providing very comprehensive documentation for it. With Yair’s help, it took me no time at all to get up and running and within a day or two the system was executing orders flawlessly in IB’s TWS. …
Yair is very generous with his time in providing support to his users and his responses to my questions were fast and detailed.

– Jonathan Kinlay, Quantitative Research and Trading, March 5, 2015 (“Algorithmic trading” article)

User testimonials

Click to view the IB Marketplace

Click to view the IB Marketplace

81 reviews

IB-Matlab free trial

The following testimonials appear on IB’s Marketplace, where IB-Matlab is the top-rated product, with a perfect score of 5.000 stars from dozens of traders:

  • “Great product that is very stable. The docs are excellent with many examples. Support is top notch as Yair responds quickly to questions.” – cbmitch
  • “Truly solid product. Easy to work with and has all the functionality to smoothly execute our trading, we have not had a single issue with it.” – STCMF
  • “This is an excellent product that gives extremely deep access to all the capabilities of IB. Surprisingly easy to use as well!” – jones13
  • “Super useful and stable. Yair is very responsive!” – travlake
  • “very usable, easily programmable (for the most part). Robust.” – fluffpin
  • “An excellent product with a detailed user guide. Quick and detailed support by its developer, Yair, an expert Matlab practitioner. Highly recommended.” – T_R
  • “Rarely are the claims of a developer so understated. The software is simply a “must have” for IB development within Matlab. Thanks to Yair.” – kvargas
  • “You should charge more for it. Best value for your money. No bugs. Detailed user-guide contains concise explanations. Easy to use and amazing support.” – Constant
  • “This software is a MUST. 15 days trial, EXCELLENT documentation, top notch support, the API is world class design, CHEAP! easy and yet powerful.” – bayes
  • “Very quick response. Support is unparalleled professional quality. Software works great, definitely an easy-to-use tool for making money.” – CLVoting
  • “Yair’s API is the best and Yair’s help, support and response time is enviable for any service provider.” – m1chael2
  • “High quality software with prompt and stable support with user guide details the relevant information for API operations” – ccjasia
  • “Highly competent, professional, quick turnaround, in-depth understanding of electronic market micro-structure” – sgoyvote
  • “The software works flawlessly and the support from Yair is unparalleled. Without a doubt worth purchasing.” – asselall
  • “Super. Wasted too much time trying other solutions eg. trading toolbox. IB-Matlab is the way to go. Robust, logical and very well documented.” – jt1010
  • “Excellent connector for MatLab. We evaluated it against the Mathworks product and found Yair’s version far better. We use it on a daily basis.” – AP1234
  • “Great software – very helpful to implement own strategies. Comprehensive and easy to use interface to the API. Yair is very responsive and helpful!” – quantD
  • “Saved me a lot of time realizing some extra tools and automation for my trading. Very robust and easy to use! Can only recommend!” – MartinMM
  • “Excellent software, easy to use and follow documentation, highly recommend. Yair is extremely responsive and eager to solve all the things you need.” – cheers
  • “Code works and is easy to install and interface with in Matlab. Code is well documented as well.” – ericdonn
  • “Highly recommended product. Easy to use, robust, inexpensive, quick and quality support from the developer. High value product for the money.” – scap
  • “Amazing interface! Prompt replies to emails. Robust connector, no issues faced yet. Will certainly recommend to anyone looking to use MATLAB with IB.” – harjas
  • “Highly recommend for anyone doing automated trading. The IB interface routines are very easy to learn and integrate. Powerful combination with Matlab.” – ber7t
  • “Very good product. Easy to follow documentation. Yair is very quick on email. Highly recommended to anyone looking for an IB to Matlab connection.” – even
  • “IB-Matlab is excellent. The connection is robust, the documentation is comprehensive and well written, and Yair is very helpful.” – Markmaj
  • “We hired Yair to write some functions for our prop-shop. Got excellent help within 10 hours and he is eager to solve all the things you need.” – johlof
  • “Clean application that nicely bridges the gap between Matlab and IB. Helpful service when you need it. Everything works as expected.” – johnd
  • “Easy to use. Very comprehensive user guide. Great support from the founder” – EAfb
  • “Robust!! Quick turnaround service!” – Anon
  • “IBMatlab has allowed me to accelerate project development by many months and comes with great product support.” – james_r
  • “Everyone should buy it. Price is reasonable. I have been using it for three years.” – flash201
  • “System has worked flawlessly for the past year. Yair is extremely responsive (I’m not sure when he sleeps) and helpful. Excellent value.” – billj
  • “IB-Matlab is the most robust wrapper for the IB API I have come across. Amazing value for the price!!” – creeves
  • “IBMatlab has been invaluable to test trading strategies; it is reliable and includes lots of useful functions. Yair is very responsive and helpful.” – algo1410
  • “Excellent software – I’ve been looking for something like this for almost a year now. 5/5” – sysdo
  • “Yair has made a great product and offers valuable support. Good for risk management and data analysis tools and recommend it.” – mkrause
  • “IB-Matlab is an excellent product. It is very solid and Yair is very quick in responding to inquiries. Strongly recommend it !” – FinLab
  • “Support is prompt. Easy to use. Speed is not as quick as I thought. Anyway, it might be due to delay from IB.” – JeffKoh
  • “IB-Matlab provides an excellent range of tools for automated trading systems. Support excellent and prompt. 100% stable in live operation.” – sunbear6
  • “I’ve been using it for over a year and I have no complaints. It is robust and does what it is supposed to do. Very quick customer service.” – hank99
  • “Very helpful interactive link to TWS. Saves hundreds of man-hours in developing custom features.” – cekaulII
  • “I find it quite reliable and easy to use. I was able to code a real time automatic trading system relatively easily. The service behind is excellent.” – khalfina
  • “I have been using IB-Matlab for almost 3 years and have found it to work perfectly. Yair responds promptly to questions with detailed answers.” – kChuck
  • “Amazing product. Running it for last one month. Stable. No instance of breakdown. Mr. Altman is very quick in response time. Highly recommended.” – sujitm
  • “IBMatlab is a very convenient way to access IB’s API. The documentation is comprehensive and it is easy to integrate the software into MATLAB code.” – prateek1
  • “Excellent product, top-notch tech support.” – nobull
  • “Excellent knowledge on Matlab, Java and IB – perfect for automated trading. It was a real joy and I will work with them again.” – human123
  • “Excellent software product, customer support and seamless integration. Totally reliable and a superb addition for automated trading.” – gazza75
  • “This product is reliable and well documented. The creator is always quick to respond and helpful.” – MacKG
  • “I have been using IB-Matlab for three months now and it has been flawless. Great value.” – wajv
  • “IB-Matlab is an easy to use end-to-end solution for Matlab users.” – BenTam
  • “Excellent. Saves $1600 from Mathworks’ built-in solution.” – muller
  • “A quality product at a good price. I find it to work better and in a more flexible way than Matlab’s own IB toolbox.” – Vasastan
  • “IB-Matlab allows me to perform fully automated trading, using my own developed code. Yair’s support is very professional. I highly recommend it.” – wimvwijn
  • “IB-Matlab is a tremendous product. The documentation is outstanding and Yair is INCREDIBLY responsive to any questions or issues which arise.” – wgpCap
  • “I found Yair Altman readily reachable when I have questions and the product has performed well.” – hwshiau
  • “IB-Matlab lets you harness the depth and efficiency of MATLAB! It’s intuitive, robust, full-featured, and affordable. Great documentation and support.” – JTrade
  • “IBMatlab is a professional Matlab TWS API interface. It works very reliable and is easy to use. The support is very client focused and supportive.” – drepl
  • “Excellent product, responsive support and very useful examples/documentation to get you up and running without much work. Highly recommend!” – CharlesM
  • “Robust product, user-friendly, hard to say no with the price and level of support. Highly recommended.” – stephenw
  • “Great product! Stable platform, very flexible, great support, and easily scaled to implement any automated trading strategy. Well worth the money!” – BenM
  • “Worth every dime and excellent support. The possibilities with the combination Matlab/IB seem limitless. The resulting mac system is extremely stable.” – onmac
  • “Great product that allows one to utilize the power and flexibility of Matlab to create automated systems.” – jbusse00
  • “Good product (IBMatlab): Good range of functionality, Good performance, Good documentation and very good support from Yair.” – unbroken
  • “As a former control system engineer, I used MATLAB. I was very excited to hear about IBMatlab. IBMatlab works! Highly recommend!” – kiscl

All these quotes are from real IB traders, who took the time to comment about IB-Matlab on IB’s website. Numerous other traders have provided similar statements by email.

In addition to the quoted testimonials above, all of whom rated IB-Matlab with a perfect 5-star rating, about a dozen other traders have also voted IB-Matlab with 5 stars, without attaching a comment. Not even a single trader has voted Matlab with a lower vote. This perfect score of 5.000 stars from dozens of traders is unparalleled by any other program on the IB Marketplace. We take great pride in providing a great product, fantastic value, and excellent customer service.

Free trial version

A fully-functional free trial version is available – just request your trial and you will get a no-obligations copy with detailed installation and usage instructions.

There are absolutely no strings attached: the trial is completely free and fully functional, just limited in duration.

You only need the basic Matlab, no toolbox is required. You can be up and running within minutes. We are confident that you will love the product, so we encourage you to test it:
IB-Matlab connectivity (Matlab and TWS may be on separate computers)

You will receive the trial installation instructions to your specified email within 24 hours. If you do not get an email within 24 hours, then please check your email’s spam folder, or send a direct email to altmany at gmail.com

 Contact us

Comments are closed.