Date   

VolCube in RQuantLib

Suhas Ghorpadkar
 

I have posted the same question on Quant StatckExchange (https://quant.stackexchange.com/questions/58479/volcube-in-rquantlib) before I discovered this group. 


Working with RQuantLib for the first time and trying to understand how the Swaption Vol Cube is being built. I am looking at volCF2CubeK.R file and my general understanding is that we are collecting ATM lognormal volatilities first in "atmMat" which is fine. Then comes the "smirk" part I don't understand. 

Why not just pass the entire set of vol spreads (with ATM being zero) for a particular tenor and expiry to QuantLib's SwaptionVolCube1 ? 

It looks like there is some interpolation involved with smirk that I don't understand why it's needed.


Also, what does CF2 and K stand for in the name of this file? Why is the file not simply called VolCube.R ?


atmMat = matrix(data = NA, nrow = length(expLvl), ncol = length(tenorLvl), 
dimnames = list(expLvl, tenorLvl))
for (i in 1:length(expLvl)) {
  for (j in 1:length(tenorLvl)) {
    atmMat[i, j] = tbl[tbl$Expiry == expLvl[i] & tbl$Tenor == 
    tenorLvl[j] & tbl$Spread == 0, ]$LogNormalVol
  }
}
smirk = matrix(ncol = length(strikes), nrow = length(expLvl) * 
  length(tenorLvl))
k = 0
for (i in 1:length(expLvl)) {
  for (j in 1:length(tenorLvl)) {
    k = k + 1
    for (n in 1:length(strikes)) {
      smirk[k, n] = tbl[tbl$Expiry == expLvl[i] & 
        tbl$Tenor == tenorLvl[j] & tbl$Spread == strikes[n], 
        ]$LogNormalVol - tbl[tbl$Expiry == expLvl[i] & 
        tbl$Tenor == tenorLvl[j] & tbl$Spread == 0, 
        ]$LogNormalVol
    }
  }
}
smirk <- na.spline(smirk, method = "natural")
On the C++ side, I see this call and it is the "qSwSmile" parameter from R that I am struggling with.


Handle<SwpVolStr>
        res(QuantLib::ext::shared_ptr<SwpVolStr>(new SwaptionVolCube1(swaptionVolAtm, 
        optionTenorsSmile,                                                               
        swapTenorsSmile, strikeSpreads, qSwSmile,
        swapIndex, shortSwapIndex, true,
        parameterGuess, parameterFixed, true, ec,
        .050)));
Thanks for your help, much appreciated.
Suhas


Replicating the discountcurve and extending it beyond the 2yr (fut8) limit

erlendmcd@...
 

Hi all,

So I am rather new to R but currently attempting to replicate the discountcurve part of the package in order to extend the futures function beyond the 2 years. 
I am struggling quite a bit with both accessing the entire code used by the discountcurve function in order to replicate it and look into how exactly it does what it does, in addition to extending the futures function beyond the current 2 year limit. 

My main issue so far has been accessing the full extent of what the discountcurve function does (code). 

Any help with this or point in the direction I should approach it would be greatly appreciated. 

Best regards,

Erlend


Re: RQuantLib v4.0.0 for Ubuntu 20

Dirk Eddelbuettel
 

On 17 May 2020 at 01:36, John Paul Broussard wrote:
| I actually figured it out, though, and only though an attempt to "purge" QuantLib's install.

Excellent!

| So, user error on my part... I suppose sometimes I need to take a look at the build versions to insure they are the latest, or at least referencing the same version.

I was suspecting something but because it can be within the package sytem, or
without, it is hard to check. Sometimes it is the simple things eg

$ locate ql/quantlib.hpp

or

$ locate libQuantLib.so

to check you don't have a version in /usr AND in /usr/local.

Glad you have it working! And thanks for the kind words.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Re: RQuantLib v4.0.0 for Ubuntu 20

John Paul Broussard
 

Yep.  I now see how my replies look like I am not providing new information, because I was not...  My bad.

I actually figured it out, though, and only though an attempt to "purge" QuantLib's install.

Let me see if I can answer your questions:
"_How_ did you install QuantLib?"

I was following the steps found here: https://www.quantlib.org/install/linux.shtml

Problem was, the tar referenced by that page contains the latest version of QuantLib, 1.18.  For whatever reason, though, some of my libquantlib* builds were for 1.17, so apparently, there was a conflict of some sort. When I uninstalled completely, e.g. "purged," and started from fresh, and then reinstalled, RQuantLib finally went all the way to install completion.

So, user error on my part... I suppose sometimes I need to take a look at the build versions to insure they are the latest, or at least referencing the same version.

Thanks for all the patience with this Dirk. I am converting over to Linux (using Ubuntu), so I am learning new things daily. Your videos on using the system are helping LOTS. Some of the "simple" things I used to know when I taught myself DOS 30+ years ago, are now becoming handy...

Thanks again for everything.


Re: RQuantLib v4.0.0 for Ubuntu 20

Dirk Eddelbuettel
 

On 16 May 2020 at 04:59, John Paul Broussard wrote:
| That's what's driving me crazy. My R works on everything. My QuantLib also appears to work - I tested it out using the example shown on the QuantLib.org site.  Rcpp loads, and appears to be working.  RQuantLib is the version you indicate, and it also appears to be working as well, it simply crashes at the very ending of the install:
|
| | ** testing if installed package can be loaded from temporary location
| | Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
| | unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
| | /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb

Well, sorry to be blunt but we are going in circles. You have not supplied
new information I can act on here.

| | Error: loading failed
| | Execution halted
| | ERROR: loading failed
| | * removing ‘/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/RQuantLib’
|
| I do not understand the error:
|
| | Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
| | unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
| | /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb
|
| If there is an "undefined symbol" I am not sure how to address the issue other than to fully remove QuantLib 1.18, which I believe I have done, but I must not have.  I am following all the steps on the QuantLib.org install page (even though it references version 1.14), and I have reinstalled 3x now.  I can only figure there is a "broken" link in the QuantLib install referenced in a /bin or /etc or other directory that I am missing when removing 1.18.

_How_ did you install QuantLib?

Obviously from the above your build of RQuantLib is unhappy about the
QuantLib used. I showed you in my last email that I using a prebuilt binary,
availble for the world to use too via the Launchpad PPA.

Am I guessing correctly that you are using a locally compiled one?

| Is there a way to perform a "purge" similar to "sudo apt purge..." ?

Purge of what?

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Re: RQuantLib v4.0.0 for Ubuntu 20

John Paul Broussard
 

That's what's driving me crazy. My R works on everything. My QuantLib also appears to work - I tested it out using the example shown on the QuantLib.org site.  Rcpp loads, and appears to be working.  RQuantLib is the version you indicate, and it also appears to be working as well, it simply crashes at the very ending of the install:

| ** testing if installed package can be loaded from temporary location
| Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
| unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
| /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb
| Error: loading failed
| Execution halted
| ERROR: loading failed
| * removing ‘/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/RQuantLib’

I do not understand the error: 

| Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):

| unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
| /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb

If there is an "undefined symbol" I am not sure how to address the issue other than to fully remove QuantLib 1.18, which I believe I have done, but I must not have.  I am following all the steps on the QuantLib.org install page (even though it references version 1.14), and I have reinstalled 3x now.  I can only figure there is a "broken" link in the QuantLib install referenced in a /bin or /etc or other directory that I am missing when removing 1.18.

Is there a way to perform a "purge" similar to "sudo apt purge..." ?  


Re: RQuantLib v4.0.0 for Ubuntu 20

Dirk Eddelbuettel
 

On 14 May 2020 at 09:17, John Paul Broussard wrote:
| Thanks Dirk.  Unfortunately, I have loaded the latest QuantLib (1.18 I think) - still same RQuantLib install error.  I loaded the items you indicate, still same RQuantLib install error. Could there a library still "lingering" somewhere in my system from a previous "bad" install?  How might I completely purge QuantLib so that I can restart from the tar file downloaded from quantlib.org?

We would need more details. I am on 19.10, everything works and should / will
once upgraded. I would recommend you check and double-check all components: R
(works, I presume), Rcpp, QuantLib and then RQuantLib.

edd@rob:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan
edd@rob:~$ dpkg -l|grep quantlib|cut -c-79
ii libquantlib0-dev 1.18-1.1910.1
ii libquantlib0v5 1.18-1.1910.1
ii quantlib-examples 1.18-1.1910.1
ii quantlib-python 1.16-1.1904.0
edd@rob:~$ Rscript -e 'library(RQuantLib); packageVersion("RQuantLib")'
[1] ‘0.4.12’
edd@rob:~$

So my RQuantLib is from source.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Re: RQuantLib v4.0.0 for Ubuntu 20

John Paul Broussard
 

Thanks Dirk.  Unfortunately, I have loaded the latest QuantLib (1.18 I think) - still same RQuantLib install error.  I loaded the items you indicate, still same RQuantLib install error. Could there a library still "lingering" somewhere in my system from a previous "bad" install?  How might I completely purge QuantLib so that I can restart from the tar file downloaded from quantlib.org?


Re: RQuantLib v4.0.0 for Ubuntu 20

Dirk Eddelbuettel
 

On 2 May 2020 at 06:43, John Paul Broussard wrote:
| I recently updated to Ubuntu 20.04, as well as to R v4. When updating packages, I ran into an issue with RQuantLib.
|
| As the attached indicates, all appears ok with QuantLib and Boost,
|
| * installing *source* package ‘RQuantLib’ ...
| ** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
| ** using staged installation
| checking whether the C++ compiler works... yes
| checking for C++ compiler default output file name... a.out
| checking for suffix of executables...
| checking whether we are cross compiling... no
| checking for suffix of object files... o
| checking whether we are using the GNU C++ compiler... yes
| checking whether g++ -std=gnu++11 accepts -g... yes
| checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
| checking whether we are using the GNU C++ compiler... (cached) yes
| checking whether g++ -std=gnu++11 accepts -g... (cached) yes
| checking for R... yes
| checking for quantlib-config... yes
| checking for Boost development files... yes
| checking for minimal Boost version... yes
| configure: creating ./config.status
| config.status: creating src/Makevars
| Configured RQuantlib 0.4.12
|
| but when the final "steps" of the install occur:
|
| installing to /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs
| ** R
| ** data
| ** demo
| ** inst
| ** byte-compile and prepare package for lazy loading
| ** help
| *** installing help indices
| ** building package indices
| ** testing if installed package can be loaded from temporary location
| Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
| unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
| /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb
| Error: loading failed
| Execution halted
| ERROR: loading failed
| * removing ‘/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/RQuantLib’
|
| What am I missing?

edd@rob:~$ c++filt _ZN8QuantLib4Date11monthOffsetENS_5MonthEb
QuantLib::Date::monthOffset(QuantLib::Month, bool)
edd@rob:~$

A symbol missing in the library (or libraries) you link against. It usually
means you QuantLib is older than what RQuantLib wants.

You report, detailed as it was, omits that detail.

I tend to create .deb packages for my work on RQuantLib and put them here
https://launchpad.net/~edd in repo 'Miscelleneous Packages' (which seems to
have QL 1.10, 1.11, and 1.13). And sometimes I seem to put them in 'r-3.5'
(though they are not R related, I shouldn't do that) which has QL 1.15, QL
1.16, QL 1.17 and QL 1.18.

Which is what I run, currently still on 19.10:

edd@rob:~$ dpkg -l | grep quantlib | cut -c-79
ii libquantlib0-dev 1.18-1.1910.1
ii libquantlib0v5 1.18-1.1910.1
ii quantlib-examples 1.18-1.1910.1
ii quantlib-python 1.16-1.1904.0
edd@rob:~$

Feel free to fetch them from there too.


Or, if you're really lazy and just need a simple RQuantLib installation, try
the pre-built package from the distro (may conflict with R 4.0.0 though) or
Michael's PPA (if/when rebuilt, dunno about the timing; will support 4.0.0).

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


RQuantLib v4.0.0 for Ubuntu 20

John Paul Broussard
 

I recently updated to Ubuntu 20.04, as well as to R v4. When updating packages, I ran into an issue with RQuantLib. 

As the attached indicates, all appears ok with QuantLib and Boost,

* installing *source* package ‘RQuantLib’ ...
** package ‘RQuantLib’ successfully unpacked and MD5 sums checked
** using staged installation
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ -std=gnu++11 accepts -g... yes
checking how to run the C++ preprocessor... g++ -std=gnu++11 -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ -std=gnu++11 accepts -g... (cached) yes
checking for R... yes
checking for quantlib-config... yes
checking for Boost development files... yes
checking for minimal Boost version... yes
configure: creating ./config.status
config.status: creating src/Makevars
Configured RQuantlib 0.4.12


but when the final "steps" of the install occur:

installing to /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs
** R
** data
** demo
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘RQuantLib’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so':
  /home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/00LOCK-RQuantLib/00new/RQuantLib/libs/RQuantLib.so: undefined symbol: _ZN8QuantLib4Date11monthOffsetENS_5MonthEb
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/home/fibrou/R/x86_64-pc-linux-gnu-library/4.0/RQuantLib’

What am I missing?


Calibrating Hull-White with negative interest rates

Chra15ab@...
 

Hi All

I have seen a couple of topics regarding this, but the problem is that the function BermudanSwaption uses a lognormal which obviously cannot be used on negative interest rates.

Is there a way to change this? (I can see it uses a UseMethod from Python I think?) or is there another work around - for example by shifting the numbers to positive?

Thanks in advance.

Kind regards,
Christopher


Market quotes passed to DiscountCurve function

bruno.crinon@...
 

Hi all,

Would you know please if there is a way to pass a more precise market curve to DiscountCurve, over short maturities ?
I would need to add d2w, d3w, d4m, d5m, d18m pilars as input, and they are not recognized yet

Many thanks in advance
Bruno
 


Re: Error installing package on CentOS 7

Dirk Eddelbuettel
 

On 11 September 2019 at 11:00, dick.r.chiang@gmail.com wrote:
| The package maintainer has previously not recommended the following, but it directly addresses the core problem.  The alternative is to upgrade to a CentOS version with boost libraries greater than 1.58.  Lots of back and forth on github issues #119, #132.

Oh dear I had forgotten all about! Indeed, old Boost / old compilers will do
that too. I should probably beef up the checks in configure.ac.

Thanks for pointing that out.

Minor nits below.

| 1. git clone `lballabio/QuantLib`
| ```
| ./autogen.sh`
| ./configure --prefix=$HOME/.local --enable-intraday

Hidden directory? Hm. Maybe $HOME/lib/ ? Anyway...

| make install
| ```
| 2. git clone `eddelbuettel/rquantlib` and remove `CXX_STD=CXX11` from `src/Makevars.in`
| 3. From the `rquantlib` parent directory, fire up R and execute
| ```
| library(devtools)
| install()

Or just say 'R CMD INSTALL .'

Dirk

| library(RQuantLib)
| getHolidayList("UnitedStates", as.Date("2018-12-01"), as.Date("2019-01-02"))
| ```
|
|
|

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Re: Error installing package on CentOS 7

dick.r.chiang@...
 

The package maintainer has previously not recommended the following, but it directly addresses the core problem.  The alternative is to upgrade to a CentOS version with boost libraries greater than 1.58.  Lots of back and forth on github issues #119, #132.

1. git clone `lballabio/QuantLib`
```
./autogen.sh`
./configure --prefix=$HOME/.local --enable-intraday
make install
```
2. git clone `eddelbuettel/rquantlib` and remove `CXX_STD=CXX11` from `src/Makevars.in`
3. From the `rquantlib` parent directory, fire up R and execute
```
library(devtools)
install()
library(RQuantLib)
getHolidayList("UnitedStates", as.Date("2018-12-01"), as.Date("2019-01-02"))
```
 


Re: Error installing package on CentOS 7

Dirk Eddelbuettel
 

On 11 September 2019 at 04:50, beppeg@gmail.com wrote:
| Dear all,
| I'm going crazy to install the package on CentOS 7.
| Required QuantLib library installed from EPEL repository via yum seems to be < 1.14 so I installed successfully 1.16 release compiling from sources.
|
| Installing R-package I get following error:
|
| *** caught segfault ***
| address 0x7f2370de92a0, cause 'invalid permissions'
|
| Error occurs loading library after compilation.
|
| Did someone have and solved the problem?
| Ther's some tutorial/hint about installation on CentOS 7?

Segfauls are sometimes a symptom of mismatched libraries. Make sure QuantLib
and Rcpp are built with the same compiler, so if you installed QuantLib from
source, also install Rcpp from sources.

Also, after building QuantLib, it might be a good idea to run its test
suite.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Error installing package on CentOS 7

beppeg@...
 

Dear all,
I'm going crazy to install the package on CentOS 7.
Required QuantLib library installed from EPEL repository via yum seems to be < 1.14 so I installed successfully 1.16 release compiling from sources.

Installing R-package I get following error:
 
 *** caught segfault ***
address 0x7f2370de92a0, cause 'invalid permissions'

Error occurs loading library after compilation.

Did someone have and solved the problem?
Ther's some tutorial/hint about installation on CentOS 7?

Thank you.
Beppe
 


Re: Pricing of a bond with negative rates

kumpelka78@...
 

I'm sorry for my misunderstanding.

I will dig the problem by myself and ask to QuantLib.

Jean-Louis 


Re: Pricing of a bond with negative rates

Dirk Eddelbuettel
 

On 26 March 2019 at 12:28, kumpelka78@gmail.com wrote:
| Any news from QuantLib ?

"You tell us". It is your itch to scratch (to borrow the common phrase about
motivation for open source) so I had suggested that you go and inquire. We
are volunteers here so you cannot really expect _us_ to do _your_ work for you.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Re: Pricing of a bond with negative rates

kumpelka78@...
 

Hello,

Any news from QuantLib ?

Thanks,
Jean-Louis


Re: Pricing of a bond with negative rates

Dirk Eddelbuettel
 

Salut Jean-Louis

On 17 March 2019 at 03:54, kumpelka78@gmail.com wrote:
| I tried to price a bond with negative rates (current economic context in eurozone...).
|
| I encounter this error :
|
| Error in FixedRateWithRebuiltCurve(bond, rates, schedule, calc, c(discountCurve$table$date),  : 
|
|   invalid value ( -0.003 ) at index 0
|
| I found these answers on StackOverflow but I don't understand how it contributes to correct the problem (especially, I don't understand if I need to install QuantLib "in addition to" the R package :
| https://stackoverflow.com/questions/51986978/rquantlib-fixedratebond-function-with-negative-rates
|
| Any help will be welcome !

I would try to distill out a self-contained C++ example and ask on the
quantlib side. Here in RQuantLib we really only expose the pricers and do
not alter them (hopefully -- by instantiating from we could of course
introduce subtle bugs in the wrapper/glue code).

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org

1 - 20 of 83