London Trading Group

London's Leading Trading Academy

Register now to get access to your free content.

No experience needed. We only show you what works.


Should a Quant Use R or MATLAB?

By 30th April 2019 News No Comments

If you really want to start a war in the quantitative finance world, just go to a group of quant developers and say,

“I am new in this, what programming language should I learn?”

The argument would never end—and you would get no useful answers.

A very easy way to solve the problem would be to learn all of them. However, because time is a limited resource, we all want to know where we should primarily focus our valuable time and attention.

Years ago, if you could buy it, MATLAB, was simply the best way to go.

It has always been very easy to use, it has a superb user-friendly interface, and when it comes to dealing with simple tasks, it is as easy as Excel.

Thanks to MATLAB tools, a task like pricing an option under stochastic volatility assumptions, or modelling a financial time series, was easily doable—although the word easy should be banned in this industry. The amazing thing that only MATLAB offers is a complete, well-written guide that allows almost anyone to price-fix their income just from reading the provided material.

And if that’s not enough, their call center is staffed by people with serious knowledge who sometimes know about these topics more than you! (Not more than me, “than you,” I said!)

So, if MATLAB is so good, why are we even talking about other programming languages?

The reason can be summed up in just one word: Price.

MATLAB is crazy expensive. With a few packages, a commercial license could easily cost $6,000 USD!!! In contrast, R or Python costs $0 USD! 😊

The high price is the only reason—I believe—many academic researchers have always tried to find a less expensive or free alternative.

You might think that hedge funds and asset managers in banks don’t really care about a few thousand pounds for a software license because of the amount of money involved in this industry. Actually, this can lead to a potentially better analysis of the options because they care very much!

Imagine, a big bank with 1000 developers could spend many millions just in MATLAB licenses alone.

You should now be broadly convinced that money, in this case, is a problem for large institutions and academics users alike – especially when there are free alternatives in the market. Even more so when the more people use this alternative, the better it becomes!!!

This is where the magic starts.

R was just a sort of version of MATLAB for those on a budget. Being open source, everyone could build their own package and functions without any supervision. As a result, if you were trying to implement a model using a function written by an anonymous developer and there was a bug, no one would be there to help you. You were stacked and forced to go back to the expensive MATLAB, calling their call center promising that you won’t cheat on them again!

Today, things have changed a lot. So many universities and big institutions have taken an interest in R and making it work. Packages have been written and updated by famous researchers and professors and some of the guides are pretty good. Rugarch, for example, is an excellent time series modelling guide that is probably better than most of the textbooks available on the same topic.

And it is so broadly used that if there were a new discovery in the quant world, you would find R code, or, if necessary, a new R package just for it.

MATLAB cannot keep up with this anymore. R now has an army of thousands and thousands of professionals. The number of packages available in the cran repository is approximately 10,000.

It’s help files are finally well written, and most of the papers on quantitative topics are now written on R or Python.

The R interface is still less user-friendly than that of MATLAB. For example, if you open R studio and MATLAB on two different screens, it is self-evident that one is free and the other is expensive.

The learning curve for R is also steeper, but there is just no choice if you want to stay updated on what is happening in the quant world. R or Python are the only way to go because some products, such as programming languages, get their value from the number of people using it.

It is like Windows; whether you like it or not, you must use it, because everybody does it.

For a programming language, this is even more true.

Think about the English language; people need to study it in order to live well in the modern world because it is used worldwide.

The question then should be:

what is the most commonly used programming language for quant application, rather than which is the best?

If you don’t want to learn R because it is slow and not user-friendly, you won’t be able to study the next 1000 papers, and you’ll be left behind.

Another reason that was used in the past to convince you to stick with MATLAB was that it is much faster than R, which is still very true. However, currently, this does not matter. First of all, computational power is no longer a limited, precious resource, which it used to be many years ago. On my Alienware laptop, I can handle most of the simulation in relatively decent time. And don’t forget that while both R and MATLAB are languages that quants use to build models, when everything is ready to go, a knowledge able C programmer would convert it to a low-level language that would do the job in a microsecond.

Computational time is still very important when dealing with real-time data, as a delay of a microsecond can cost money. However, in this case, both R and MATLAB are way too slow to be used.

You might be wondering why I am not discussing Python? It is primarily because this article would be far too long, and I should not go beyond 1000 words. But it is also because even if Python can be used to do almost the same as can be done with R, I won’t put it in direct comparison with MATLAB because it has a broader usage.

When dealing with financial engineering, R is a MATLAB clone. Even the layout of R studio looks almost the same as that of MATLAB.

Python is a much broader programing language that is used to do many applications.

I have also noticed that, lately, financial time series modelling and derivatives pricing are using R more often than Python.

It does not really matter how much you prefer MATLAB over R – I am one of you. People are using R, and we must all convert and let go of the good old times.

It is simple and a bit painful, but it is necessary.