Author: Jorrit de Jong

Credit Default Swaps : First Steps with Example

A Credit Default Swaps (CDS) is a derivative to transfer default risk from one party to the next. The default protection is granted on the reference entity which can in principal be any entity, for example a single company, a group of companies or even a country. The protection buyer makes (quarterly) payments as compensation for the protection until either the end of the contract or the moment of default of the reference entity. This structure results in the pricing of this leg containing a part for the value of the payout in case of default and a part for the accrued premium until default. This side of the swap is called the premium leg.

The protection seller pays out a fixed amount in case of default of the reference entity. This amount is usually quoted as the notional amount times a recovery fraction. This side of the swap is called the protection leg.

To get a feel for the pricing of these kind of swaps please consider the simple attached example based on the book of Hull. In this example the CDS price is computed based on deterministic default probabilities and a fixed interest rate. To get a more realistic pricing, we could change the fixed interest rate with an interest rate model and the deterministic default probability with a stochastic model. However, that aside, we think this example gives a good basic understanding of how a CDS works. 

The CDS example spreadsheet is available here : cds example

Change more-link display text in WordPress

For a recent project we created an online house pricer for the Dutch market, Huizen Prijs Checker. The backend, a statistical model, was built using Java which connects to our PHP / WordPress frontend using an API. We have worked with WordPress before, but once again we were surprised to see how easy it’s to setup and customise using templates and plug-ins.

The site being local to Dutch market is all in Dutch. This meant creating pages and blogs in Dutch. Which works wonderfully. The one thing which gave us headache was the continue reading text displayed by the more-link object.  The tag is inserted using the WordPress editor as shown here:

read more insert

On your blog-role or category pages a link will be displayed with the text “Continue reading ->”, like so:continue

This wasn’t any good as our site was meant to be in Dutch. So we where hoping for something like:

lees meer

It took quite some time to figure out how to get our theme to display a “continue reading” link with custom text. As it turns out this can be fixed by creating a child package. Details on how to do this can be found in WordPress Codex. Once you have the child theme setup the link text can be modified by adding a new read_more_link function to the functions.php file in your theme. This function will then override the default behaviour of the links. The following snippet does the trick. Continue reading

Theta - Critical Note

In a previous blog we presented an implementation of the Generalised Hull-White model (2014). This implementation relies on a numerical root-finding routine to determine model parameters so that model prices match actual market prices. The root finding is far from trivial as different algorithms will give different results. Fortunately the quality of the result can be easily monitored as the difference between model prices and actual marked prices is a clear indicator. As it turns out in most cases, the root finding for theta is not required. Instead an analytical formula can be used. Mike Staunton very kindly pointed us to a paper by Grant & Vora (2001) that shows that the approximation used by Hull-White is not necessary. The equations explained in the paper are implemented in the attached spreadsheet by Mike Stauton for the first 3 steps of the lattice giving a good example of how the process for finding theta works in practice.

 

blog theta

 


The spreadsheet is available here:

MikeHWTriTreeGV


 

 

References:

Grant & Vora (2001) , An Analytical Implementation of the Hull and White Model

http://janroman.dhis.org/finance/Hull%20&%20White/analytical-approximation-hull-and-white.pdf

 

Hull & White (2014), A Generalized Procedure for Building Trees for the Short Rate and its

Application to Determining Market Implied Volatility Functions

http://www-2.rotman.utoronto.ca/~hull/downloadablepublications/TreeBuilding.pdf

Review of Lattice Construction Methods

Just before year end we put out our paper, titled "Review of Lattice Construction Methods"!

lattice

This paper extends the generalized procedure for building trees for short rates by Hull & White. A generalization for any mean and standard deviation of the underlying short rate model is presented. In addition we review the methodologies for constructing lattice models and give a step-by-step explanation on how to construct trinominal trees. We apply the formalism to some explicit examples of various complexity.

 

Full text can be found here

 

World Finance Conference Talk 2015 - The Geometry of Interest Rate Risk

In this talk the process of interest rate risk management is considered. The yield curve construction is revisited and emphasis is given to aspects such as input instruments, bootstrap and interpolation. For various financial products new formulas are presented that are crucial to define sensitivities to changes in the instruments and/or in the curve rates. Such sensitivities are exploited for hedging purposes. The risk space is constructed, which eventually turns out to be a curve property, and show how to hedge any product or any portfolio of products in terms of the original curve instruments. Continue reading

Theta : A Test for Short Rate Model Lattice

While short rate models have lost ground to libor market models for valuation of (complex) interest rate derivatives, they remain popular for Asset and Liability Management. As a result you may find yourself implementing a short rate model. Often the choice is to implement a lattice approach, perhaps in combination with a Monte Carlo framework. One critical step in these models is to match the model discounts to the ones observed in the market. This makes to model (almost) arbitrage free. To match the market a numerical root finding algorithm needs to be used, for example Newton Raphson. This poses the challenge that mistakes in the model may not be obvious as the root finder can still find parameters to match the market even though there are mistakes in the model. Our suggestion is to check the root finder solution to known analytical solution of the Hull White model using functional form for the zero curve that is continuous and two times differentiable.

Continue reading

Warning NlOptNet Contains Malware

For a recent project building short rate lattice trees we needed to do some root solving. Fortunately there are quite a few Open Source solvers available enabling us to test a wide range of algorithms with little effort. One of the algorithms we tried was NlOpt, which is excellent. To use this code in .Net we used https://github.com/BrannonKing/NLoptNet via NuGet repo with the following command.

 

PM> Install-Package NLoptNet

Installing 'NLoptNet 1.0.2.0'.

Install failed. Rolling back…

 

This made the virus scanner go on full alert!

 

image00

Downloading the zip from github directly resulted in a zip with the virus included.

image01

Hope this helps keeps PCs safe and that the next version of this otherwise great package will be without virus.

Generalized Procedure for Building Short Rate Trees in Excel / VBA using LevmarExcel

In a previous we blog we reproduced example 1 of the  2014 paper John Hull and Alan White “Generalized Procedure for Building Short Rate Trees”. In the paper the authors derive a generalized method for the construction of short rate trees. This generalization is interesting as it allows for one tree (or lattice) construction algorithm for all one-factor short rate models. Continue reading

Wrapping C++ DLL for use in Excel / VBA using some pretty awesome open source projects

In this blog it’s explained how you can wrap up C++ managed or unmanaged code and make the functionality available in Excel / VBA. The blog uses levmar as specific example, but most steps are generic. The levmar specific example is due to the fact that we are currently working on some short rate lattice models that need to be calibrated to the interests market. The calibration requires a robust solver for a nonlinear least squares problem. To share our models and their implementation with the wider finance community we choose Excel / VBA for the implementation. This allows us to easily share our ideas and algorithms. For most simple cases this worked wonderfully using a solver algorithm that was originally part of MINPACK developed by Jorge More, Burt Garbow, and Ken Hillstrom at Argonne National Laboratory. The algorithm we used was translated from Fortran to VBA by Vanna and shared on quantcode.com. This algorithm proved not to be stable enough for more complex problems. So we started looking for more stable implementations and found levmar by Lourakis. This package was written in ANSI C. Here we explain how we took this code and build xll add-in for Excel using:

Continue reading

Levmar Excel version 1.1 released

We are happy to announce that a new version of Levmar Excel has been released. This version exposes more functionalities from the original levmar package to Excel.

New in this version is the ability to pass a VBA class (i.e. object) as extra parameter to LevmarExcel. This object can contain extra information needed to evaluate the error function. This addition offers a lot of extra flexibility using the package. Complex object models can now be passed as arguments to be used for the evaluation of the error function (the error function can be only a thin wrapper for the “real” error function in the object).

The latest version of Excel Levmar is available here. The package contains the example “demo_vba_object.xlsm” which shows how to use this new functionality. The example contains a module with some code to build the LevmarExcelSolver object. Continue reading