An Italian coding, tech, financial math professional and running lover

I have released a new version of the package SwapPricer on GitHub here.
As we are now at version 1.0.1 the toolbox is able to price using just a one-curve framework but is able to price multiple currencies (ie. CHF, EUR, GBP, JPY and USD) and any convention in terms of coupon frequency, day count convention.
We are working to introduce OIS Discounting in the next releases
SwapPricer: instructions for use To run a multi-currency swap portfolio valuation you need the following three “ingredients”:

In the previous posts we have seen how easy it is to price interest rate swaps using R. I am honoured to announce that I have decided to put all the functions I have described together into a package that is called…SwapPricer!
Ok, the name is not super original, but it should at least be easy to remember.
You can install it as follows:

Davide Magno

I have released a new version of the package SwapPricer on GitHub here.
As we are now at version 1.0.1 the toolbox is able to price using just a one-curve framework but is able to price multiple currencies (ie. CHF, EUR, GBP, JPY and USD) and any convention in terms of coupon frequency, day count convention.
We are working to introduce OIS Discounting in the next releases
SwapPricer: instructions for use To run a multi-currency swap portfolio valuation you need the following three “ingredients”:

In the previous posts we have seen how easy it is to price interest rate swaps using R. I am honoured to announce that I have decided to put all the functions I have described together into a package that is called…SwapPricer!
Ok, the name is not super original, but it should at least be easy to remember.
You can install it as follows:

In this post we will close the trilogy on (old style) swap pricing. In particular, we will look at how downloading the data for the variable rate needed to calculate the variable leg accrual.
Part 1 gave the general idea behind tidy pricing interest rate swaps using a 7 lines pipe
Part 2 went much more into detail and priced some real world contract comparing the results obtained vs Bloomberg and showing significantly good results.

In this post I will show how easy is to price a portfolio of swaps leveraging the purrr package and given the swap pricing functions that we introduced in a previous post. I will do this in a “real world” environment hence using real market data as per the last 14th of April.
Import the discount factors from Bloomberg Let’s start the pricing of the swap portfolio with purrr by loading from an external source the EUR discount factor curve.

Introduction I am a big passionate of the tidyverse packages: I think they make the code very clean and clear. In particular, I like the lubridate packages for managing and making operations with dates but its major drawback is that it doesn’t manage financial holidays, which are key when projecting financial cashflows linked to instruments like interest rte swaps.
In this case, I prefer to use the RQuantLib package.

Here's my #TidyTuesday submission.I studied the total increase in the housing index for each US State compared to the US federal index. No surprise in California house price has increased much more than the rest of US.The #mapdata library was 👍🏼@thomas_mock @R4DScommunity #rstats pic.twitter.com/sYI1zKhIpC
— Davide Magno (@DavideMagno) February 10, 2019

Finally my first #TidyTuesday submission! 🎊🎉I am starting from week 1 2019 but I will catch up soon😉When do people submit their visualisations?Mostly on Tuesday and Wednesday afternoon, but also on Monday before the new set is released #rstats #ggplot @rstats4ds @thomas_mock pic.twitter.com/pKZAyL8vp1
— Davide Magno (@DavideMagno) February 3, 2019

One of the most common problems when dealign with financial data is to have assets (or liabilities) denominated in a currency that is different from the domestic one.
I propose a tidy solution to this problem that involves no use of for cycles.
The principle of the solution is that converting each currency can be done in parallel using the map function while the consolidation of the results will be done using the reduce logic.

In quantitative finance we often look at simulations of some market risk factors like equity returns or interest rate changes.
There are many third party companies who specialize in the historical calibration of such variables and provide simulations of future expected outcomes to the companies who require them.
For example, let’s suppose that we receive the expected returns of the Google shares as per the following distribution
# This modelling is given by the third party and in theory we don't know it google <- rnorm(10000, mean = 0.