codefinance.training

Coding for Finance

Interview with Jörg Kienitz on Financial Modelling with MATLAB

Interview with Jörg Kienitz on Financial Modelling with MATLAB

Financial Modelling: Theory, Implementation and Practice with MATLAB Source cover

In this extended interview Jacob Bettany talks to Jörg Kienitz, co-author with Daniel Wetterau of Financial Modelling: Theory, Implementation and Practice with MATLAB Source. They discuss the book and talk about the state of Computational Finance as it was back in 2013.

Financial Modelling: Theory, Implementation and Practice with MATLAB Source was published by ‎Wiley on 21 September 2012. Learn More

Jacob Bettany:  Thank you very much for joining us Jörg. Could you begin by telling us a little bit about yourself and your colleague Daniel Wetterau?

Jörg Kienitz: Yes, thank you Jacob. I have a mathematical background, I studied Math and obtained a Ph.D. in Mathematics that was mainly in the areas of complex analysis, probability theory and stochastic analysis. After finishing my studies I started as a financial consultant in the end of 2000 at Reuters and there I had my first contact with the financial industry. Later on I moved to Postbank Systems where I had an IT role, as a Senior System Architect, and finally I got my role in Deutsche Postbank AG, where I am now head of Quantitative Analytics in the treasury department. My collaborator Mr Wetterau is also employed by Deutsche Postbank AG, he works in my team and he is also a mathematician with a background in mathematics and economics.

JB: You write that the goal of the book is to fill a gap in the literature on financial modelling, would you mind explaining that?

JK: There are several reasons why we wrote the book. I was a lecturer at the University of Bonn and Oxford and currently I am doing lectures in Wuppertal, and the idea was to familiarise people with the application of mathematical methods in practice. There are of course many books available on this subject, but we wanted to write a book which was not simply designed for IT people – systems specialists who want to dive into the software architecture stuff – or simply for people who are only interested in the financial mathematics background: we wanted to write something which connects both worlds by presenting some real, challenging problems and also the implementation of the solutions. Often books on these topics might describe elegant or complex software frameworks, but in term of models they often resort to Black Scholes for convenience, on the other hand, financial mathematics books tend to explain the heavy theory – stochastic processes, stochastic analysis and so on – but only provide formulas for the models. Our aim therefore was to fill in the gap by combining those worlds; so we tackle challenging models, for example the Heston–Hull–White Model, some calibration routines for CMS contracts and the Libor market model, and demonstrate how such models can be programmed into software using, in this case, MATLAB.

So not only do we take the Black-Scholes model as an example but extend the range of the models to the state of the art – with stochastic volatility models, high dimensional models. We then describe the whole development workflow from market data and data analysis, to model choice and the derivation of model parameters, and then the use of more involved numerical methods such as the Monte Carlo method simulation to tackle the pricing of exotic derivatives, part dependant derivatives, the derivative exercises and so on. So this was the idea behind this book.

JB: So am I right in thinking that the gap in the literature you identify came about because the academic work is really new and the practical work hasn’t happened yet?

What I think is missing at the moment is this: People invent new, clever ideas using a heavy mathematical machinery, but fail to provide an example – a crystallisation point – say, like the initial code for a special case of this model so that people can really use the new ideas in Computational Finance in a very practical way.

JK: Well we certainly noticed, through our academic and practical experience, that when people try to implement some models they always reinvent the wheel. So, for example, people who program the pricing routine or the pricing algorithm for the Heston stochastic volatility model have to implement the correct characteristic function, Fourier transform stuff and so on, and what we provide, for each model, is a kind of recipe of how to do this, so nobody has to reinvent the wheel in practice, people can just use the algorithms which we have already tested and applied to financial problems.

JB: Why MATLAB? Was there a reason for choosing it in this context?

JK: Our attitude was that it was a nice environment for developing models because you do not have to concentrate on the side issues. For instance, if you want to calibrate a model you can really concentrate on implementing the model without having to think about the algorithms doing the optimisation for example. MATLAB offers a lot of optimisation routines which are really reliable and which are fast, which are tested and used by thousands of people in the industry. We thought it was a good idea to use standardised mathematical software, a programming language where all the mathematical functions like optimisation, like Fourier transform, random number generator and so on, are very reliable and robust. That way we could concentrate on the algorithms which are necessary to implement models, and not have to worry about a programming a random number generator or such stuff. That was the main idea, to work on a strong ground and build our house on a really nice foundation. So that was the idea of choosing MATLAB.

JB: So there is a lot of functionality built in, you don’t have to recreate it.

JK: Yes, this was the main reason. Plus it’s very easy to use those functions. We used to program in C++ for example, and VBA of course but in C++ you always have to find some library where certain algorithms are provided or create them on your own, and you have to really think hard about the software design and structure. Matlab prevents you having to spend quite so much time in the software development and design process. It’s a more functionally based approach which can of course be extended to an object-oriented approach, but in general it’s much easier to use that a lower level language like C++.

C++ has more features, of course, but it’s hard to get familiar with a programming language like that, you need a lot of practice and MATLAB is much easier to learn, much easier to use. Also we are doing our prototyping in MATLAB here at the bank so we were quite familiar with MATLAB and this was a natural choice as we work with it every day. By the way in the future we provide several training courses in using Matlab for financial problems on the Quants Hub network.

JB: I interviewed Daniel Duffy recently and one of his reasons for choosing C# as his preferred programming language was that it integrated very well with other languages, is that also true for MATLAB?

JK: Yes, you can compile your MATLAB code into a version which can be used in connection with C++, C# or the dot.net framework from Microsoft, for example; it integrates with Java and you can also build standalone applications. Conveniently you don’t need to have a MATLAB user licence to use the deployed software – you get a kind of compiled version of the MATLAB kernel with all the functions inside – and though you can’t use the programming language you can use the functions which are deployed. So people running the software in for example the DLL framework in Microsoft Excel do not have to buy a MATLAB licence they just get the deployed software to use.

JB: How is the book structured and why did you make those decisions?

JK: The book is structured in three parts. The first part is on available market data and financial markets. We wanted to show some evidence for the appearance of complex non-Gaussian models, so for example we look at volatility dynamics or volatility surfaces and we consider the market data from equity indices and fixed income. After that we show some diffusion models and two jump models which can somehow resemble the observed market data – like the shape of the implied volatility surface – so we cover popular models like Heston or SABR, the Variance Gamma model and Levy models with stochastic time changes and we show that the models can resemble certain observed market structures.

In the second part we show how people can use the models by showing the numerical analysis and code for implementation. For example we give pricing formulas for standard derivatives like Calls and Puts which are necessary for calibrating these models; we show several numerical techniques which are quite fast and which can be extended to more complex models and are very reliable. We also demonstrate the Monte Carlo simulation methods for tackling these models – and so really the second part of the book is on the advanced models and the different numerical methods which can be used. We especially focus on integration and transform techniques and on the Monte Carlo simulation.

Part three then is a kind of introduction to the MATLAB programming environment, demonstrating which techniques can be implemented in MATLAB. We start from the very basic stuff with variables and function calls and so on, then we extend this to using classes and Object-Oriented programming in MATLAB.

In the final chapter everything is gathered together and we demonstrate an application of a specific model in the MATLAB environment with an Object-Oriented framework for calibrating options for the German DAX Index. We show step-by-step how you can build up an application by doing the calibration and deriving the volatility surface for the models we have introduced in the first part.

So, summarising, the first part concerns markets and models, the second part numerical techniques and the third part is really on the application of these numerical techniques in MATLAB, providing an example which shows the whole work-flow, which can then be used as a starting point in your own applications, or experiments or even products such as software in the bank or insurance company or consulting business.

Practitioners really need to learn a little bit more about the underlying assumptions and the mathematics of the models they use, while those in academia should somehow be more keen to actually use and implement models on a computer – and to have also instilled the understanding in their students that programming is a really useful skill.

JB: What was it like collaborating and what were the main challenges when writing the book?

JK: Collaborating was easy because we work in the same unit in Postbank and we see each other every day and could easily talk about any problems arising when writing the book. Of course sometimes it is hard to push and pull and meet deadlines and so on, communicating with the publisher. But the selection of the material was probably the most important issue. The book is about 850 pages and we did not cover, for example, such an important topic as finite difference methods. Also we started to write the book in 2008-2009 around the time of the credit crisis and our book therefore does not include the new market paradigms for collateralisation and the multi-curve stuff which is really a topic on its own. What we did do, which I think is still very important, even after the crash, is really cover in depth the basics of the option pricing model and option pricing techniques.

The multi curve framework for example is a kind of ornamentation of the core principals in terms of object oriented patterns, for instance multi-curve processing can be done before pricing a derivatives contract or incorporating this into existing interest rate models for example. The basic techniques and core principals have stayed the same, so the book remains relevant after the financial crisis. The same mathematical programming techniques can also be applied in other ways but the techniques as they are stayed the same – so this book is really relevant before, during and after the crisis.

Furthermore, we tackle the pricing of American options using Monte Carlo techniques, and provide different methods for doing this. This is very important now for calculating all the adjustments and thinking about exposure modelling, calculating CVA and DVA, FVA and so on.  Those are numerical techniques which are very demanding and they are also discussed in our book. When we talk about Monte Carlo simulations and early exercise opportunities, we talk about exactly those kind of algorithms which are very important for everyday life nowadays to calculate CVA, etc. In short, the techniques covered are really quite useful even after the crisis.

JB: Does that mean that there might be another book coming?

JK: Yeah maybe! I think there are some good books on this topic but maybe there is room there for another!

JB: Who is this book written for? How much prior knowledge do you need to understand the book?

JK: We really wanted to write for both of the worlds; for the practical-minded people and also for academics, so people from the Quantitative Businesses, such as Quants, Consultants and Risk Managers can use the book, but also students and lecturers. The practical guys in banks, insurance companies and so on can use it for finding a certain model, understanding the properties of the model, and then have the code readily available for modification or to use ‘as is’ and apply it to everyday problems.

On the other hand we thought that lecturers might find it useful. Of course lecturers always use examples in their presentations and mathematical finance lectures and I think it would be quite beneficial – for people discussing the Levy processes for example, applications in finance, or studying the DAX options index pricing – to use our code and demonstrate to students how it can be used to solve practical problems. For students it’s always useful to have some implementation and guidance for really understanding the numerical stuff.

Of course people can use this book as it is, and no real prior knowledge is needed to apply the methods we demonstrate, however if you act in the financial markets you should really understand them and what you are doing if you apply a model. You should always check the model’s assumptions, whether it is the right model, which programming language is used, and whether it is efficiently programmed. I would recommend, therefore, that if you really dig deeper into the application of models you should familiarise yourself with the market and of course with the mathematical properties of the model, this is really necessary. The book can help in both cases here.

JB: We talked a little about the benefits of MATLAB, could you outline any limitations it has?

JK: Yes, of course, one limitation would be the price. People who want to develop in MATLAB have to buy a licence and I wonder if it is affordable for students but there are certain discounts – I don’t know the pricing model – but it may also be expensive for companies who have many developers. With other programming languages like C++ or C#, students can download a free version but professional versions are costly when, if you really want to, you can use C++ for free.
MATLAB is also a little bit more limited than C++, Java and C# in using Object-Oriented methodologies – design patterns and so on – so if you want to develop a state of the art in-house library in an object oriented pattern-minded programming language, that’s not MATLAB. Also if you want to gain more efficient programs in terms of runtime C++ is unbeatable.

JB: What sort of supporting resources are provided with the book?

JK: We have put our code for all the examples which I’ve discussed on the MathWorks homepage (http://www.mathworks.co.uk/) so that users have the opportunity to download it, exchange links and software.  When we find corrections needed in the code we put those on an errata page maintained by Wiley. We have also set up an email address where people can reach us kienitzwetterau_financialmodelling@gmx.de if they have questions or problems, or if they have any new ideas. If they have code or have developed their own applications using our code they can send it and we will have a look.

JB: I’d like to talk a little bit about financial programming, Computational Finance and the state of the art generally: What, in your view, are the key developments in Computational Finance of the last decade and how do you think things will develop?

JK: That’s a really hard question! Computational Finance has many facets and there were so many developments in the last decade. Some of these of course were made available by using more sophisticated hardware designs, for example parallel programming and GPU programming made it really possible to run numerical experiments and explore numerical issues, creating simulations or solving high dimensional problems in a very short amount of computational time. This new technology is I think complicated to program but if you use it and get a grip on this technology it will put you in a nice position to do more sophisticated, more complicated numerical analysis.

Also there have been many nice ideas from the mathematical side which can be applied to financial problems and which have been realised in computer algorithms, so I see this also as a development in computational finance also. For example there is a nice mathematical idea for a new integration formula for the SABR model, based on Riemannian geometry which can now be implemented, or there are other ideas for calibrating local volatilities for example. These algorithms appear first as mathematical ideas, then they make it into computer programs and expand the range of the current available methods for tackling these models. So I think these are also very important issues in Computational Finance – not only the computational side, the hardware side, but also the mathematical brains lying behind these algorithms and software.

JB: You talked about the hardware developments, does the book address any of that?

JK: We focus on the models and we do not really discuss anything in terms of parallelism or GPU computing. We just focus on the algorithms which are needed for implementing a particular model but not really on extending this to more sophisticated hardware settings.

JB: Are there any areas in Computational Finance which you feel are overrated or given too much prominence in the financial media?

JK: Always in the market people like a certain model or a certain method and it’s really prominent for a while and maybe later it turns out that it was a blind alley, but I don’t think there is something in particular which is overrated at the moment. What I think is missing at the moment is this: People invent new, clever ideas using a heavy mathematical machinery, but fail to provide an example – a crystallisation point – say, like the initial code for a special case of this model so that people can really use the new ideas in Computational Finance in a very practical way. I think it would be ideal if, when someone invents a new model or a new calibration method or whatever, that they also provide some basic code say in C++ or in MATLAB, so that people can see on a very basic level how this new method works. This would give people more confidence in using this model or method so that they can understand the benefits of implementing it. Sometimes I think people working in Computational Finance put forward the nice big model but people are not really sure how to use it or if it is really interesting and reasonable to implement the model. They cannot really see its advantages, or how complicated it is to program the model.

Of course people will say it is secret to the bank or to the industry where they work but I think, especially for academics, it might be a good idea to structure papers on the new methods in such a way that people can really put this into an algorithm in practice. That would be very useful and important for practitioners, being able to see a nice method written up in such a way that people can really adapt it to their software framework. This would definitely be advantageous for this model in becoming popular I think.

JB: That sounds like a potential journal on the practical methods in Computational Finance!

JK: Yes why not, that sounds really good! I think people working in Computational Finance in academia can really enhance their work by giving some kind of tips for implementing a model – a simple algorithm, a simple application – I think it would add to the knowledge in the market.

JB: Well, that’s good to know!  I was wondering if you have any views on how Computational Finance is taught generally?

JK: Yes, I do practitioners courses and I also lecture at university, currently in Computational Finance and I think it’s very important, starting with academics, that on the one hand you get the numerical details and the mathematics right, but on the other hand emphasise the link to practice – by doing computer exercises and experiments. Of course you need to learn the theory and know how an algorithm should work by calculating roots of whatever, the very basic stuff, but if you are forced to do it yourself using some programming language it gets complicated. I think it would be very beneficial if every lecture on Computational Finance had a kind of practical session or a practical part for the students applying their new knowledge to real financial models and financial problems.

So that’s one thing, from an academic perspective, but on the other hand practitioners always like to have an implementation of the model, but what they really should understand, for each model, are under what circumstances a model delivers reasonable results. So, if you think about the credit crisis for example, the popular model, the Gaussian stuff was nice but didn’t really apply to the structures we have seen. So assumptions were not really fulfilled and you can only judge a model when you know what the model was made for, and how the assumptions for applying this model are fulfilled. Practitioners really need to learn a little bit more about the underlying assumptions and the mathematics of the models they use, while those in academia should somehow be more keen to actually use and implement models on a computer – and to have also instilled the understanding in their students that programming is a really useful skill.

More should be done at university to emphasise this practical element. Not simply the modelling and the theory, but also doing it on a computer.

JB: That was very interesting Jörg, I really appreciate your time.

Comments are closed.