This post shows a simple example which uses the RDCOMClient R package. As an example, A Libor IRS pricing with OIS discounting is presented with the help of a VBA macro code from Mikael Katajamäki’s source with proper citation (this should be always).
In the previous post, we have used the RDCOMClient R package for communications between Excel and R.
In this post, we provides a simple example for pricing a Libor IRS with OIS discounting. Unlike Libor IRS pricing with only one Libor curve, pricing of Libor IRS using OIS discounting uses two curves.
1) Projecting floating cash flows using an adjsuted Libor forward rate curve.
2) Discounting all cash flows from two fixed and floating legs using OIS discount factors.
Among them, the first part is a little complicated so that this issue (construction of adjusted forward libor curve) will be covered in some later post. Instead, for this time, we borrow Mikael Katajamäki’s VBA function, which is found in the following his blog. Some useful background information for OIS discounting is provided for your understanding in his blog.
Like this, if useful functions for some specific purpose have already been made by another researchers, we can use these functions without transforming from VBA code to R code (with proper citation as follows).
Excel Example with VBA macro
The following figure shows the operation of macro1() function.
Clicking [run macro1] rectangular button calls macro1() which also calls a internal function for OIS discount factors and adjusted forward rates.
Mikael Katajamäki’s VBA code of bootstrapping OIS discounting is as follows, to which I add some modifications (shaded area) for OIS discounting factor to be also returned (original version returns only forward rate). When Rectangular button is clicked, macro1() VBA function is called, which calls this VBA OIS bootstrapping function.
The following R code implements three operations:
- Write input array to Excel
- Run macro1()
- Read output array from Excel
- Using OIS DFs and Adjusted Forward Rates,
Calculate Swap Price at Inception
R code is similar to the that of previous post because R does not perform the core part of calculation.
The following console shows two outputs: 1) OIS discount factors and adjusted forward rates, 2) swap pricing at inception for each maturity. As you can see, we can get swap prices at inception which are correctly at par (zero).
The core part of this above swap pricing is based on the VBA code from other sources. Therefore, when we have some good VBA resources other than R, we can use them in R for efficient process. I think that this is a kind of “standing on the shoulders of giants”.
Of course, this Libor IRS pricing with OIS discounting is so simple that we can deal with this issue more concretely in the next time \(\blacksquare\)