Integrating Matlab/Java/QuickFIX


3 0

Long post coming. I’m looking at a solution to execute trading strategies I have in Matlab. I’m considering some options and I would appreciate some feedback on them. I have put the underlying history data in a MySQL database that I load from Matlab or into Java.

The ideal situation for me is to have the data in MySQL, have everything related to the strategies in Matlab and have Java do the execution through QuickFIX/J, giving me maximum control over the important connection to my prime broker (who uses FIX interface). This is not HFT and I only trade a few times a day, an execution latency of 100-250ms is not of concern.

These are some potential solutions I’ve come up with:

1. Use Matlab for prototyping only and then implement each strategy in Java, both using the common underlying database. This is certainly the most straight-forward solution but becomes really bad if you use any components in Matlab that are not directly available in Java.

2. Use Matlab for both strategies and execution. I have several problems with this. First I have to use a third-party package that I’m uncertain of how well tested it is and furthermore I feel more comfortable with Java handling the execution part. QuickFIX/J has even been recommended by the electronic trading services at my prime broker.

3. Use Matlab as a sort of server that Java queries from time to time (meaning that the controlling process would be Java). I like this option the most but I’m not sure of how to interact the components. Java would be sending inputs such as real-time market data and Matlab would output orders in stocks. Matlab has some startup-time (and data loading time in strategy) so it would be best if the Matlab process was continuously running. Otherwise Java could just start the entire strategy, have it output a file and Java reads the files…
Any recommendation on how such communication could work?

I’d love to hear how others have solved this problem.



Well-known member
257 9
I gave up with integrating matlab into my java program, you can program in c++ and use sockets to utilize matlab in any way you want but it is more time consuming than I could handle. I ended up doing it all in java and then serving web pages from a php server integrated with SQL for the data. Now I actually store all my data in custom built array packages and don't use SQL anymore because it is more streamlined and easier for me to manage. I build the graphics with php and the backend is java and c++. Fast enough and rock solid. I only scan around 500 stocks a day. It takes my program about an hour and I cycle daily 250 bars of my stocks through 100 meg of logic conditionals.

Guess what I really mean to say is that you should do what works easiest. Computers these days are crazy fast no matter what language or DB you use, also the formulas available in matlab are reproducible in any common programming language.

Good luck


3 0
Thanks for sharing.

Luckily the first strategy is rather simple to implement in java so the first production system will be completely java only. The strategy will look at a few hundred stocks as near closing time as possible and enter orders at that point (overnight strategy). I have all my underlying historical data in mysql, get real-time feeds from third party, use apache common math for the actual strategy building block and use Quickfix/J for executing the orders.

In the longer run though I will look for a better solution where matlab acts as a "strategy server" which java can query. I've used matlab for a long time now through school and after and I must say I am surprised about how bad it is at integrating with external components.


Established member
566 165
Option 3 seems to be the best.

this way you can replace Matlab at a later stage without impacting the core components of your system
AdBlock Detected

We get it, advertisements are annoying!

But it's thanks to our sponsors that access to Trade2Win remains free for all. By viewing our ads you help us pay our bills, so please support the site and disable your AdBlocker.

I've Disabled AdBlock