What is the best trading API for Matlab? MBtrading? IB?

(Last Updated On: April 30, 2012)

What is the best trading API for Matlab? MBtrading? IB?


Why do you need a trading API for matlab?



Matlab typically has faster development turnarounds, and in some cases we have noticed the matrix math is so heavily optimized that it runs faster than C/C++. Also the GPU support for Matlab makes GPU development more rapid as well. Then like it was said there are many mathematical tools available: robust control, metaheuristics, custom plotting, etc…


I am sure you can use matlab’s API to implement it’s functions in your software. That should be more comfortable for trading I think.


It depends from speed required and some other stuff! For example i prefer to’ develop something in matlab and then exporting it as a library (jar o what else).


I have used Matlab’s code gen feature to generate C/C++ code but noticed my pinv function ran slower than it did in Matlab. When I contact Mathworks they said it was slower because Matlab uses the heavily optimized LAPACK libraries which are not export to C/C++. So Ivan have you noticed any speed decreases in your jar files? I know there is an interactive broker API for Matlab, but I was hoping to find a better FOREX broker to auto trade. The big draw for my inside Matlab is the easy of GPU coding.



if you are definitely looking for speed you need to have ultra fast modules for other things, like risk management, transport, monitoring and so on. And this would be quite difficult to do with matlab at ultra fast speeds. About what speeds are we talking?


Anyway, you can always write your own API to any broker or infrastructure provider


Just a quick warning. MATLABs martrix modules may be fast, but nothing else is. I haven’t sorted out if you are using this for High Frequency trading or more traditional analysis and trade placement. If you are intending to use this for even moderate HFT I would stay away from the final implementation being in MATLAB, even exporting MATLAB modules and incorporating them in C++ or C# projects is a bad idea.

A MATLAB interface could be convenient in an Analyse & Trade scenario, but MATLAB falls apart very quickly in any form of data feed and HFT scenario. It just doesn’t handle streaming data very well at all. The memory management in MATLAB is poor and I have also seen lots of times it just stops reacting to incoming data for long periods. MATLAB is an interpreted layer over Java and sometimes C/C++. It was designed for rapidly implementing mathematical ideas and not deterministic on the fly data processing.

MATLAB is outstanding for rapidly prototyping analysis ideas, but that is truly all it is good at. I would highly recommend that you use either C++ or C# for the live trading system work.

This is from my last 10 years trying to do exactly what you are talking about. Just my 2 cents and I hope it helps.


Poor guy: he wanted a suggestion about brokers and we are talking about everything else.

I used matlab as Java library and i was satisfied about speed and memory.
Maybe it depends from what kind of matlab tools are used: i used filters, clustering working with oo phylosophy.



maybe it is because not many who uses matlab for direct trading?)


I agree, if you’re looking for ultre speed, Matlab is not what you need.


Recently I am trading with Matlab via API. My reasons to choose matlab is, first, easy development; second, easy math lib. There are many drawbacks, such as speed, single thread,


so how does one easily treat tick by tick data in matlab. the fints only handles minute data. let’s say you have micro second data or there any tools to help


Back to the broker question. IB will have better pricing, but they also force you to manually log in every night. That is tough for an automated trading system. Since they will disconnect you, if you are not there to log in your system is no longer connected. This may be okay for a US stock market program, but if you are trading any 24 hour market like currencies, it is not advisable.



Interactive broker also provides IB Gateway, which keeps you connected all the time. This may resolve your concern.


I am using Matlab in conjunction with Quant2IB as an interface to IB. This works well for trading on one minute intervals.


NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!

Subscribe For Latest Updates

Sign up to best of business news, informed analysis and opinions on what matters to you.
Invalid email address
We promise not to spam you. You can unsubscribe at any time.


Check NEW site on stock forex and ETF analysis and automation

Scroll to Top