RQuantLib/ 0000755 0001762 0000144 00000000000 13200552033 012104 5 ustar ligges users RQuantLib/inst/ 0000755 0001762 0000144 00000000000 13200460111 013054 5 ustar ligges users RQuantLib/inst/Boost_LICENSE.TXT 0000644 0001762 0000144 00000002473 12271333436 015733 0 ustar ligges users Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
RQuantLib/inst/NEWS.Rd 0000644 0001762 0000144 00000014665 13200460111 014133 0 ustar ligges users \name{NEWS}
\title{News for Package \pkg{RQuantLib}}
\newcommand{\ghpr}{\href{https://github.com/eddelbuettel/rquantlib/pull/#1}{##1}}
\newcommand{\ghit}{\href{https://github.com/eddelbuettel/rquantlib/issues/#1}{##1}}
\section{Changes in RQuantLib version 0.4.4 (2016-xx-xx)}{
\itemize{
\item Changes in RQuantLib code:
\itemize{
\item Equity options can now be analyzed via discrete dividends
through two vectors of dividend dates and values (Francois
Cocquemas in \ghpr{73} fixing \ghit{72})
\item Some package and dependency information was updated in files
\code{DESCRIPTION} and \code{NAMESPACE}.
\item The new \code{Date(time)Vector} classes introduced with Rcpp
0.12.8 are now used when available.
\item Minor corrections were applied to \code{BKTree}, to vanilla
options for the case of intraday time stamps, to the
\code{SabrSwaption} documentation, and to bond utilities for the
most recent QuantLib release.
}
}
}
\section{Changes in RQuantLib version 0.4.3 (2016-08-19)}{
\itemize{
\item Changes in RQuantLib code:
\itemize{
\item Discount curve creation has been made more general by
allowing additional arguments for day counter and fixed and
floating frequency (contributed by Terry Leitch in \ghpr{31},
plus some work by Dirk in \ghpr{32}).
\item Swap leg parameters are now in combined variable and allow
textual description (Terry Leitch in \ghpr{34} and \ghpr{35})
\item BermudanSwaption has been modfied to take option expiration
and swap tenors in order to enable more general swaption structure
pricing; a more general search for the swaptions was developed to
accomodate this. Also, a DiscountCurve is allowed as an
alternative to market quotes to reduce computation time for a
portfolio on a given valuation date (Terry Leitch in \ghpr{42}
closing issue \ghpr{41}).
\item A new AffineSwaption model was added with similar interface
to BermudanSwaption but allowing for valuation of a European
exercise swaption utlizing the same affine methods available in
BermudanSwaption. AffineSwaption will also value a Bermudan
swaption, but does not take rate market quotes to build a term
structure and a DiscountCurve object is required (Terry Leitch in
\ghpr{43}).
\item Swap tenors can now be defined up to 100 years (Terry Leitch
in \ghpr{48} fising issue \ghit{46}).
\item Additional (shorter term) swap tenors are now defined
(Guillaume Horel in \ghpr{49}, \ghpr{54}, \ghpr{55}).
\item New SABR swaption pricer (Terry Leitch in \ghpr{60} and
\ghpr{64}, small follow-up by Dirk in \ghpr{65}).
\item Use of Travis CI has been updated and switch to maintained
fork of deprecated mainline.
}
}
}
\section{Changes in RQuantLib version 0.4.2 (2015-12-30)}{
\itemize{
\item Changes in RQuantLib code:
\itemize{
\item Intra-day times are now available if QuantLib 1.7 or later is
used, and has been configured with \code{--enable-intraday}
\item New helper functions \code{getQuantLibVersion()} and
\code{getQuantLibCapabilties()}
\item New package startup code detects and warns about outdated
QuantLib versions, or missing intra-day capability, unless not
interactive.
\item The missing \code{Monthly} parameter has been added to
\code{matchFrequency} (fixing issue ticket \ghit{19})
}
}
}
\section{Changes in RQuantLib version 0.4.1 (2015-09-11)}{
\itemize{
\item Changes in RQuantLib code:
\itemize{
\item A simple \CRANpkg{shiny} application is now included in the
directory \code{shiny/DiscountCurve/} and accessible via the new
demo function \code{ShinyDiscountCurve}.
\item The option surface plotting example in \code{arrays.R} now
checks for \CRANpkg{rgl} by using \code{requireNamespace}.
\item The files \code{NAMESPACE} and \code{DESCRIPTION} have been
updated to reflect all the suggestions of \code{R CMD check}.
\item The Travis CI tests now use binary Debian packages for all
package dependencies making the tests a little faster.
}
}
}
\section{Changes in RQuantLib version 0.4.0 (2014-12-01)}{
\itemize{
\item Changes in RQuantLib code:
\itemize{
\item All function interfaces have been rewritten using \CRANpkg{Rcpp}
Attributes. No \code{SEXP} remain in the function signatures. This
make the code shorter, more readable and more easily extensible.
\item The header files have been reorganized so that plugin use is
possible. An \code{impl.h} files is imported once for each compilation
unit: for RQuantLib from the file \code{src/dates.cpp} directory, from
a sourced file via a \code{#define} set by the plugin wrapper.
\item \code{as<>()} and \code{wrap()} converters have added for
QuantLib Date types.
\item Plugin support has been added, allowing more ad-hoc use via Rcpp
Attributes.
\item Several Fixed Income functions have been added, and/or
rewritten to better match the QuantLib signatures; this was done
mostly by Michele Salvadore.
\item Several Date and Calendar functions have been added.
\item Calendar support has been greatly expanded thanks to Danilo
Dias da Silva.
\item Exported curve objects are now more parsimonious and advance
entries in the \code{table} object roughly one business month at a
time.
\item The \code{DiscountCurve} and \code{Bond} curve construction
has been fixed via a corrected evaluation date and omitted the
two-year swap rate, as suggested by Luigi Ballabio.
\item The \code{NAMESPACE} file has a tighter rule for export of
\code{*.default} functions, as suggested by Bill Dunlap
\item Builds now use OpenMP where available.
\item The package now depends on QuantLib 1.4.0 or later.
}
\item Changes in RQuantLib tests:
\itemize{
\item New unit tests for dates have been added.
\item C++ code for the unit tests has also been converted to
\CRANpkg{Rcpp} Attributes use; a helper function
\code{unitTestSetup()} has been added.
\item Continuous Integration via Travis is now enabled from the
GitHub repo.
}
\item Changes in RQuantLib documentation:
\itemize{
\item This NEWS file has been added. Better late than never, as
they say.
}
}
}
RQuantLib/inst/shiny/ 0000755 0001762 0000144 00000000000 12744670072 014233 5 ustar ligges users RQuantLib/inst/shiny/DiscountCurve/ 0000755 0001762 0000144 00000000000 12466654326 017035 5 ustar ligges users RQuantLib/inst/shiny/DiscountCurve/ui.R 0000644 0001762 0000144 00000002055 12466654326 017577 0 ustar ligges users library(shiny)
shinyUI(fluidPage(
## Application title
titlePanel("Simple DiscountCurve Example from RQuantLib"),
## Sidebar with controls to select parameters
sidebarLayout(
sidebarPanel(
radioButtons("interpolation", "Interpolation type:",
c("loglinear" = "loglinear",
"linear" = "linear",
"spline" = "spline")),
br(),
radioButtons("curve", "Curve type:",
c("forwards" = "forwards",
"zero rates" = "zerorates",
"discounts" = "discounts"))
),
## Show a tabset that includes a plot, summary, and table view
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Plot", plotOutput("plot")),
tabPanel("Summary", verbatimTextOutput("summary")),
tabPanel("Table", tableOutput("table"))
)
)
)
))
RQuantLib/inst/shiny/DiscountCurve/server.R 0000644 0001762 0000144 00000004443 12466654326 020473 0 ustar ligges users
library(shiny)
library(RQuantLib)
shinyServer(function(input, output) {
## This data is taken from sample code shipped with QuantLib 0.9.7
## from the file Examples/Swap/swapvaluation
params <- list(tradeDate=as.Date('2004-09-20'),
settleDate=as.Date('2004-09-22'),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
setEvaluationDate(as.Date("2004-09-20"))
## We get numerical issue for the spline interpolation if we add
## any on of these three extra futures -- the original example
## creates different curves based on different deposit, fra, futures
## and swap data
## Removing s2y helps, as kindly pointed out by Luigi Ballabio
tsQuotes <- list(d1w = 0.0382,
d1m = 0.0372,
d3m = 0.0363,
d6m = 0.0353,
d9m = 0.0348,
d1y = 0.0345,
fut1=96.2875,
fut2=96.7875,
fut3=96.9875,
fut4=96.6875,
fut5=96.4875,
fut6=96.3875,
fut7=96.2875,
fut8=96.0875,
## s2y = 0.037125,
s3y = 0.0398,
s5y = 0.0443,
s10y = 0.05165,
s15y = 0.055175)
times <- seq(0,10,.1)
## Reactive expression to generate the requested curves.
data <- reactive({
params$interpHow <- input$interpolation
curve <- DiscountCurve(params, tsQuotes, times)
})
## Generate a plot of the data.
output$plot <- renderPlot({
interp <- input$interpolation
crv <- input$curve
dat <- data()
plot(dat[["times"]], dat[[crv]],
type='l', main=paste(interp, crv),
ylab=crv, xlab="time in years")
})
## Generate a summary of the data
output$summary <- renderPrint({
dat <- data()
cat("Return Object Structure\n")
str(dat)
cat("\n\nSummary of first four elements\n")
summary(data.frame(dat[1:4]))
})
## Generate an HTML table view of the data
output$table <- renderTable({
data.frame(x=data()[1:4])
})
})
RQuantLib/inst/shiny/SabrSwaption/ 0000755 0001762 0000144 00000000000 12757140057 016646 5 ustar ligges users RQuantLib/inst/shiny/SabrSwaption/ui.R 0000644 0001762 0000144 00000002260 12744670072 017407 0 ustar ligges users
# This is the user-interface definition of a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(shiny)
shinyUI(fluidPage(
# Application title
titlePanel("SABR Vol Cube Tool"),
checkboxGroupInput("expiries", label = h3("Option Expiries"), inline=T,
choices=list("1M"="1M","3M"="3M","6M"="6M","1Y"="1Y" , "2Y"="2Y", "3Y"="3Y",
"4Y"="4Y", "5Y"="5Y", "6Y"="6Y", "7Y"="7Y", "8Y"="8Y", "9Y"="9Y","10Y"="10Y"),
# selected = c("1M","3M","6M","1Y" , "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y","10Y")),
selected = c( "3Y", "4Y","5Y")),
checkboxGroupInput("tenors", label = h3("Swap Tenors"), inline=T,
choices=list("1Y"="1Y" , "2Y"="2Y", "5Y"="5Y","10Y"="10Y","15Y"="15Y","20Y"="20Y","30Y"="30Y"),
#selected = c("1Y" , "2Y", "5Y", "10Y","15Y","20Y","30Y")),
selected = c( "5Y")),
checkboxInput("bermudan", label = "Bermudan Exercise?", value = F),
# Show a plot of the generated distribution
mainPanel(
rHandsontableOutput(outputId="table")
)
))
RQuantLib/inst/shiny/SabrSwaption/server.R 0000644 0001762 0000144 00000013006 12757140057 020277 0 ustar ligges users
# This is the server logic for a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#
library(rhandsontable)
library(lubridate)
library(reshape2)
library(zoo)
library(data.table)
data(vcube)
data(tsQuotes)
library(shiny)
assignInNamespace("volDF2CubeK",source("volDF2CubeK.R"),"RQuantLib")
# tsQuotes <- list(
# d1w =0.004,
# d1y=.0091,
# s2y=.0115,
# s3y=.0138,
# s4y =.011349,
# s5y =0.012375,
# s6y =.0134,
# s7y=.01446,
# s10y =0.016829,
# s15y =0.01944,
# s30y=.02178,
# s50y=.02205)
tsQuoteUp01=lapply(tsQuotes,"+",.0001)
tsQuoteDn01=lapply(tsQuotes,"-",.0001)
setEvaluationDate(as.Date("2016-4-30"))
params <- list(tradeDate=as.Date('2016-4-28'),
settleDate=as.Date('2016-4-30'),
payFixed=TRUE,
#european=F,
dt=.25,
interpWhat="discount",
interpHow="loglinear")
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")
times<-times <- seq(0,49.5,.25)
dcurve <- DiscountCurve(params, tsQuotes, times=times,legparams)
dcurveUp01 <- DiscountCurve(params, tsQuoteUp01, times=times,legparams)
dcurveDn01 <- DiscountCurve(params, tsQuoteDn01, times=times,legparams)
expiriesY=c(1/12,.25,.5,1,2,3,4,5,6,7,8,9,10)
expiriesM=c(1,3,6,0,0,0,0,0,0,0,0,0,0)
expLvl=c("1M","3M","6M","1Y" , "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y","10Y")
tenorLvl=c("1Y" , "2Y", "5Y", "10Y","15Y","20Y","30Y")
tenors=c(1,2,5,10,15,20,30)
shinyServer(function(input, output) {
inputVol<-vcube
output$table<- renderRHandsontable({
tbl2=inputVol
tbl2$Expiry<-factor(tbl2$Expiry,level=expLvl)
tbl2$Tenor=factor(tbl2$Tenor,level=tenorLvl)
tbl2=subset(tbl2,Expiry %in% input$expiries)
tbl2=subset(tbl2,Tenor %in% input$tenors)
tbl2=tbl2[with(tbl2,order(Expiry,Tenor,-Spread))]
tbl2[,"payer"]<- -.0000001
tbl2[,"payerDV01"]<- -.0000001
tbl2[,"payerCnvx"]<- -.0000001
tbl2[,"rcv"]<- -.0000001
tbl2[,"rcvDV01"]<- -.0000001
tbl2[,"rcvCnvx"]<- -.0000001
tbl2[,"payerVega"]<- -.0000001
tbl2[,"rcvVega"]<- -.0000001
tbl2[,"sabrVol"]<- -.0000001
tbl2[,"strike"]<- -.00000001
for(expire in input$expiries){
for(tenor in input$tenors){
expIDX=match(expire,expLvl)
expiry=params$settleDate;
if(expIDX>3){
year(expiry)=year(expiry)+expiriesY[expIDX]
} else{
expiry=expiry%m+% months(expiriesM[expIDX])
}
tenorIDX=match(tenor,tenorLvl)
tenorVal=expiry;
params$european=!input$bermudan
year(tenorVal)=year(tenorVal)+tenors[tenorIDX]
params$expiryDate=expiry
if(params$european){params$startDate=expiry;}else{params$startDate=params$settleDate}
params$maturity=tenorVal
params$strike=.03
tmp2<-SabrSwaption(params, dcurve, inputVol,legparams, vega=T)
fwd1=tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==0,]$Strike
fwdDiff=fwd1-tmp2$atmRate
for(spread in unique(tbl2$Spread)){
params$strike=tmp2$atmRate+spread/10000
if(params$strike>0){
tmp<-SabrSwaption(params, dcurve, inputVol,legparams,tsUp01=dcurveUp01,tsDn01=dcurveDn01,vega=T)
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,rcv:=signif(tmp$rcv,digits=4)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,payer:=signif(tmp$pay,digits=4)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,rcvDV01:=signif(tmp$rcvDV01,digits=6)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,rcvCnvx:=signif(tmp$rcvCnvx,digits=6)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,payerDV01:=signif(tmp$payDV01,digits=6)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,payerCnvx:=signif(tmp$payCnvx,digits=6)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,rcvVega:=signif(tmp$rcvVega,digits=4)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,payerVega:=signif(tmp$payVega,digits=4)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,sabrVol:=signif(tmp$sigma,digits=3)]
tbl2[tbl2$Expiry==expire & tbl2$Tenor== tenor & tbl2$Spread==spread,strike:=signif(params$strike,digits=4)]
}
}
}
}
tbl2=tbl2[,c("Expiry","Tenor","Spread","strike","LogNormalVol","sabrVol","payer","payerDV01","payerCnvx","payerVega","rcv","rcvDV01","rcvCnvx","rcvVega"),with=F]
numRow=length(tbl2)
rhandsontable(tbl2,readOnly = F,rowHeaders=NULL,selectCallback = TRUE,halign="htCenter")%>%
hot_col("strike", format = "0.0000") %>%
hot_col("LogNormalVol", format = "0.00") %>%
hot_col("sabrVol", format = "0.00") %>%
hot_col("payer", format = "0.0000") %>%
hot_col("payerDV01", format = "0.000000") %>%
hot_col("payerCnvx", format = "0.000000") %>%
hot_col("payerVega", format = "0.0000") %>%
hot_col("rcv", format = "0.000")%>%
hot_col("rcvDV01", format = "0.00000")%>%
hot_col("rcvCnvx", format = "0.00000")%>%
hot_col("rcvVega", format = "0.0000")
})
})
RQuantLib/inst/shiny/SabrSwaption/README.md 0000755 0001762 0000144 00000000006 12744670072 020125 0 ustar ligges users # cftc RQuantLib/inst/shiny/SabrSwaption/volcube.csv 0000644 0001762 0000144 00000055230 12744670072 021030 0 ustar ligges users Expiry,Tenor,Spread,LogNormalVol
10Y,10Y,-200,0.6897
10Y,10Y,-150,0.4973
10Y,10Y,-100,0.4034
10Y,10Y,-75,0.3703
10Y,10Y,-50,0.3428
10Y,10Y,-25,0.3199
10Y,10Y,0,0.3007
10Y,10Y,25,0.2849
10Y,10Y,50,0.2719
10Y,10Y,75,0.2613
10Y,10Y,100,0.2527
10Y,10Y,150,0.2409
10Y,10Y,200,0.2342
1M,10Y,-200,NA
1M,10Y,-150,1.5201
1M,10Y,-100,0.8195
1M,10Y,-75,0.6487
1M,10Y,-50,0.5274
1M,10Y,-25,0.4435
1M,10Y,-20,0.4306
1M,10Y,-15,0.4190
1M,10Y,-10,0.4087
1M,10Y,-5,0.3997
1M,10Y,0,0.3922
1M,10Y,5,0.3859
1M,10Y,10,0.3810
1M,10Y,15,0.3773
1M,10Y,20,0.3749
1M,10Y,25,0.3734
1M,10Y,50,0.3786
1M,10Y,75,0.3982
1M,10Y,100,0.4237
1M,10Y,150,0.4732
1M,10Y,200,0.5186
1Y,10Y,-200,NA
1Y,10Y,-150,0.9561
1Y,10Y,-100,0.6572
1Y,10Y,-75,0.5768
1Y,10Y,-50,0.5167
1Y,10Y,-25,0.4704
1Y,10Y,0,0.4343
1Y,10Y,25,0.4066
1Y,10Y,50,0.3858
1Y,10Y,75,0.3706
1Y,10Y,100,0.3598
1Y,10Y,150,0.3478
1Y,10Y,200,0.3437
2Y,10Y,-200,2.1527
2Y,10Y,-150,0.8126
2Y,10Y,-100,0.5968
2Y,10Y,-75,0.5326
2Y,10Y,-50,0.4831
2Y,10Y,-25,0.4438
2Y,10Y,0,0.4123
2Y,10Y,25,0.3869
2Y,10Y,50,0.3666
2Y,10Y,75,0.3506
2Y,10Y,100,0.3381
2Y,10Y,150,0.3215
2Y,10Y,200,0.3126
3M,10Y,-200,NA
3M,10Y,-150,1.2754
3M,10Y,-100,0.7706
3M,10Y,-75,0.6444
3M,10Y,-50,0.5518
3M,10Y,-25,0.4839
3M,10Y,-20,0.4730
3M,10Y,-15,0.4630
3M,10Y,-10,0.4537
3M,10Y,-5,0.4454
3M,10Y,0,0.4379
3M,10Y,5,0.4311
3M,10Y,10,0.4252
3M,10Y,15,0.4201
3M,10Y,20,0.4156
3M,10Y,25,0.4118
3M,10Y,50,0.4015
3M,10Y,75,0.4016
3M,10Y,100,0.4075
3M,10Y,150,0.4264
3M,10Y,200,0.4467
3Y,10Y,-200,1.2763
3Y,10Y,-150,0.7217
3Y,10Y,-100,0.5521
3Y,10Y,-75,0.4980
3Y,10Y,-50,0.4554
3Y,10Y,-25,0.4210
3Y,10Y,0,0.3928
3Y,10Y,25,0.3699
3Y,10Y,50,0.3511
3Y,10Y,75,0.3358
3Y,10Y,100,0.3237
3Y,10Y,150,0.3065
3Y,10Y,200,0.2965
4Y,10Y,-200,1.0370
4Y,10Y,-150,0.6589
4Y,10Y,-100,0.5163
4Y,10Y,-75,0.4691
4Y,10Y,-50,0.4310
4Y,10Y,-25,0.4000
4Y,10Y,0,0.3743
4Y,10Y,25,0.3532
4Y,10Y,50,0.3357
4Y,10Y,75,0.3214
4Y,10Y,100,0.3098
4Y,10Y,150,0.2932
4Y,10Y,200,0.2831
5Y,10Y,-200,0.9182
5Y,10Y,-150,0.6181
5Y,10Y,-100,0.4915
5Y,10Y,-75,0.4486
5Y,10Y,-50,0.4135
5Y,10Y,-25,0.3846
5Y,10Y,0,0.3606
5Y,10Y,25,0.3408
5Y,10Y,50,0.3244
5Y,10Y,75,0.3110
5Y,10Y,100,0.3001
5Y,10Y,150,0.2844
5Y,10Y,200,0.2749
6M,10Y,-200,NA
6M,10Y,-150,1.1043
6M,10Y,-100,0.7136
6M,10Y,-75,0.6130
6M,10Y,-50,0.5387
6M,10Y,-25,0.4832
6M,10Y,0,0.4428
6M,10Y,25,0.4150
6M,10Y,50,0.3976
6M,10Y,75,0.3880
6M,10Y,100,0.3838
6M,10Y,150,0.3847
6M,10Y,200,0.3910
6Y,10Y,-200,0.8326
6Y,10Y,-150,0.5803
6Y,10Y,-100,0.4661
6Y,10Y,-75,0.4267
6Y,10Y,-50,0.3942
6Y,10Y,-25,0.3672
6Y,10Y,0,0.3447
6Y,10Y,25,0.3261
6Y,10Y,50,0.3107
6Y,10Y,75,0.2981
6Y,10Y,100,0.2879
6Y,10Y,150,0.2732
6Y,10Y,200,0.2645
7Y,10Y,-200,0.7789
7Y,10Y,-150,0.5530
7Y,10Y,-100,0.4466
7Y,10Y,-75,0.4094
7Y,10Y,-50,0.3787
7Y,10Y,-25,0.3531
7Y,10Y,0,0.3317
7Y,10Y,25,0.3140
7Y,10Y,50,0.2994
7Y,10Y,75,0.2875
7Y,10Y,100,0.2778
7Y,10Y,150,0.2641
7Y,10Y,200,0.2560
8Y,10Y,-200,0.7418
8Y,10Y,-150,0.5313
8Y,10Y,-100,0.4301
8Y,10Y,-75,0.3945
8Y,10Y,-50,0.3651
8Y,10Y,-25,0.3405
8Y,10Y,0,0.3201
8Y,10Y,25,0.3032
8Y,10Y,50,0.2891
8Y,10Y,75,0.2776
8Y,10Y,100,0.2684
8Y,10Y,150,0.2554
8Y,10Y,200,0.2479
9Y,10Y,-200,0.7122
9Y,10Y,-150,0.5128
9Y,10Y,-100,0.4158
9Y,10Y,-75,0.3815
9Y,10Y,-50,0.3532
9Y,10Y,-25,0.3295
9Y,10Y,0,0.3098
9Y,10Y,25,0.2935
9Y,10Y,50,0.2800
9Y,10Y,75,0.2689
9Y,10Y,100,0.2601
9Y,10Y,150,0.2478
9Y,10Y,200,0.2407
10Y,15Y,-200,0.6438
10Y,15Y,-150,0.4650
10Y,15Y,-100,0.3758
10Y,15Y,-75,0.3441
10Y,15Y,-50,0.3178
10Y,15Y,-25,0.2958
10Y,15Y,0,0.2775
10Y,15Y,25,0.2626
10Y,15Y,50,0.2503
10Y,15Y,75,0.2405
10Y,15Y,100,0.2329
10Y,15Y,150,0.2228
10Y,15Y,200,0.2179
1M,15Y,-200,NA
1M,15Y,-150,1.0595
1M,15Y,-100,0.6597
1M,15Y,-75,0.5378
1M,15Y,-50,0.4454
1M,15Y,-25,0.3782
1M,15Y,-20,0.3675
1M,15Y,-15,0.3578
1M,15Y,-10,0.3492
1M,15Y,-5,0.3417
1M,15Y,0,0.3352
1M,15Y,5,0.3299
1M,15Y,10,0.3256
1M,15Y,15,0.3224
1M,15Y,20,0.3202
1M,15Y,25,0.3189
1M,15Y,50,0.3234
1M,15Y,75,0.3407
1M,15Y,100,0.3637
1M,15Y,150,0.4089
1M,15Y,200,0.4506
1Y,15Y,-200,1.4169
1Y,15Y,-150,0.7512
1Y,15Y,-100,0.5573
1Y,15Y,-75,0.4964
1Y,15Y,-50,0.4488
1Y,15Y,-25,0.4109
1Y,15Y,0,0.3809
1Y,15Y,25,0.3576
1Y,15Y,50,0.3400
1Y,15Y,75,0.3274
1Y,15Y,100,0.3186
1Y,15Y,150,0.3097
1Y,15Y,200,0.3076
2Y,15Y,-200,1.0972
2Y,15Y,-150,0.6758
2Y,15Y,-100,0.5177
2Y,15Y,-75,0.4665
2Y,15Y,-50,0.4258
2Y,15Y,-25,0.3929
2Y,15Y,0,0.3660
2Y,15Y,25,0.3443
2Y,15Y,50,0.3270
2Y,15Y,75,0.3134
2Y,15Y,100,0.3030
2Y,15Y,150,0.2898
2Y,15Y,200,0.2833
3M,15Y,-200,2.7078
3M,15Y,-150,0.9321
3M,15Y,-100,0.6341
3M,15Y,-75,0.5416
3M,15Y,-50,0.4699
3M,15Y,-25,0.4154
3M,15Y,-20,0.4064
3M,15Y,-15,0.3982
3M,15Y,-10,0.3905
3M,15Y,-5,0.3837
3M,15Y,0,0.3775
3M,15Y,5,0.3719
3M,15Y,10,0.3670
3M,15Y,15,0.3628
3M,15Y,20,0.3591
3M,15Y,25,0.3560
3M,15Y,50,0.3482
3M,15Y,75,0.3497
3M,15Y,100,0.3565
3M,15Y,150,0.3763
3M,15Y,200,0.3974
3Y,15Y,-200,0.9383
3Y,15Y,-150,0.6228
3Y,15Y,-100,0.4880
3Y,15Y,-75,0.4426
3Y,15Y,-50,0.4062
3Y,15Y,-25,0.3763
3Y,15Y,0,0.3518
3Y,15Y,25,0.3316
3Y,15Y,50,0.3152
3Y,15Y,75,0.3020
3Y,15Y,100,0.2917
3Y,15Y,150,0.2777
3Y,15Y,200,0.2702
4Y,15Y,-200,0.8387
4Y,15Y,-150,0.5798
4Y,15Y,-100,0.4612
4Y,15Y,-75,0.4201
4Y,15Y,-50,0.3864
4Y,15Y,-25,0.3588
4Y,15Y,0,0.3358
4Y,15Y,25,0.3169
4Y,15Y,50,0.3013
4Y,15Y,75,0.2887
4Y,15Y,100,0.2787
4Y,15Y,150,0.2649
4Y,15Y,200,0.2572
5Y,15Y,-200,0.7816
5Y,15Y,-150,0.5525
5Y,15Y,-100,0.4430
5Y,15Y,-75,0.4045
5Y,15Y,-50,0.3728
5Y,15Y,-25,0.3464
5Y,15Y,0,0.3246
5Y,15Y,25,0.3066
5Y,15Y,50,0.2917
5Y,15Y,75,0.2797
5Y,15Y,100,0.2702
5Y,15Y,150,0.2571
5Y,15Y,200,0.2499
6M,15Y,-200,1.9107
6M,15Y,-150,0.8340
6M,15Y,-100,0.5954
6M,15Y,-75,0.5210
6M,15Y,-50,0.4632
6M,15Y,-25,0.4184
6M,15Y,0,0.3851
6M,15Y,25,0.3621
6M,15Y,50,0.3478
6M,15Y,75,0.3404
6M,15Y,100,0.3379
6M,15Y,150,0.3408
6M,15Y,200,0.3484
6Y,15Y,-200,0.7338
6Y,15Y,-150,0.5267
6Y,15Y,-100,0.4247
6Y,15Y,-75,0.3885
6Y,15Y,-50,0.3585
6Y,15Y,-25,0.3333
6Y,15Y,0,0.3125
6Y,15Y,25,0.2952
6Y,15Y,50,0.2811
6Y,15Y,75,0.2697
6Y,15Y,100,0.2606
6Y,15Y,150,0.2482
6Y,15Y,200,0.2416
7Y,15Y,-200,0.7015
7Y,15Y,-150,0.5072
7Y,15Y,-100,0.4102
7Y,15Y,-75,0.3757
7Y,15Y,-50,0.3469
7Y,15Y,-25,0.3227
7Y,15Y,0,0.3027
7Y,15Y,25,0.2861
7Y,15Y,50,0.2725
7Y,15Y,75,0.2616
7Y,15Y,100,0.2529
7Y,15Y,150,0.2413
7Y,15Y,200,0.2351
8Y,15Y,-200,0.6812
8Y,15Y,-150,0.4927
8Y,15Y,-100,0.3983
8Y,15Y,-75,0.3646
8Y,15Y,-50,0.3366
8Y,15Y,-25,0.3133
8Y,15Y,0,0.2938
8Y,15Y,25,0.2779
8Y,15Y,50,0.2649
8Y,15Y,75,0.2544
8Y,15Y,100,0.2462
8Y,15Y,150,0.2354
8Y,15Y,200,0.2300
9Y,15Y,-200,0.6609
9Y,15Y,-150,0.4783
9Y,15Y,-100,0.3867
9Y,15Y,-75,0.3541
9Y,15Y,-50,0.3271
9Y,15Y,-25,0.3045
9Y,15Y,0,0.2857
9Y,15Y,25,0.2702
9Y,15Y,50,0.2577
9Y,15Y,75,0.2475
9Y,15Y,100,0.2397
9Y,15Y,150,0.2292
9Y,15Y,200,0.2240
10Y,1Y,-200,0.9112
10Y,1Y,-150,0.5967
10Y,1Y,-100,0.4741
10Y,1Y,-75,0.4335
10Y,1Y,-50,0.4004
10Y,1Y,-25,0.3729
10Y,1Y,0,0.3501
10Y,1Y,25,0.3310
10Y,1Y,50,0.3148
10Y,1Y,75,0.3013
10Y,1Y,100,0.2899
10Y,1Y,150,0.2729
10Y,1Y,200,0.2616
1M,1Y,-200,NA
1M,1Y,-150,NA
1M,1Y,-100,NA
1M,1Y,-75,1.4547
1M,1Y,-50,0.7412
1M,1Y,-25,0.5216
1M,1Y,-20,0.4943
1M,1Y,-15,0.4717
1M,1Y,-10,0.4533
1M,1Y,-5,0.4391
1M,1Y,0,0.4285
1M,1Y,5,0.4213
1M,1Y,10,0.4166
1M,1Y,15,0.4142
1M,1Y,20,0.4139
1M,1Y,25,0.4154
1M,1Y,50,0.4401
1M,1Y,75,0.4710
1M,1Y,100,0.5020
1M,1Y,150,0.5437
1M,1Y,200,0.5704
1Y,1Y,-200,NA
1Y,1Y,-150,NA
1Y,1Y,-100,2.1187
1Y,1Y,-75,1.0539
1Y,1Y,-50,0.7994
1Y,1Y,-25,0.6664
1Y,1Y,-20,0.6470
1Y,1Y,-15,0.6289
1Y,1Y,-10,0.6124
1Y,1Y,-5,0.5975
1Y,1Y,0,0.5835
1Y,1Y,5,0.5707
1Y,1Y,10,0.5589
1Y,1Y,15,0.5479
1Y,1Y,20,0.5378
1Y,1Y,25,0.5285
1Y,1Y,50,0.4917
1Y,1Y,75,0.4674
1Y,1Y,100,0.4513
1Y,1Y,150,0.4345
1Y,1Y,200,0.4285
2Y,1Y,-200,NA
2Y,1Y,-150,NA
2Y,1Y,-100,1.2829
2Y,1Y,-75,0.9560
2Y,1Y,-50,0.7924
2Y,1Y,-25,0.6878
2Y,1Y,-20,0.6712
2Y,1Y,-15,0.6556
2Y,1Y,-10,0.6410
2Y,1Y,-5,0.6272
2Y,1Y,0,0.6143
2Y,1Y,5,0.6020
2Y,1Y,10,0.5906
2Y,1Y,15,0.5798
2Y,1Y,20,0.5694
2Y,1Y,25,0.5597
2Y,1Y,50,0.5181
2Y,1Y,75,0.4861
2Y,1Y,100,0.4613
2Y,1Y,150,0.4274
2Y,1Y,200,0.4076
3M,1Y,-200,NA
3M,1Y,-150,NA
3M,1Y,-100,NA
3M,1Y,-75,1.4071
3M,1Y,-50,0.8456
3M,1Y,-25,0.6451
3M,1Y,-20,0.6197
3M,1Y,-15,0.5978
3M,1Y,-10,0.5786
3M,1Y,-5,0.5623
3M,1Y,0,0.5483
3M,1Y,5,0.5366
3M,1Y,10,0.5268
3M,1Y,15,0.5188
3M,1Y,20,0.5123
3M,1Y,25,0.5071
3M,1Y,50,0.4972
3M,1Y,75,0.5031
3M,1Y,100,0.5159
3M,1Y,150,0.5455
3M,1Y,200,0.5703
3Y,1Y,-200,NA
3Y,1Y,-150,NA
3Y,1Y,-100,1.0590
3Y,1Y,-75,0.8624
3Y,1Y,-50,0.7429
3Y,1Y,-25,0.6593
3Y,1Y,0,0.5972
3Y,1Y,25,0.5491
3Y,1Y,50,0.5111
3Y,1Y,75,0.4806
3Y,1Y,100,0.4561
3Y,1Y,150,0.4204
3Y,1Y,200,0.3973
4Y,1Y,-200,NA
4Y,1Y,-150,1.7981
4Y,1Y,-100,0.8690
4Y,1Y,-75,0.7429
4Y,1Y,-50,0.6568
4Y,1Y,-25,0.5927
4Y,1Y,0,0.5431
4Y,1Y,25,0.5037
4Y,1Y,50,0.4717
4Y,1Y,75,0.4456
4Y,1Y,100,0.4242
4Y,1Y,150,0.3923
4Y,1Y,200,0.3709
5Y,1Y,-200,NA
5Y,1Y,-150,1.1238
5Y,1Y,-100,0.7352
5Y,1Y,-75,0.6463
5Y,1Y,-50,0.5812
5Y,1Y,-25,0.5305
5Y,1Y,0,0.4901
5Y,1Y,25,0.4574
5Y,1Y,50,0.4305
5Y,1Y,75,0.4082
5Y,1Y,100,0.3898
5Y,1Y,150,0.3619
5Y,1Y,200,0.3431
6M,1Y,-200,NA
6M,1Y,-150,NA
6M,1Y,-100,NA
6M,1Y,-75,1.1688
6M,1Y,-50,0.7929
6M,1Y,-25,0.6289
6M,1Y,-20,0.6067
6M,1Y,-15,0.5868
6M,1Y,-10,0.5694
6M,1Y,-5,0.5538
6M,1Y,0,0.5402
6M,1Y,5,0.5280
6M,1Y,10,0.5173
6M,1Y,15,0.5081
6M,1Y,20,0.5001
6M,1Y,25,0.4930
6M,1Y,50,0.4712
6M,1Y,75,0.4633
6M,1Y,100,0.4629
6M,1Y,150,0.4711
6M,1Y,200,0.4833
6Y,1Y,-200,NA
6Y,1Y,-150,0.8859
6Y,1Y,-100,0.6396
6Y,1Y,-75,0.5718
6Y,1Y,-50,0.5200
6Y,1Y,-25,0.4786
6Y,1Y,0,0.4449
6Y,1Y,25,0.4172
6Y,1Y,50,0.3943
6Y,1Y,75,0.3751
6Y,1Y,100,0.3591
6Y,1Y,150,0.3348
6Y,1Y,200,0.3183
7Y,1Y,-200,2.1998
7Y,1Y,-150,0.7689
7Y,1Y,-100,0.5805
7Y,1Y,-75,0.5241
7Y,1Y,-50,0.4797
7Y,1Y,-25,0.4437
7Y,1Y,0,0.4142
7Y,1Y,25,0.3895
7Y,1Y,50,0.3691
7Y,1Y,75,0.3519
7Y,1Y,100,0.3375
7Y,1Y,150,0.3157
7Y,1Y,200,0.3010
8Y,1Y,-200,1.2528
8Y,1Y,-150,0.6938
8Y,1Y,-100,0.5358
8Y,1Y,-75,0.4864
8Y,1Y,-50,0.4467
8Y,1Y,-25,0.4144
8Y,1Y,0,0.3876
8Y,1Y,25,0.3652
8Y,1Y,50,0.3466
8Y,1Y,75,0.3309
8Y,1Y,100,0.3178
8Y,1Y,150,0.2981
8Y,1Y,200,0.2849
9Y,1Y,-200,1.0338
9Y,1Y,-150,0.6393
9Y,1Y,-100,0.5021
9Y,1Y,-75,0.4575
9Y,1Y,-50,0.4217
9Y,1Y,-25,0.3920
9Y,1Y,0,0.3675
9Y,1Y,25,0.3468
9Y,1Y,50,0.3296
9Y,1Y,75,0.3150
9Y,1Y,100,0.3029
9Y,1Y,150,0.2846
9Y,1Y,200,0.2725
10Y,20Y,-200,0.6282
10Y,20Y,-150,0.4504
10Y,20Y,-100,0.3621
10Y,20Y,-75,0.3308
10Y,20Y,-50,0.3049
10Y,20Y,-25,0.2832
10Y,20Y,0,0.2653
10Y,20Y,25,0.2507
10Y,20Y,50,0.2388
10Y,20Y,75,0.2294
10Y,20Y,100,0.2223
10Y,20Y,150,0.2131
10Y,20Y,200,0.2089
1M,20Y,-200,1.7578
1M,20Y,-150,0.9182
1M,20Y,-100,0.5991
1M,20Y,-75,0.4941
1M,20Y,-50,0.4118
1M,20Y,-25,0.3504
1M,20Y,-20,0.3405
1M,20Y,-15,0.3315
1M,20Y,-10,0.3233
1M,20Y,-5,0.3162
1M,20Y,0,0.3100
1M,20Y,5,0.3048
1M,20Y,10,0.3006
1M,20Y,15,0.2975
1M,20Y,20,0.2952
1M,20Y,25,0.2939
1M,20Y,50,0.2978
1M,20Y,75,0.3145
1M,20Y,100,0.3368
1M,20Y,150,0.3808
1M,20Y,200,0.4209
1Y,20Y,-200,1.0880
1Y,20Y,-150,0.6779
1Y,20Y,-100,0.5152
1Y,20Y,-75,0.4611
1Y,20Y,-50,0.4179
1Y,20Y,-25,0.3830
1Y,20Y,0,0.3552
1Y,20Y,25,0.3335
1Y,20Y,50,0.3171
1Y,20Y,75,0.3053
1Y,20Y,100,0.2973
1Y,20Y,150,0.2897
1Y,20Y,200,0.2886
2Y,20Y,-200,0.9368
2Y,20Y,-150,0.6213
2Y,20Y,-100,0.4826
2Y,20Y,-75,0.4360
2Y,20Y,-50,0.3986
2Y,20Y,-25,0.3680
2Y,20Y,0,0.3430
2Y,20Y,25,0.3227
2Y,20Y,50,0.3065
2Y,20Y,75,0.2940
2Y,20Y,100,0.2845
2Y,20Y,150,0.2728
2Y,20Y,200,0.2676
3M,20Y,-200,1.5135
3M,20Y,-150,0.8222
3M,20Y,-100,0.5804
3M,20Y,-75,0.4999
3M,20Y,-50,0.4359
3M,20Y,-25,0.3864
3M,20Y,-20,0.3782
3M,20Y,-15,0.3707
3M,20Y,-10,0.3637
3M,20Y,-5,0.3573
3M,20Y,0,0.3515
3M,20Y,5,0.3463
3M,20Y,10,0.3417
3M,20Y,15,0.3378
3M,20Y,20,0.3343
3M,20Y,25,0.3315
3M,20Y,50,0.3242
3M,20Y,75,0.3259
3M,20Y,100,0.3328
3M,20Y,150,0.3529
3M,20Y,200,0.3745
3Y,20Y,-200,0.8374
3Y,20Y,-150,0.5788
3Y,20Y,-100,0.4575
3Y,20Y,-75,0.4154
3Y,20Y,-50,0.3814
3Y,20Y,-25,0.3535
3Y,20Y,0,0.3304
3Y,20Y,25,0.3115
3Y,20Y,50,0.2961
3Y,20Y,75,0.2839
3Y,20Y,100,0.2745
3Y,20Y,150,0.2621
3Y,20Y,200,0.2559
4Y,20Y,-200,0.7681
4Y,20Y,-150,0.5432
4Y,20Y,-100,0.4342
4Y,20Y,-75,0.3956
4Y,20Y,-50,0.3640
4Y,20Y,-25,0.3378
4Y,20Y,0,0.3162
4Y,20Y,25,0.2984
4Y,20Y,50,0.2838
4Y,20Y,75,0.2722
4Y,20Y,100,0.2630
4Y,20Y,150,0.2510
4Y,20Y,200,0.2447
5Y,20Y,-200,0.7311
5Y,20Y,-150,0.5223
5Y,20Y,-100,0.4191
5Y,20Y,-75,0.3823
5Y,20Y,-50,0.3519
5Y,20Y,-25,0.3269
5Y,20Y,0,0.3060
5Y,20Y,25,0.2889
5Y,20Y,50,0.2750
5Y,20Y,75,0.2638
5Y,20Y,100,0.2552
5Y,20Y,150,0.2438
5Y,20Y,200,0.2380
6M,20Y,-200,1.2817
6M,20Y,-150,0.7434
6M,20Y,-100,0.5478
6M,20Y,-75,0.4828
6M,20Y,-50,0.4311
6M,20Y,-25,0.3905
6M,20Y,0,0.3598
6M,20Y,25,0.3384
6M,20Y,50,0.3252
6M,20Y,75,0.3185
6M,20Y,100,0.3164
6M,20Y,150,0.3200
6M,20Y,200,0.3281
6Y,20Y,-200,0.7000
6Y,20Y,-150,0.5036
6Y,20Y,-100,0.4050
6Y,20Y,-75,0.3698
6Y,20Y,-50,0.3406
6Y,20Y,-25,0.3164
6Y,20Y,0,0.2964
6Y,20Y,25,0.2799
6Y,20Y,50,0.2665
6Y,20Y,75,0.2557
6Y,20Y,100,0.2475
6Y,20Y,150,0.2366
6Y,20Y,200,0.2313
7Y,20Y,-200,0.6771
7Y,20Y,-150,0.4885
7Y,20Y,-100,0.3933
7Y,20Y,-75,0.3594
7Y,20Y,-50,0.3312
7Y,20Y,-25,0.3077
7Y,20Y,0,0.2883
7Y,20Y,25,0.2724
7Y,20Y,50,0.2594
7Y,20Y,75,0.2492
7Y,20Y,100,0.2412
7Y,20Y,150,0.2309
7Y,20Y,200,0.2258
8Y,20Y,-200,0.6607
8Y,20Y,-150,0.4760
8Y,20Y,-100,0.3829
8Y,20Y,-75,0.3498
8Y,20Y,-50,0.3223
8Y,20Y,-25,0.2995
8Y,20Y,0,0.2807
8Y,20Y,25,0.2651
8Y,20Y,50,0.2527
8Y,20Y,75,0.2428
8Y,20Y,100,0.2351
8Y,20Y,150,0.2255
8Y,20Y,200,0.2210
9Y,20Y,-200,0.6429
9Y,20Y,-150,0.4625
9Y,20Y,-100,0.3722
9Y,20Y,-75,0.3401
9Y,20Y,-50,0.3135
9Y,20Y,-25,0.2913
9Y,20Y,0,0.2729
9Y,20Y,25,0.2579
9Y,20Y,50,0.2458
9Y,20Y,75,0.2362
9Y,20Y,100,0.2288
9Y,20Y,150,0.2195
9Y,20Y,200,0.2151
10Y,2Y,-200,0.8560
10Y,2Y,-150,0.5773
10Y,2Y,-100,0.4615
10Y,2Y,-75,0.4226
10Y,2Y,-50,0.3908
10Y,2Y,-25,0.3643
10Y,2Y,0,0.3424
10Y,2Y,25,0.3238
10Y,2Y,50,0.3084
10Y,2Y,75,0.2954
10Y,2Y,100,0.2847
10Y,2Y,150,0.2688
10Y,2Y,200,0.2585
1M,2Y,-200,NA
1M,2Y,-150,NA
1M,2Y,-100,NA
1M,2Y,-75,1.1581
1M,2Y,-50,0.7831
1M,2Y,-25,0.6093
1M,2Y,-20,0.5863
1M,2Y,-15,0.5665
1M,2Y,-10,0.5497
1M,2Y,-5,0.5359
1M,2Y,0,0.5246
1M,2Y,5,0.5153
1M,2Y,10,0.5084
1M,2Y,15,0.5028
1M,2Y,20,0.4991
1M,2Y,25,0.4964
1M,2Y,50,0.5005
1M,2Y,75,0.5188
1M,2Y,100,0.5391
1M,2Y,150,0.5748
1M,2Y,200,0.6021
1Y,2Y,-200,NA
1Y,2Y,-150,NA
1Y,2Y,-100,1.4312
1Y,2Y,-75,0.9778
1Y,2Y,-50,0.7853
1Y,2Y,-25,0.6717
1Y,2Y,-20,0.6541
1Y,2Y,-15,0.6380
1Y,2Y,-10,0.6228
1Y,2Y,-5,0.6089
1Y,2Y,0,0.5959
1Y,2Y,5,0.5839
1Y,2Y,10,0.5725
1Y,2Y,15,0.5620
1Y,2Y,20,0.5522
1Y,2Y,25,0.5431
1Y,2Y,50,0.5057
1Y,2Y,75,0.4795
1Y,2Y,100,0.4613
1Y,2Y,150,0.4401
1Y,2Y,200,0.4310
2Y,2Y,-200,NA
2Y,2Y,-150,NA
2Y,2Y,-100,1.0852
2Y,2Y,-75,0.8630
2Y,2Y,-50,0.7339
2Y,2Y,-25,0.6466
2Y,2Y,-20,0.6323
2Y,2Y,-15,0.6190
2Y,2Y,-10,0.6063
2Y,2Y,-5,0.5944
2Y,2Y,0,0.5830
2Y,2Y,5,0.5724
2Y,2Y,10,0.5623
2Y,2Y,15,0.5529
2Y,2Y,20,0.5437
2Y,2Y,25,0.5352
2Y,2Y,50,0.4980
2Y,2Y,75,0.4693
2Y,2Y,100,0.4467
2Y,2Y,150,0.4157
2Y,2Y,200,0.3974
3M,2Y,-200,NA
3M,2Y,-150,NA
3M,2Y,-100,NA
3M,2Y,-75,1.1906
3M,2Y,-50,0.8598
3M,2Y,-25,0.6965
3M,2Y,-20,0.6737
3M,2Y,-15,0.6534
3M,2Y,-10,0.6355
3M,2Y,-5,0.6196
3M,2Y,0,0.6054
3M,2Y,5,0.5929
3M,2Y,10,0.5821
3M,2Y,15,0.5726
3M,2Y,20,0.5646
3M,2Y,25,0.5576
3M,2Y,50,0.5369
3M,2Y,75,0.5321
3M,2Y,100,0.5359
3M,2Y,150,0.5541
3M,2Y,200,0.5749
3Y,2Y,-200,NA
3Y,2Y,-150,2.7138
3Y,2Y,-100,0.9112
3Y,2Y,-75,0.7689
3Y,2Y,-50,0.6741
3Y,2Y,-25,0.6049
3Y,2Y,0,0.5523
3Y,2Y,25,0.5108
3Y,2Y,50,0.4777
3Y,2Y,75,0.4511
3Y,2Y,100,0.4296
3Y,2Y,150,0.3985
3Y,2Y,200,0.3788
4Y,2Y,-200,NA
4Y,2Y,-150,1.2480
4Y,2Y,-100,0.7712
4Y,2Y,-75,0.6728
4Y,2Y,-50,0.6018
4Y,2Y,-25,0.5475
4Y,2Y,0,0.5047
4Y,2Y,25,0.4703
4Y,2Y,50,0.4421
4Y,2Y,75,0.4190
4Y,2Y,100,0.4001
4Y,2Y,150,0.3718
4Y,2Y,200,0.3531
5Y,2Y,-200,NA
5Y,2Y,-150,0.9631
5Y,2Y,-100,0.6754
5Y,2Y,-75,0.6003
5Y,2Y,-50,0.5433
5Y,2Y,-25,0.4983
5Y,2Y,0,0.4620
5Y,2Y,25,0.4323
5Y,2Y,50,0.4078
5Y,2Y,75,0.3875
5Y,2Y,100,0.3706
5Y,2Y,150,0.3453
5Y,2Y,200,0.3285
6M,2Y,-200,NA
6M,2Y,-150,NA
6M,2Y,-100,2.1063
6M,2Y,-75,1.0959
6M,2Y,-50,0.8281
6M,2Y,-25,0.6862
6M,2Y,-20,0.6655
6M,2Y,-15,0.6469
6M,2Y,-10,0.6297
6M,2Y,-5,0.6143
6M,2Y,0,0.6005
6M,2Y,5,0.5880
6M,2Y,10,0.5766
6M,2Y,15,0.5662
6M,2Y,20,0.5570
6M,2Y,25,0.5487
6M,2Y,50,0.5188
6M,2Y,75,0.5028
6M,2Y,100,0.4955
6M,2Y,150,0.4943
6M,2Y,200,0.5012
6Y,2Y,-200,NA
6Y,2Y,-150,0.8025
6Y,2Y,-100,0.5993
6Y,2Y,-75,0.5398
6Y,2Y,-50,0.4930
6Y,2Y,-25,0.4554
6Y,2Y,0,0.4246
6Y,2Y,25,0.3990
6Y,2Y,50,0.3778
6Y,2Y,75,0.3600
6Y,2Y,100,0.3453
6Y,2Y,150,0.3229
6Y,2Y,200,0.3080
7Y,2Y,-200,1.3475
7Y,2Y,-150,0.7196
7Y,2Y,-100,0.5537
7Y,2Y,-75,0.5021
7Y,2Y,-50,0.4609
7Y,2Y,-25,0.4274
7Y,2Y,0,0.3996
7Y,2Y,25,0.3767
7Y,2Y,50,0.3574
7Y,2Y,75,0.3412
7Y,2Y,100,0.3277
7Y,2Y,150,0.3074
7Y,2Y,200,0.2938
8Y,2Y,-200,1.0788
8Y,2Y,-150,0.6571
8Y,2Y,-100,0.5144
8Y,2Y,-75,0.4684
8Y,2Y,-50,0.4313
8Y,2Y,-25,0.4008
8Y,2Y,0,0.3756
8Y,2Y,25,0.3545
8Y,2Y,50,0.3369
8Y,2Y,75,0.3220
8Y,2Y,100,0.3097
8Y,2Y,150,0.2912
8Y,2Y,200,0.2791
9Y,2Y,-200,0.9438
9Y,2Y,-150,0.6123
9Y,2Y,-100,0.4852
9Y,2Y,-75,0.4433
9Y,2Y,-50,0.4092
9Y,2Y,-25,0.3810
9Y,2Y,0,0.3576
9Y,2Y,25,0.3378
9Y,2Y,50,0.3215
9Y,2Y,75,0.3077
9Y,2Y,100,0.2962
9Y,2Y,150,0.2791
9Y,2Y,200,0.2680
10Y,30Y,-200,0.6565
10Y,30Y,-150,0.4572
10Y,30Y,-100,0.3638
10Y,30Y,-75,0.3312
10Y,30Y,-50,0.3044
10Y,30Y,-25,0.2822
10Y,30Y,0,0.2637
10Y,30Y,25,0.2488
10Y,30Y,50,0.2367
10Y,30Y,75,0.2274
10Y,30Y,100,0.2202
10Y,30Y,150,0.2112
10Y,30Y,200,0.2072
1M,30Y,-200,1.4241
1M,30Y,-150,0.8312
1M,30Y,-100,0.5566
1M,30Y,-75,0.4622
1M,30Y,-50,0.3866
1M,30Y,-25,0.3294
1M,30Y,-20,0.3201
1M,30Y,-15,0.3117
1M,30Y,-10,0.3039
1M,30Y,-5,0.2971
1M,30Y,0,0.2912
1M,30Y,5,0.2862
1M,30Y,10,0.2822
1M,30Y,15,0.2791
1M,30Y,20,0.2769
1M,30Y,25,0.2755
1M,30Y,50,0.2793
1M,30Y,75,0.2954
1M,30Y,100,0.3169
1M,30Y,150,0.3586
1M,30Y,200,0.3965
1Y,30Y,-200,0.9574
1Y,30Y,-150,0.6327
1Y,30Y,-100,0.4865
1Y,30Y,-75,0.4363
1Y,30Y,-50,0.3957
1Y,30Y,-25,0.3628
1Y,30Y,0,0.3362
1Y,30Y,25,0.3154
1Y,30Y,50,0.2998
1Y,30Y,75,0.2886
1Y,30Y,100,0.2812
1Y,30Y,150,0.2744
1Y,30Y,200,0.2740
2Y,30Y,-200,0.8640
2Y,30Y,-150,0.5894
2Y,30Y,-100,0.4602
2Y,30Y,-75,0.4161
2Y,30Y,-50,0.3803
2Y,30Y,-25,0.3509
2Y,30Y,0,0.3268
2Y,30Y,25,0.3073
2Y,30Y,50,0.2917
2Y,30Y,75,0.2797
2Y,30Y,100,0.2708
2Y,30Y,150,0.2600
2Y,30Y,200,0.2556
3M,30Y,-200,1.2563
3M,30Y,-150,0.7574
3M,30Y,-100,0.5436
3M,30Y,-75,0.4699
3M,30Y,-50,0.4106
3M,30Y,-25,0.3642
3M,30Y,-20,0.3565
3M,30Y,-15,0.3493
3M,30Y,-10,0.3428
3M,30Y,-5,0.3367
3M,30Y,0,0.3313
3M,30Y,5,0.3264
3M,30Y,10,0.3221
3M,30Y,15,0.3183
3M,30Y,20,0.3152
3M,30Y,25,0.3125
3M,30Y,50,0.3061
3M,30Y,75,0.3083
3M,30Y,100,0.3157
3M,30Y,150,0.3366
3M,30Y,200,0.3588
3Y,30Y,-200,0.7977
3Y,30Y,-150,0.5577
3Y,30Y,-100,0.4407
3Y,30Y,-75,0.4001
3Y,30Y,-50,0.3669
3Y,30Y,-25,0.3396
3Y,30Y,0,0.3171
3Y,30Y,25,0.2986
3Y,30Y,50,0.2838
3Y,30Y,75,0.2721
3Y,30Y,100,0.2632
3Y,30Y,150,0.2518
3Y,30Y,200,0.2464
4Y,30Y,-200,0.7491
4Y,30Y,-150,0.5299
4Y,30Y,-100,0.4224
4Y,30Y,-75,0.3843
4Y,30Y,-50,0.3529
4Y,30Y,-25,0.3270
4Y,30Y,0,0.3056
4Y,30Y,25,0.2880
4Y,30Y,50,0.2738
4Y,30Y,75,0.2626
4Y,30Y,100,0.2539
4Y,30Y,150,0.2427
4Y,30Y,200,0.2373
5Y,30Y,-200,0.7236
5Y,30Y,-150,0.5137
5Y,30Y,-100,0.4104
5Y,30Y,-75,0.3738
5Y,30Y,-50,0.3433
5Y,30Y,-25,0.3183
5Y,30Y,0,0.2975
5Y,30Y,25,0.2804
5Y,30Y,50,0.2666
5Y,30Y,75,0.2557
5Y,30Y,100,0.2472
5Y,30Y,150,0.2363
5Y,30Y,200,0.2310
6M,30Y,-200,1.0927
6M,30Y,-150,0.6891
6M,30Y,-100,0.5150
6M,30Y,-75,0.4551
6M,30Y,-50,0.4071
6M,30Y,-25,0.3689
6M,30Y,0,0.3400
6M,30Y,25,0.3198
6M,30Y,50,0.3074
6M,30Y,75,0.3013
6M,30Y,100,0.2998
6M,30Y,150,0.3041
6M,30Y,200,0.3127
6Y,30Y,-200,0.7012
6Y,30Y,-150,0.4982
6Y,30Y,-100,0.3984
6Y,30Y,-75,0.3630
6Y,30Y,-50,0.3336
6Y,30Y,-25,0.3093
6Y,30Y,0,0.2892
6Y,30Y,25,0.2727
6Y,30Y,50,0.2594
6Y,30Y,75,0.2489
6Y,30Y,100,0.2408
6Y,30Y,150,0.2304
6Y,30Y,200,0.2255
7Y,30Y,-200,0.6871
7Y,30Y,-150,0.4873
7Y,30Y,-100,0.3895
7Y,30Y,-75,0.3550
7Y,30Y,-50,0.3262
7Y,30Y,-25,0.3026
7Y,30Y,0,0.2829
7Y,30Y,25,0.2668
7Y,30Y,50,0.2539
7Y,30Y,75,0.2436
7Y,30Y,100,0.2358
7Y,30Y,150,0.2259
7Y,30Y,200,0.2212
8Y,30Y,-200,0.6784
8Y,30Y,-150,0.4782
8Y,30Y,-100,0.3815
8Y,30Y,-75,0.3475
8Y,30Y,-50,0.3192
8Y,30Y,-25,0.2959
8Y,30Y,0,0.2766
8Y,30Y,25,0.2609
8Y,30Y,50,0.2483
8Y,30Y,75,0.2383
8Y,30Y,100,0.2309
8Y,30Y,150,0.2215
8Y,30Y,200,0.2173
9Y,30Y,-200,0.6655
9Y,30Y,-150,0.4669
9Y,30Y,-100,0.3721
9Y,30Y,-75,0.3389
9Y,30Y,-50,0.3114
9Y,30Y,-25,0.2886
9Y,30Y,0,0.2699
9Y,30Y,25,0.2546
9Y,30Y,50,0.2423
9Y,30Y,75,0.2327
9Y,30Y,100,0.2254
9Y,30Y,150,0.2162
9Y,30Y,200,0.2122
10Y,5Y,-200,0.7596
10Y,5Y,-150,0.5355
10Y,5Y,-100,0.4327
10Y,5Y,-75,0.3971
10Y,5Y,-50,0.3679
10Y,5Y,-25,0.3436
10Y,5Y,0,0.3233
10Y,5Y,25,0.3063
10Y,5Y,50,0.2922
10Y,5Y,75,0.2805
10Y,5Y,100,0.2709
10Y,5Y,150,0.2571
10Y,5Y,200,0.2486
1M,5Y,-200,NA
1M,5Y,-150,NA
1M,5Y,-100,1.3245
1M,5Y,-75,0.9421
1M,5Y,-50,0.7337
1M,5Y,-25,0.6056
1M,5Y,-20,0.5869
1M,5Y,-15,0.5700
1M,5Y,-10,0.5553
1M,5Y,-5,0.5424
1M,5Y,0,0.5316
1M,5Y,5,0.5224
1M,5Y,10,0.5150
1M,5Y,15,0.5091
1M,5Y,20,0.5045
1M,5Y,25,0.5012
1M,5Y,50,0.4992
1M,5Y,75,0.5131
1M,5Y,100,0.5334
1M,5Y,150,0.5737
1M,5Y,200,0.6072
1Y,5Y,-200,NA
1Y,5Y,-150,NA
1Y,5Y,-100,0.9357
1Y,5Y,-75,0.7732
1Y,5Y,-50,0.6694
1Y,5Y,-25,0.5964
1Y,5Y,0,0.5424
1Y,5Y,25,0.5017
1Y,5Y,50,0.4712
1Y,5Y,75,0.4486
1Y,5Y,100,0.4320
1Y,5Y,150,0.4113
1Y,5Y,200,0.4015
2Y,5Y,-200,NA
2Y,5Y,-150,1.3330
2Y,5Y,-100,0.7802
2Y,5Y,-75,0.6723
2Y,5Y,-50,0.5960
2Y,5Y,-25,0.5389
2Y,5Y,0,0.4946
2Y,5Y,25,0.4598
2Y,5Y,50,0.4320
2Y,5Y,75,0.4102
2Y,5Y,100,0.3929
2Y,5Y,150,0.3693
2Y,5Y,200,0.3554
3M,5Y,-200,NA
3M,5Y,-150,NA
3M,5Y,-100,1.2131
3M,5Y,-75,0.9225
3M,5Y,-50,0.7535
3M,5Y,-25,0.6440
3M,5Y,-20,0.6272
3M,5Y,-15,0.6119
3M,5Y,-10,0.5980
3M,5Y,-5,0.5855
3M,5Y,0,0.5743
3M,5Y,5,0.5641
3M,5Y,10,0.5552
3M,5Y,15,0.5473
3M,5Y,20,0.5404
3M,5Y,25,0.5346
3M,5Y,50,0.5160
3M,5Y,75,0.5107
3M,5Y,100,0.5129
3M,5Y,150,0.5271
3M,5Y,200,0.5442
3Y,5Y,-200,NA
3Y,5Y,-150,0.9940
3Y,5Y,-100,0.6815
3Y,5Y,-75,0.6017
3Y,5Y,-50,0.5419
3Y,5Y,-25,0.4954
3Y,5Y,0,0.4583
3Y,5Y,25,0.4284
3Y,5Y,50,0.4041
3Y,5Y,75,0.3844
3Y,5Y,100,0.3686
3Y,5Y,150,0.3459
3Y,5Y,200,0.3320
4Y,5Y,-200,NA
4Y,5Y,-150,0.8346
4Y,5Y,-100,0.6137
4Y,5Y,-75,0.5501
4Y,5Y,-50,0.5004
4Y,5Y,-25,0.4609
4Y,5Y,0,0.4290
4Y,5Y,25,0.4028
4Y,5Y,50,0.3812
4Y,5Y,75,0.3635
4Y,5Y,100,0.3492
4Y,5Y,150,0.3281
4Y,5Y,200,0.3148
5Y,5Y,-200,1.4151
5Y,5Y,-150,0.7405
5Y,5Y,-100,0.5665
5Y,5Y,-75,0.5124
5Y,5Y,-50,0.4694
5Y,5Y,-25,0.4343
5Y,5Y,0,0.4057
5Y,5Y,25,0.3821
5Y,5Y,50,0.3625
5Y,5Y,75,0.3462
5Y,5Y,100,0.3328
5Y,5Y,150,0.3130
5Y,5Y,200,0.3003
6M,5Y,-200,NA
6M,5Y,-150,NA
6M,5Y,-100,1.0846
6M,5Y,-75,0.8579
6M,5Y,-50,0.7219
6M,5Y,-25,0.6307
6M,5Y,0,0.5678
6M,5Y,25,0.5252
6M,5Y,50,0.4975
6M,5Y,75,0.4807
6M,5Y,100,0.4712
6M,5Y,150,0.4649
6M,5Y,200,0.4671
6Y,5Y,-200,1.0999
6Y,5Y,-150,0.6737
6Y,5Y,-100,0.5272
6Y,5Y,-75,0.4797
6Y,5Y,-50,0.4413
6Y,5Y,-25,0.4099
6Y,5Y,0,0.3839
6Y,5Y,25,0.3624
6Y,5Y,50,0.3445
6Y,5Y,75,0.3297
6Y,5Y,100,0.3175
6Y,5Y,150,0.2995
6Y,5Y,200,0.2880
7Y,5Y,-200,0.9539
7Y,5Y,-150,0.6262
7Y,5Y,-100,0.4971
7Y,5Y,-75,0.4541
7Y,5Y,-50,0.4193
7Y,5Y,-25,0.3904
7Y,5Y,0,0.3665
7Y,5Y,25,0.3466
7Y,5Y,50,0.3300
7Y,5Y,75,0.3163
7Y,5Y,100,0.3050
7Y,5Y,150,0.2884
7Y,5Y,200,0.2778
8Y,5Y,-200,0.8663
8Y,5Y,-150,0.5891
8Y,5Y,-100,0.4716
8Y,5Y,-75,0.4316
8Y,5Y,-50,0.3992
8Y,5Y,-25,0.3721
8Y,5Y,0,0.3497
8Y,5Y,25,0.3311
8Y,5Y,50,0.3155
8Y,5Y,75,0.3025
8Y,5Y,100,0.2920
8Y,5Y,150,0.2764
8Y,5Y,200,0.2667
9Y,5Y,-200,0.8055
9Y,5Y,-150,0.5599
9Y,5Y,-100,0.4507
9Y,5Y,-75,0.4132
9Y,5Y,-50,0.3825
9Y,5Y,-25,0.3570
9Y,5Y,0,0.3358
9Y,5Y,25,0.3180
9Y,5Y,50,0.3032
9Y,5Y,75,0.2910
9Y,5Y,100,0.2810
9Y,5Y,150,0.2664
9Y,5Y,200,0.2573 RQuantLib/inst/shiny/SabrSwaption/volDF2CubeK.R 0000644 0001762 0000144 00000005013 12757140057 020776 0 ustar ligges users volDF2CubeK <- function(params, tbl, source = "CME") {
strikes <- levels(tbl$Spread)<-c(-200,-150,-100,-75,-50,-25,0,25,50,75,100,150,200)
matYears <- as.numeric(params$maturity-params$tradeDate)/365
expYears <- as.numeric(params$expiryDate-params$tradeDate)/365
expLvl <- c( "1M","3M","6M","1Y","2Y","3Y","4Y", "5Y", "6Y", "7Y", "8Y", "9Y","10Y")
tbl$Expiry <- factor(tbl$Expiry, levels <- expLvl)
expiries <- c(1/12,.25,.5,1,2,3,4,5,6,7,8,9,10)
tenorLvl <- c( "1Y", "2Y", "5Y", "10Y","15Y","20Y","30Y")
tbl$Tenor <- factor(tbl$Tenor, levels = tenorLvl)
tenors <- c(1,2,5,10,15,20,30)
tenorIDX <- max(findInterval(matYears-expYears,tenors),1)
tenorIDX <- min(tenorIDX,length(tenors)-3)
expiryIDX <- findInterval(expYears,expiries)
expiryIDX <- min(expiryIDX,length(expiries)-3)
strikeIDX <- 1
expire <- expLvl[expiryIDX]
tenor <- tenorLvl[tenorIDX]
for(strike in levels(tbl$Spread)){
if(!is.na(tbl[tbl$Expiry==expire & tbl$Spread==strike &tbl$Tenor==tenor,]$LogNormalVol))break;
strikeIDX <- strikeIDX+1
}
strikes <- strikes[strikeIDX:length(strikes)]
expLvl <- expLvl[expiryIDX:length(expLvl)]
expiries <- expiries[expiryIDX:length(expiries)]
tenorLvl <- tenorLvl[tenorIDX:length(tenorLvl)]
tenors <- tenors[tenorIDX:length(tenors)]
tbl <- tbl[tbl$Expiry%in%expLvl,]
tbl <- tbl[tbl$Tenor%in%tenorLvl,]
tbl <- tbl[tbl$Spread%in%strikes,]
tbl <- tbl[with(tbl,order(Expiry,Tenor,Spread)),]
tbl3 <- tbl[tbl$Spread==0,]
# atm vol matrix
atmMat=acast(tbl3,Expiry~Tenor,value.var = "LogNormalVol")
#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))
tmp3=acast(tbl,Expiry~Tenor~Spread,value.var="LogNormalVol")
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,]=tmp3[i,j,]-tmp3[i,j,"0"]
#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")
tmp <- list(atmVol=atmMat,tenors=tenors,expiries=expiries,smirk=smirk,strikes=strikes/10000)
class(tmp) <- "volcube"
return(tmp)
} RQuantLib/inst/QuantLib_LICENSE.TXT 0000644 0001762 0000144 00000013736 12303640333 016361 0 ustar ligges users QuantLib is
Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
Copyright (C) 2001, 2002, 2003 Nicolas Di Césaré
Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
Copyright (C) 2002, 2003, 2004 Decillion Pty(Ltd)
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Ferdinando Ametrano
Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 StatPro Italia srl
Copyright (C) 2003, 2004, 2007 Neil Firth
Copyright (C) 2003, 2004 Roman Gitlin
Copyright (C) 2003, 2005, 2013 Gary Kennedy
Copyright (C) 2003 Niels Elken Sønderby
Copyright (C) 2003 Kawanishi Tomoya
Copyright (C) 2004 FIMAT Group
Copyright (C) 2004 M-Dimension Consulting Inc.
Copyright (C) 2004 Mike Parker
Copyright (C) 2004 Walter Penschke
Copyright (C) 2004 Gianni Piolanti
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Klaus Spanderen
Copyright (C) 2004 Jeff Yu
Copyright (C) 2005, 2006, 2008 Toyin Akin
Copyright (C) 2005 Sercan Atalik
Copyright (C) 2005, 2006 Theo Boafo
Copyright (C) 2005, 2006, 2007, 2009 Piter Dias
Copyright (C) 2005, 2006, 2007 Joseph Wang
Copyright (C) 2005 Charles Whitmore
Copyright (C) 2006, 2007 Banca Profilo S.p.A.
Copyright (C) 2006, 2007 Marco Bianchetti
Copyright (C) 2006 Yiping Chen
Copyright (C) 2006 Warren Chou
Copyright (C) 2006, 2007 Cristina Duminuco
Copyright (C) 2006, 2007 Giorgio Facchinetti
Copyright (C) 2006, 2007 Chiara Fornarola
Copyright (C) 2006 Silvia Frasson
Copyright (C) 2006 Richard Gould
Copyright (C) 2006, 2007, 2008, 2009, 2010 Mark Joshi
Copyright (C) 2006, 2007, 2008 Allen Kuo
Copyright (C) 2006, 2007, 2008, 2009, 2012 Roland Lichters
Copyright (C) 2006, 2007 Katiuscia Manzoni
Copyright (C) 2006, 2007 Mario Pucci
Copyright (C) 2006, 2007 François du Vignaud
Copyright (C) 2007 Affine Group Limited
Copyright (C) 2007 Richard Gomes
Copyright (C) 2007, 2008 Laurent Hoffmann
Copyright (C) 2007, 2008, 2009, 2010, 2011 Chris Kenyon
Copyright (C) 2007 Gang Liang
Copyright (C) 2008, 2009 Jose Aparicio
Copyright (C) 2008 Yee Man Chan
Copyright (C) 2008, 2011 Charles Chongseok Hyun
Copyright (C) 2008 Piero Del Boca
Copyright (C) 2008 Paul Farrington
Copyright (C) 2008 Lorella Fatone
Copyright (C) 2008, 2009 Andreas Gaida
Copyright (C) 2008 Marek Glowacki
Copyright (C) 2008 Florent Grenier
Copyright (C) 2008 Frank Hövermann
Copyright (C) 2008 Simon Ibbotson
Copyright (C) 2008 John Maiden
Copyright (C) 2008 Francesca Mariani
Copyright (C) 2008, 2009, 2010, 2011, 2012 Master IMAFA - Polytech'Nice Sophia - Université de Nice Sophia Antipolis
Copyright (C) 2008, 2009 Andrea Odetti
Copyright (C) 2008 J. Erik Radmall
Copyright (C) 2008 Maria Cristina Recchioni
Copyright (C) 2008, 2009, 2012 Ralph Schreyer
Copyright (C) 2008 Roland Stamm
Copyright (C) 2008 Francesco Zirilli
Copyright (C) 2009 Nathan Abbott
Copyright (C) 2009 Sylvain Bertrand
Copyright (C) 2009 Frédéric Degraeve
Copyright (C) 2009 Dirk Eddelbuettel
Copyright (C) 2009 Bernd Engelmann
Copyright (C) 2009, 2010, 2012 Liquidnet Holdings, Inc.
Copyright (C) 2009 Bojan Nikolic
Copyright (C) 2009, 2010 Dimitri Reiswich
Copyright (C) 2009 Sun Xiuxin
Copyright (C) 2010 Kakhkhor Abdijalilov
Copyright (C) 2010 Hachemi Benyahia
Copyright (C) 2010 Manas Bhatt
Copyright (C) 2010 DeriveXperts SAS
Copyright (C) 2010, 2014 Cavit Hafizoglu
Copyright (C) 2010 Michael Heckl
Copyright (C) 2010 Slava Mazur
Copyright (C) 2010, 2011, 2012, 2013 Andre Miemiec
Copyright (C) 2010 Adrian O' Neill
Copyright (C) 2010 Robert Philipp
Copyright (C) 2010 Alessandro Roveda
Copyright (C) 2010 SunTrust Bank
Copyright (C) 2011, 2013 Fabien Le Floc'h
Copyright (C) 2012, 2013 Grzegorz Andruszkiewicz
Copyright (C) 2012, 2013, 2014 Peter Caspers
Copyright (C) 2012 Mateusz Kapturski
Copyright (C) 2012 Simon Shakeshaft
Copyright (C) 2012 Édouard Tallent
Copyright (C) 2012 Samuel Tebege
Copyright (C) 2013 BGC Partners L.P.
Copyright (C) 2013 Cheng Li
Copyright (C) 2013 Yue Tian
QuantLib includes code taken from Peter Jäckel's book "Monte Carlo
Methods in Finance".
QuantLib includes software developed by the University of Chicago,
as Operator of Argonne National Laboratory.
QuantLib includes a set of numbers provided by Stephen Joe and Frances
Kuo under a BSD-style license.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the names of the copyright holders nor the names of the QuantLib
Group and its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
RQuantLib/inst/unitTests/ 0000755 0001762 0000144 00000000000 13004144174 015070 5 ustar ligges users RQuantLib/inst/unitTests/runit.businessdayconvention.R 0000644 0001762 0000144 00000003056 12722576357 023035 0 ustar ligges users test.Nearest <- function(){
checkEquals(advance("SouthAfrica", as.Date("2015-02-03"), 1, 2, bdc=6),
as.Date("2015-03-03"))
checkEquals(advance("SouthAfrica", as.Date("2015-02-03"), 4, 0, bdc=6),
as.Date("2015-02-09"))
checkEquals(advance("SouthAfrica", as.Date("2015-04-16"), 1, 2, bdc=6),
as.Date("2015-05-15"))
checkEquals(advance("SouthAfrica", as.Date("2015-04-17"), 1, 2, bdc=6),
as.Date("2015-05-18"))
checkEquals(advance("SouthAfrica", as.Date("2015-03-04"), 1, 2, bdc=6),
as.Date("2015-04-02"))
checkEquals(advance("SouthAfrica", as.Date("2015-04-02"), 1, 2, bdc=6),
as.Date("2015-05-04"))
}
test.HalfMonthModifiedFollowing <- function() {
checkEquals(advance("SouthAfrica", as.Date("2015-02-03"), 1, 2, bdc=5),
as.Date("2015-03-03"))
checkEquals(advance("SouthAfrica", as.Date("2015-02-03"), 4, 0, bdc=5),
as.Date("2015-02-09"))
checkEquals(advance("SouthAfrica", as.Date("2015-01-31"), 1, 2, emr=1, bdc=5),
as.Date("2015-02-27"))
checkEquals(advance("SouthAfrica", as.Date("2015-01-31"), 1, 2, bdc=5),
as.Date("2015-02-27"))
checkEquals(advance("SouthAfrica", as.Date("2015-01-3"), 1, 1, bdc=5),
as.Date("2015-01-12"))
checkEquals(advance("SouthAfrica", as.Date("2015-03-21"), 1, 1, bdc=5),
as.Date("2015-03-30"))
checkEquals(advance("SouthAfrica", as.Date("2015-02-07"), 1, 2, bdc=5),
as.Date("2015-03-09"))
}
RQuantLib/inst/unitTests/runit.options.R 0000644 0001762 0000144 00000077072 13004144174 020063 0 ustar ligges users
## AsianOption() currently has issue of Windows
.onWindows <- .Platform$OS.type == "windows"
## American option tests based on Haug's book
test.american.Haug <- function() {
## see QuantLib's test-suite/americanoption.cpp
#/* The data below are from
# "Option pricing formulas", E.G. Haug, McGraw-Hill 1998
# pag 24
#
# The following values were replicated only up to the second digit
# by the VB code provided by Haug, which was used as base for the
# C++ implementation
#
#*/
AO <- AmericanOption # shorthand
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF=0.10, mat=0.10, vol= 0.15)$value, 0.0206, tol=1.0e-2)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.15)$value, 1.8771, tol=1.0e-4)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.15)$value, 10.0089, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 0.3159, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 3.1280, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 10.3919, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 0.9495, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 4.3777, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 11.1679, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 0.8208, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 4.0842, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 10.8087, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 2.7437, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 6.8015, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 13.0170, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 5.0063, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 9.5106, tol=1.0e-3)
checkEquals(AO(type="call", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 15.5689, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.15)$value, 10.0000, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.15)$value, 1.8770, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.15)$value, 0.0410, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 10.2533, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 3.1277, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.25)$value, 0.4562, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 10.8787, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 4.3777, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.10, vol= 0.35)$value, 1.2402, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 10.5595, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 4.0842, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.15)$value, 1.0822, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 12.4419, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 6.8014, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.25)$value, 3.3226, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 90.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 14.6945, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 100.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 9.5104, tol=1.0e-3)
checkEquals(AO(type="put", strike= 100.00, underl= 110.00, div= 0.10, riskF= 0.10, mat= 0.50, vol= 0.35)$value, 5.8823, tol=1.0e-3)
}
## Asian option tests
test.asian <- function() {
## see QuantLib's test-suite/asianoptions.cpp
AO <- AsianOption # shorthand
checkEquals(AO(averageType="geometric", typ="put", strike=85, underl=80, div=-0.03, riskF=0.05, mat=0.25, vol=0.20)$value, 4.6922, tol=1.0e-4)
if (!.onWindows) {
## data from "Asian Option", Levy, 1997
## in "Exotic Options: The State of the Art",
## edited by Clewlow, Strickland
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=2, vol=0.13)$value, 1.3942835683, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=4, vol=0.13)$value, 1.5852442983, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=8, vol=0.13)$value, 1.66970673, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=12, vol=0.13)$value, 1.6980019214, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=26, vol=0.13)$value, 1.7255070456, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=52, vol=0.13)$value, 1.7401553533, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=100, vol=0.13)$value, 1.7478303712, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=250, vol=0.13)$value, 1.7490291943, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=500, vol=0.13)$value, 1.7515113291, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=0.0, length=11.0/12.0, fixings=1000, vol=0.13)$value, 1.7537344885, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=2, vol=0.13)$value, 1.8496053697, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=4, vol=0.13)$value, 2.0111495205, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=8, vol=0.13)$value, 2.0852138818, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=12, vol=0.13)$value, 2.1105094397, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=26, vol=0.13)$value, 2.1346526695, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=52, vol=0.13)$value, 2.147489651, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=100, vol=0.13)$value, 2.154728109, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=250, vol=0.13)$value, 2.1564276565, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=500, vol=0.13)$value, 2.1594238588, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=1.0/12.0, length=11.0/12.0, fixings=1000, vol=0.13)$value, 2.1595367326, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=2, vol=0.13)$value, 2.63315092584, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=4, vol=0.13)$value, 2.76723962361, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=8, vol=0.13)$value, 2.83124836881, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=12, vol=0.13)$value, 2.84290301412, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=26, vol=0.13)$value, 2.88179560417, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=52, vol=0.13)$value, 2.88447044543, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=100, vol=0.13)$value, 2.89985329603, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=250, vol=0.13)$value, 2.90047296063, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=500, vol=0.13)$value, 2.89813412160, tol=1.0e-2)
checkEquals(AO("arithmetic", "put", underl=90.0, strike=87.0, div=0.06, riskF=0.025, first=3.0/12.0, length=11.0/12.0, fixings=1000, vol=0.13)$value, 2.8970336243, tol=1.0e-2)
}
}
## Barrier Options
test.barrier <- function() {
checkEquals(BarrierOption(barrType="downin", type="call", underl=100, strike=100, div=0.02, riskF=0.03, mat=0.5, vol=0.4, barrier=90)$value, 3.738254414)
checkEquals(BarrierOption("downout", barrier=95, rebate=3, type="call", strike=90, underlying=100, div=0.04, riskF=0.08, mat=0.5, vol=0.25)$value, 9.024567695)
checkEquals(BarrierOption("downin", barrier=95, rebate=3, type="call", strike=90, underlying=100, div=0.04, riskF=0.08, mat=0.5, vol=0.25)$value, 7.76267021)
}
test.barrier.Haug <- function() {
## see QuantLib's test-suite/barrieroption.cpp
# /* The data below are from
# * "Option pricing formulas", E.G. Haug, McGraw-Hill 1998 pag. 72
# */
#
BO <- BarrierOption # shorthand
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 9.0246, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 6.7924, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 4.8759, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.6789, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.3580, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.3453, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 7.7627, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 4.0109, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.0576, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 13.8333, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 7.8494, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.9795, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 14.1112, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 8.4482, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 4.5910, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 8.8334, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 7.0285, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 5.4137, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.6341, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.4389, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.4315, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 9.0093, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 5.1370, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.8517, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 14.8816, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 9.2045, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 5.3043, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 15.2098, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 9.7278, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="call", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 5.8350, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.2798, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.2947, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.6252, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.7760, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 5.4932, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 7.5187, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.9586, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 6.5677, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 11.9752, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 2.2845, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 5.9085, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 11.6465, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 1.4653, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 3.3721, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.25)$value, 7.0846, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.4170, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.4258, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=95.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.6246, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="downout", barrier=100.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.0000, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 4.2293, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 5.8032, tol=1.0e-4)
checkEquals(BO(barrType="upout", barrier=105.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 7.5649, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.8769, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 7.7989, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=95.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 13.3078, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 3.3328, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 7.2636, tol=1.0e-4)
checkEquals(BO(barrType="downin", barrier=100.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 12.9713, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=90, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 2.0658, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=100, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 4.4226, tol=1.0e-4)
checkEquals(BO(barrType="upin", barrier=105.0, rebate=3.0, type="put", strike=110, underl=100.0, div=0.04, riskF=0.08, mat=0.50, vol=0.30)$value, 8.3686, tol=1.0e-4)
}
## Binary Options aka Digitals
test.binary <- function() {
## cash or nothing European
rc <- BinaryOption(binType="cash", type="put", excType="european", strike=80, underl=100, div=0.06, r=0.06, mat=0.75, vol=0.35, cash=10)
checkEquals(rc$value, 2.671045684)
checkEquals(rc[1:7],
list(value=2.671045, delta=-0.1060594, gamma=0.00310624, vega=8.153881, theta=-1.742309, rho=-9.9577, divRho=7.9544),
tolerance=1.0e-5)
}
## European option tests based on Haug's book
test.european.Haug <- function() {
## see QuantLib's test-suite/europeanoption.cpp
#/* The data below are from
# "Option pricing formulas", E.G. Haug, McGraw-Hill 1998
#*/
# // pag 2-8, pg 24, p 27
#
Lines <- "type strike spot q r t v value tol"
EO <- EuropeanOption # shorthand
checkEquals(EO(type="call", strike=65.00, underl=60.00, div= 0.00, riskF=0.08, mat=0.25, vol=0.30)$value, 2.1334, tol=1.0e-3)
checkEquals(EO(type="put", strike=95.00, underl=100.00, div= 0.05, riskF=0.10, mat=0.50, vol=0.20)$value, 2.4648, tol=1.0e-3)
checkEquals(EO(type="put", strike=19.00, underl=19.00, div= 0.10, riskF=0.10, mat=0.75, vol=0.28)$value, 1.7011, tol=1.0e-3)
checkEquals(EO(type="call", strike=19.00, underl=19.00, div= 0.10, riskF=0.10, mat=0.75, vol=0.28)$value, 1.7011, tol=1.0e-3)
checkEquals(EO(type="call", strike=1.60, underl=1.56, div= 0.08, riskF=0.06, mat=0.50, vol=0.12)$value, 0.0291, tol=1.0e-3)
checkEquals(EO(type="put", strike=70.00, underl=75.00, div= 0.05, riskF=0.10, mat=0.50, vol=0.35)$value, 4.0870, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 0.0205, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 1.8734, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 9.9413, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 0.3150, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 3.1217, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 10.3556, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 0.9474, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 4.3693, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 11.1381, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 0.8069, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 4.0232, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 10.5769, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 2.7026, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 6.6997, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 12.7857, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 4.9329, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 9.3679, tol=1.0e-3)
checkEquals(EO(type="call", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 15.3086, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 9.9210, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 1.8734, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.15)$value, 0.0408, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 10.2155, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 3.1217, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.25)$value, 0.4551, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 10.8479, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 4.3693, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.10, vol=0.35)$value, 1.2376, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 10.3192, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 4.0232, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.15)$value, 1.0646, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 12.2149, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 6.6997, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.25)$value, 3.2734, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=90.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 14.4452, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=100.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 9.3679, tol=1.0e-3)
checkEquals(EO(type="put", strike=100.00, underl=110.00, div= 0.10, riskF=0.10, mat=0.50, vol=0.35)$value, 5.7963, tol=1.0e-3)
checkEquals(EO(type="call", strike=40.00, underl=42.00, div= 0.08, riskF=0.04, mat=0.75, vol=0.35)$value, 5.0975, tol=1.0e-3)
}
## European and American option tests with discrete dividends based on Hull's book
test.discreteDividend.Hull <- function() {
AO <- AmericanOption # shorthand
EO <- EuropeanOption # shorthand
## Reference p. 253 - Hull 5th ed. Exercise 12.8 - From QuantLib tests
checkEquals(EO(type="call", underlying=40, strike=40, div=0, riskFree=0.09, maturity=0.5, vol=0.3,
discreteDividends = c(0.5, 0.5), discreteDividendsTimeUntil = c(2/12, 5/12))$value, 3.67, tol=1.0e-2)
## Reference p. 256 - Hull 5th ed. Exercise 12.9 using (flawed) Roll, Geske and Whaley formula
checkEquals(AO(type="call", underlying=40, strike=40, div=0, riskFree=0.09, maturity=0.5, vol=0.3, engine = "CrankNicolson",
discreteDividends = c(0.5, 0.5), discreteDividendsTimeUntil = c(2/12, 5/12))$value, 3.72, tol=1.0e-1)
} RQuantLib/inst/unitTests/runit.calendar.R 0000644 0001762 0000144 00000000537 12420470564 020137 0 ustar ligges users
## test for calendaring functions
##
## cf test-suite/calendars.cpp in the QL sources
test.isHoliday <- function() {
checkEquals(isHoliday("UnitedStates", as.Date("2004-05-01")), TRUE, msg="isHoliday.US")
}
test.isBusinessDay <- function() {
checkEquals(isBusinessDay("UnitedStates", as.Date("2004-04-26")), TRUE, msg="isBusinessDay.US")
}
RQuantLib/inst/unitTests/runTests.R 0000644 0001762 0000144 00000002624 12271333436 017054 0 ustar ligges users ## borrowed from Rmetrics' unit testing framework
## removed test for interactive()
##
## Dirk Eddelbuettel, 29 Dec 2007
pkg <- "RQuantLib"
if (require("RUnit", quietly = TRUE)) {
library(package=pkg, character.only = TRUE)
if(!(exists("path") && file.exists(path)))
path <- system.file("unitTests", package = pkg)
## Define tests
testSuite <- defineTestSuite(name = paste(pkg, "unit testing"), dirs = path)
## Run tests
tests <- runTestSuite(testSuite)
if(file.access(path, 02) != 0) {
## cannot write to path -> use writable one
tdir <- tempfile(paste(pkg, "unitTests", sep="_"))
dir.create(tdir)
pathReport <- file.path(tdir, "report")
cat("RUnit reports are written into ", tdir, "/report.(txt|html)", sep = "")
} else {
pathReport <- file.path(path, "report")
}
## Print Results:
printTextProtocol(tests)
printTextProtocol(tests, fileName = paste(pathReport, ".txt", sep = ""))
## Print HTML Version to a File:
printHTMLProtocol(tests, fileName = paste(pathReport, ".html", sep = ""))
## stop() if there are any failures i.e. FALSE to unit test.
## This will cause R CMD check to return error and stop
if(getErrors(tests)$nFail > 0) {
stop("one of the unit tests failed")
}
} else {
cat("R package 'RUnit' cannot be loaded -- no unit tests run\n", "for package", pkg,"\n")
}
RQuantLib/inst/unitTests/cpp/ 0000755 0001762 0000144 00000000000 12422734444 015662 5 ustar ligges users RQuantLib/inst/unitTests/cpp/dates.cpp 0000644 0001762 0000144 00000003343 13015655624 017472 0 ustar ligges users // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
//
// dates.cpp: RQuantLib date conversion tests
//
// Copyright (C) 2014 - 2016 Dirk Eddelbuettel
//
// This file is part of RQuantLib.
//
// RQuantLib is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// RQuantLib is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with RQuantLib. If not, see .
// [[Rcpp::depends(RQuantLib)]]
#include
// [[Rcpp::export]]
Rcpp::Date advanceDateRR(Rcpp::Date d, int n) {
return d + n;
}
// [[Rcpp::export]]
Rcpp::Date advanceDateQR(QuantLib::Date d, int n) {
return Rcpp::wrap(d + n);
}
// [[Rcpp::export]]
QuantLib::Date advanceDateQQ(QuantLib::Date d, int n) {
return d + n;
}
// [[Rcpp::export]]
Rcpp::DateVector advanceDatesRR(Rcpp::DateVector d, int n) {
Rcpp::DateVector nd(d.size());
for (int i=0; i d, int n) {
for (unsigned int i=0; i advanceDatesQQ(std::vector d, int n) {
for (unsigned int i=0; i