Beyond Excel – MATLAB
April 24, 2012 Leave a comment
Many financial analysts develop models using Excel; it is easy, flexible and powerful. However, as time goes by, some of these models become sophisticated, unstable or take forever to run. These models have reached Excel’s limits and it may be time to migrate the models to a more flexible and powerful tool, i.e. MATLAB.
What is MATLAB?
Just like Excel, MATLAB has its own financial functions, development environment, and high level programming language but you will soon find out MATLAB is much more advanced; it allow us to develop more challenging financial models in a more effective manner.
Financial Libraries
Excel 2010 only has about 50 simple financial functions but MATLAB provides a huge set of financial libraries:
- Financial Toolbox – estimate risk, analyze interest rate levels, price equity and interest rate derivatives, and measure investment performance
- Financial Derivatives Toolbox – analyze and model equity and fixed-income derivatives and securities contingent on interest rates
- Fixed-Income Toolbox – calculate price, rates, and sensitivities for interest rate swaps, credit default swaps, bond futures, and convertible bonds
- Econometric Toolbox – provides Monte Carlo methods for simulating systems of linear and nonlinear stochastic differential equations.
These MATLAB toolboxes can handle very demanding financial models, e.g. asset allocation, cash flow analysis, portfolio optimization, credit default swap valuation, or using the GARCH, Heath-Jarrow-Morton, Black-Derman-Toy, or Black-Karasinski models to price assets or measure interest rate sensitivity. This is just the tip of iceberg.
However, the most important feature is that MATLAB gives us the source code so we can customize it according to our own requirements. Instead of building the financial models from scratch, we can jump start using existing MATALB functions. How quick we can build a model on Excel to calculate option-adjusted spread? Days? Weeks?
High Performance Computing (HPC)
Have you tried to run stochastic models on Excel? It would take you days, weeks or even months to process; this is why Microsoft come up with HPC Services for Excel. However, it requires expensive server hardware / software and special cluster safe functions.
MATLAB’s answer to HPC is much simpler and more powerful. it has 2 different toolboxes to handle the most demanding models:
- Parallel Computing Toolbox – solve computationally and data-intensive problems using multicore processors, and GPUs (a.k.a. video card)
- Distributed Computing Server – scale up to many computers by running models on MATLAB Distributed Computing Server.
We don’t need expensive server infrastructure; I managed to increase my model’s performance by nearly 350% on my Dell quad core desktop and over 6 times with a $300 video card. If I need significant more power, I can upload my model to Amazon Elastic Compute Cloud (Amazon EC2) – Cluster GPU. It is much easier to scale up the performance in MATLAB.
And even with single core, MATLAB can process much faster than VBA because MATLAB supports native matrix manipulation.
And more…
Apart from financial libraries, MATLAB also has other advanced mathematical and statistical packages. It supports object oriented programming language and we can use its profiler to identify where the bottleneck is. We can deploy our models to other environments, e.g. Java, .NET and even Excel. It is also very easy to use.
The bottom line is if your financial models have reached Excel’s limit and you are looking for something beyond Excel, then you would find MATLAB a very good alternative!