eddelbuettel / rquantlib

R interface to the QuantLib library
119 stars 50 forks source link

Does RQuantLib support IRSwap? #67

Closed scchess closed 8 years ago

scchess commented 8 years ago

@eddelbuettel Does RQuantLib allow me to construct an interest-rate swap (VanillaSwap in QuantLib)? For example, can I use RQuantLib to compute fair swap rate? I can't seem to find the function in the documentation.

eddelbuettel commented 8 years ago

The idea of RQuantLib is to give you a few cooked examples and otherwise allow you access to the full pantry to construct your own.

If you need (almost) everything pre-cooked then the Python SWIG interface is probably more feature-complete.

@tleitch works a lot with swap(tion)s so he may have an example for you.

tleitch commented 8 years ago

There is a vanilla swap module that calls quantlib swap functions in development with an ETA of 2-4 weeks. In the meantime, you can always model a vanilla swap as the difference of two bonds. For a receive fixed bond, you model the fixed leg as a long position in a fixed rate bond and a short position in a floating bond using the swap dates and leg conventions for each bond. For a pay fix, you reverse the position.

tleitch commented 8 years ago

To get the fair rate, look at the code for recently released SabrSwaption. The swap is set up and the fair rate calculated and returned for the forward start swap that matches the swaption. So, in a roundabout way you could get it using the SabrSwaption module until the swap module is ready. You need a vol cube, but there's one in the example available on github repo. Using a stale vol cube does not affect the fair rate calculation. It is affected only by the discount curve input.

sonben commented 7 years ago

Is there any progress in getting vanilla swaps to be supported in rquantlib?

scchess commented 7 years ago

Not from me. I'm just using the C++ code. It's not hard to port the vanilla swap code to R, you can give a try if you wish.

eddelbuettel commented 7 years ago

And we can help.