RQuantLib/ 0000755 0001762 0000144 00000000000 15211275715 012121 5 ustar ligges users RQuantLib/tests/ 0000755 0001762 0000144 00000000000 15211270414 013252 5 ustar ligges users RQuantLib/tests/RQuantlib.R 0000644 0001762 0000144 00000020145 13403306333 015301 0 ustar ligges users
stopifnot(require(RQuantLib))
## values from Quantlib's test-suite
## Reference: Haug, Option Pricing Formulas, McGraw-Hill, 1998
##
## and generally sourced from the code in the test-suite/
## directory of the QuantLib distribution
## europeanoption.cpp: call value == 2.1334
print(EuropeanOption("call", underlying=60, strike=65, div=0, riskFree=0.08,
maturity=0.25, vol=0.3), digits=5)
## europeanoption.cpp: put value == 2.4648
print(EuropeanOption("put", underlying=100, strike=95, div=0.05, riskFree=0.1,
maturity=0.5, vol=0.2), digits=5)
## europeanoption.cpp: call delta == 0.5946
print(EuropeanOption("call", underlying=105, strike=100,div=0.1,riskFree=0.1,
maturity=0.5, vol=0.36), digits=4)
## europeanoption.cpp: put delta == -0.3566
print(EuropeanOption("put", underlying=105, strike=100,div=0.1,riskFree=0.1,
maturity=0.5, vol=0.36), digits=4)
## europeanoption.cpp: call gamma == 0.0278
print(EuropeanOption("call", underlying=55, strike=60,div=0.0,riskFree=0.1,
maturity=0.75, vol=0.30), digits=4)
## europeanoption.cpp: put gamma == 0.0278
print(EuropeanOption("put", underlying=55, strike=60,div=0.0,riskFree=0.1,
maturity=0.75, vol=0.30), digits=4)
## europeanoption.cpp: call vega == 18.9358
print(EuropeanOption("call", underlying=55, strike=60,div=0.0,riskFree=0.1,
maturity=0.75, vol=0.30), digits=4)
## europeanoption.cpp: put vega == 18.9358
print(EuropeanOption("put", underlying=55, strike=60,div=0.0,riskFree=0.1,
maturity=0.75, vol=0.30), digits=4)
## americanoption.cpp: call value == 10.0089 -- we show 10.00606
print(AmericanOption("call", underlying=110, strike=100, div=0.1, riskFree=0.1,
maturity=0.1, vol=0.15), digits=5)
## americanoption.cpp: put value == 0.3159
print(AmericanOption("call", underlying=90, strike=100, div=0.1, riskFree=0.1,
maturity=0.1, vol=0.25), digits=5)
# Discrete dividend
## europeanoption.cpp: call value == 3.67
## Reference pg. 253 - Hull 5th ed Exercise 12.8 - From QuantLib tests
print(EuropeanOption("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)), digits=5)
## americanoption.cpp: call value == 3.72 (Hull) -- we show 3.75
## Reference p. 256 - Hull 5th ed. Exercise 12.9 using (flawed) Roll, Geske, Whaley formula
print(AmericanOption("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)), digits=5)
## barrier: down and out call == 9.0246
print(BarrierOption("downout", barrier=95, rebate=3, type="call",
strike=90, underlying=100, div=0.04, riskF=0.08,
mat=0.5, vol=0.25), digits=4)
## barrier: down and in call == 7.7627
print(BarrierOption("downin", barrier=95, rebate=3, type="call",
strike=90, underlying=100, div=0.04, riskF=0.08,
mat=0.5, vol=0.25), digits=4)
## binary aka digital: put == 2.6710
print(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), digits=4)
## asianoption.cpp: put == 4.6922 (from testAnalyticContinuousGeometricAveragePrice())
print( AsianOption("geometric", "put", underlying=80, strike=85, div=-0.03, riskFree=0.05, maturity=0.25, vol=0.2))
#.onWindows <- .Platform$OS.type == "windows"
## simple call with unnamed parameters
bond <- list(faceAmount=100,issueDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"), redemption=100 )
dateparams <-list(settlementDays=1, calendar="UnitedStates/GovernmentBond", businessDayConvention='Unadjusted')
discountCurve.param <- list(tradeDate=as.Date('2002-2-15'),
settleDate=as.Date('2002-2-15'),
dt=0.25,
interpWhat='discount', interpHow='loglinear')
discountCurve <- DiscountCurve(discountCurve.param, list(flat=0.05))
ZeroCouponBond(bond, discountCurve, dateparams)
## bond.cpp: examples from Fixed Income page of Matlab
ZeroYield(95, 100, as.Date("1993-6-24"), as.Date("1993-11-1"))
## bond.cpp: test theoretical price of bond by its yield
ZeroPriceByYield(0.1478, 100, as.Date("1993-6-24"), as.Date("1993-11-1"))
## bond.cpp: test theoretical yield of a fixed rate bond, = 0.0307
FixedRateBondYield(,99.282, 100000, as.Date("2004-11-30"), as.Date("2008-11-30"), 3, , c(0.02875), , , , ,as.Date("2004-11-30"))
## bond.cpp: test theoretical price of a fixed rate bond = 99.2708
FixedRateBondPriceByYield(,0.0307, 100000, as.Date("2004-11-30"), as.Date("2008-11-30"), 3, , c(0.02875), , , , ,as.Date("2004-11-30"))
## bond.cpp
## Simple call with a flat curve
bond <- list(settlementDays=1,
issueDate=as.Date("2004-11-30"),
faceAmount=100,
dayCounter='Thirty360',
paymentConvention='Unadjusted')
schedule <- list(effectiveDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"),
period='Semiannual',
calendar='UnitedStates/GovernmentBond',
businessDayConvention='Unadjusted',
terminationDateConvention='Unadjusted',
dateGeneration='Forward',
endOfMonth=1)
calc=list(dayCounter='Actual360',
compounding='Compounded',
freq='Annual',
durationType='Modified')
coupon.rate <- c(0.02875)
params <- list(tradeDate=as.Date('2002-2-15'),
settleDate=as.Date('2002-2-19'),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
discountCurve.flat <- DiscountCurve(params, list(flat=0.05))
FixedRateBond(bond,
coupon.rate,
schedule,
calc,
discountCurve=discountCurve.flat)
## Same bond calculated from yield rather than from the discount curve
yield <- 0.02
FixedRateBond(bond,
coupon.rate,
schedule,
calc,
yield=yield)
#same example with clean price
price <- 103.31
FixedRateBond(bond,
coupon.rate,
schedule,
calc,
price = price)
## bond.cpp FloatingRateBond, following test-suite/bonds.cpp
bond <- list(faceAmount=100, issueDate=as.Date("2004-11-30"),
maturityDate=as.Date("2008-11-30"), redemption=100,
effectiveDate=as.Date("2004-11-30"))
dateparams <- list(settlementDays=1, calendar="UnitedStates/GovernmentBond",
dayCounter = 'ActualActual', period=2,
businessDayConvention = 1, terminationDateConvention=1,
dateGeneration=0, endOfMonth=0, fixingDays = 1)
gearings <- spreads <- caps <- floors <- vector()
params <- list(tradeDate=as.Date('2002-2-15'),
settleDate=as.Date('2002-2-19'),
dt=.25,
interpWhat="discount",
interpHow="loglinear")
tsQuotes <- list(d1w =0.0382,
d1m =0.0372,
fut1=96.2875,
fut2=96.7875,
fut3=96.9875,
fut4=96.6875,
fut5=96.4875,
fut6=96.3875,
fut7=96.2875,
fut8=96.0875,
s3y =0.0398,
s5y =0.0443,
s10y =0.05165,
s15y =0.055175)
## when both discount and libor curves are flat.
discountCurve.flat <- DiscountCurve(params, list(flat=0.05))
termstructure <- DiscountCurve(params, list(flat=0.03))
iborIndex.params <- list(type="USDLibor", length=6,
inTermOf="Month", term=termstructure)
FloatingRateBond(bond, gearings, spreads, caps, floors,
iborIndex.params, discountCurve.flat, dateparams)
RQuantLib/tests/tinytest.R 0000644 0001762 0000144 00000001034 13564352402 015265 0 ustar ligges users
if (requireNamespace("tinytest", quietly=TRUE) &&
utils::packageVersion("tinytest") >= "1.0.0") {
## Set a seed to make the test deterministic
set.seed(42)
## R makes us to this
Sys.setenv("R_TESTS"="")
## there are several more granular ways to test files in a tinytest directory,
## see its package vignette; tests can also run once the package is installed
## using the same command `test_package(pkgName)`, or by director or file
tinytest::test_package("RQuantLib", ncpu=getOption("Ncpus", 1))
}
RQuantLib/MD5 0000644 0001762 0000144 00000013237 15211275715 012437 0 ustar ligges users b7dcef93212638901bc945e18575378a *ChangeLog
bbe5b2aac5d3913325feb9c2b6009010 *DESCRIPTION
9f69341f2d42b0946ac130e1e3e59a8f *NAMESPACE
7cdb30b8289358d1a10c7ac5450f65eb *R/RcppExports.R
8bae9e10a0e0a48dd0b91bb6a0bde18d *R/affine.R
d1a8bb78523a6b3825293784e37f3844 *R/arrays.R
aa79aeacc8d63ddb3ac33b6706c05e1e *R/asian.R
29e7581085d455c1e624b5a42b3b955d *R/bermudan.R
688fbc14f3e3150e1e524f57b58a07fd *R/bond.R
199d4fe297a35feaa479c65d0d4eeaa4 *R/calendars.R
c946fbb142fc1ad588319ecf5b3b6fba *R/datasets.R
a0a4d7aa07a16c88bfcb94caf171b9b3 *R/dayCounter.R
b573f804569873ce3c288f1c2c09a5d6 *R/discount.R
b79175a852abf36508c1fe7c8be9546b *R/hullWhiteCalibration.R
f48a0decbbbedceb7dfb3b114017f5ec *R/implied.R
03c5562d493d8c2a9577aa3d3132d56d *R/inline.R
57bb1ee8b9bc6931658c5f4ef95f70e3 *R/mod.R
31a1b577670a34d0157b7ae02dd6d19e *R/option.R
3b7caab9ae86f5f083e58f68a3e109ba *R/sabr.R
1820845115c19f810eb0ccc279e4cce2 *R/schedule.R
cd95d1bdf925936fea0e4652d8d5b34a *R/zzz.R
b550c98423ce37e2f03b3daae68997cb *README.md
0b4e9a09b64bef80f5a626b72b29df56 *cleanup
be1868100555a0d307769767b6d1e1e0 *configure
25b3666492609da4785f228c252656d7 *configure.ac
a1bb4ffc7a0f00c377ae6543575ae883 *data/tsQuotes.RData
1e0ac485dcdc434f85725af29a43a0db *data/vcube.RData
fd060754d818864ca897476ff2b58f16 *demo/00Index
158727f1e40f6b5ad10f228368dc47bb *demo/OptionSurfaces.R
8887075c0be0b9a5ed5368d8b7b5333e *demo/ShinyDiscountCurves.R
2adf2228c562c11831db1d7ee0480cc6 *inst/Boost_LICENSE.TXT
911e6fdf49099b08bea0dcda89159651 *inst/NEWS.Rd
6ce07e1e9679d2c63ff4fe0bece5ad05 *inst/QuantLib_LICENSE.TXT
f4b079613d0dee5843973b30e0b6aa77 *inst/include/RQuantLib.h
f605ca62f473a6e55fe1c2e3f059a763 *inst/include/RQuantLib_RcppExports.h
b44e152e6474102c15d3a93e362061f8 *inst/include/rquantlib_impl.h
2b73eaabbd317786eaa99ac2f9506c65 *inst/include/rquantlib_internal.h
001d1eea5707e1b3369e95ee2165ad74 *inst/include/rquantlib_wrappers.h
11c98a9cc1dbd4604c20ad86cb85fff8 *inst/shiny/DiscountCurve/server.R
397d98cb41922fe368e6f0701d36d1f0 *inst/shiny/DiscountCurve/ui.R
078ee9b3bbaadf65afbfceded0d9d7e9 *inst/shiny/SabrSwaption/README.md
c56b0b08e1ee51334d5c2b76683ce3ec *inst/shiny/SabrSwaption/server.R
f278368b4f4e603e0a936c0c6691fba2 *inst/shiny/SabrSwaption/ui.R
ad9146ee33b853d522f948f4923ec75b *inst/shiny/SabrSwaption/volDF2CubeK.R
d8edd335ab2b7b0727a002c0ddf5cc39 *inst/shiny/SabrSwaption/volcube.csv
ca4e6472c457a1e9ade2b7f87a3a475c *inst/tinytest/cpp/dates.cpp
641daa9e7373fdc1e507e879d655af01 *inst/tinytest/test_businessdayconvention.R
3438bf4439d2f76c5ebb691364406dae *inst/tinytest/test_calendar.R
28ffb91bf505701b3fc021a34183cba5 *inst/tinytest/test_dates.R
78c29ac033586e11d981894f04c36b29 *inst/tinytest/test_options.R
b20c3e16585110e888e7d10a4fc017a8 *inst/tinytest/test_schedule.R
ca0cc805bc7aeef8b5a22fb725432f8a *man/AffineSwaption.Rd
c35e8c8c817064339eb55160453e20b5 *man/AmericanOption.Rd
698fea87e503d67ecd89b5f94897b995 *man/AmericanOptionImpliedVolatility.Rd
7106cd557e531d46b0a943b2743a1a57 *man/AsianOption.Rd
d6ea645d0732ae988f21d5c8ef7b3987 *man/BarrierOption.Rd
cc1ccf7d9a4992ba836ff09e6d790908 *man/BermudanSwaption.Rd
43367a3dafc302f71fcf90ebca10424c *man/BinaryOption.Rd
78e7221522ad4be2604f11b898470d73 *man/BinaryOptionImpliedVolatility.Rd
70b743b4e768d075ae01001b87c0f4bc *man/Bond.Rd
2446c79680df6c0d1044ae8566dbac46 *man/BondUtilities.Rd
7a7ab771e8d58207d57c0bc9e79293ab *man/Calendars.Rd
7d8351caa226d27cc8053c82ba940938 *man/CallableBond.Rd
79c0d19531d8a191bea8cf0fa62c0559 *man/ConvertibleBond.Rd
8608518fe8fd88a8b4bf0d77bbd98f70 *man/DiscountCurve.Rd
1319167b7971cf6e0b6d313bdeabb73d *man/Enum.Rd
974cabaa3e60ba9da6423baa73f4e4bf *man/EuropeanOption.Rd
f3b2273829d760d14adf849a434633e3 *man/EuropeanOptionArrays.Rd
cdc7a598916f6258cb63106cec8028a1 *man/EuropeanOptionImpliedVolatility.Rd
492a1def62a4dfa911be1db19d49e6dd *man/FittedBondCurve.Rd
056548b7d93c79a2c435eff1923f4bba *man/FixedRateBond.Rd
6d9a77ad05baedeac2a4b0c479a377f0 *man/FloatingRateBond.Rd
c1f1126ade1121bd416a8d12dc4b1d08 *man/ImpliedVolatility.Rd
bd33272fcb6f5075af9d4eac8543b482 *man/Option.Rd
cebcb30d66543a50b95b4f6ffe008c22 *man/SabrSwaption.Rd
fb2fa47e192132df023291a911cc07c9 *man/Schedule.Rd
8ef46f2f1a4b6a185fcb36c58dc98dec *man/ZeroCouponBond.Rd
465e234c2ac6746c492421cba8c557db *man/getQuantLibCapabilities.Rd
6d445a89d4f35f8fecbd0d29503c9bff *man/getQuantLibVersion.Rd
0abdd3c24763fc0d991155276b2f7577 *man/tsQuotes.Rd
b132afe2925ac2a027e19002d40ed388 *man/vcube.Rd
8870eb3132e96dfcc3d3ed50f223dfd0 *src/Makevars.in
39ccc28ce3677a73fe61956d4304e464 *src/Makevars.win
9213d18c4aa6e6464b0dc775fbbb8861 *src/RcppExports.cpp
1daa62867cb7b201cbc5e17a697dd47a *src/affine.cpp
3dc085eccadd5d1de2b50d0f6852ac45 *src/asian.cpp
b64ab5f3be714e5ecc6a6cabbd01c97f *src/barrier_binary.cpp
5b8f706bc0a4f3b8d864b1cd1d66e839 *src/bermudan.cpp
6b0f60ea3d4fc76eb56df9a1c0ea85d3 *src/bonds.cpp
fe0fe816e4c4bd4d4ec05a1cebb53a11 *src/calendars.cpp
0a9e2d427d5545a34d79befa152c073c *src/curves.cpp
b467ede776a5f35074b1b13011686dbe *src/dates.cpp
99eb924b6326ccef0f2d4e17b28e7790 *src/daycounter.cpp
5cbf1e336e97a65e20fdd61dc27aee44 *src/deprecated/rquantlib.h
d5d3c28120084a646790392999881490 *src/discount.cpp
69b23f4885012af746ae2648db7da8cb *src/hullwhite.cpp
b0b9b080c2efbdf717fed03b1ec56147 *src/implieds.cpp
30fc5d704106520e394d42a520045782 *src/modules.cpp
2a6ef65f3553cb2a38e2bfe5b8da2c20 *src/sabr.cpp
5c3a8515fe3237dc4b6e0d05e0424ea5 *src/schedule.cpp
618147b76a467b48a505571e68b374b3 *src/utils.cpp
a61d0504320b92699d09a348835766ce *src/vanilla.cpp
406bd3df1749ed959f1c3cf1762e4561 *src/zero.cpp
109f1aa5994f65aec7f0a6ee5cfedfc3 *tests/RQuantlib.R
8ec30eb98b0069708f04d87ef146fed0 *tests/tinytest.R
0e2ae09ae946a03f6e132b9aff0442ad *tools/build_RQuantLib.sh
95431c5a45d52d2d0ce34ab19ee95309 *tools/winlibs.R
RQuantLib/R/ 0000755 0001762 0000144 00000000000 15211270414 012311 5 ustar ligges users RQuantLib/R/sabr.R 0000644 0001762 0000144 00000015737 14234647620 013413 0 ustar ligges users ## RQuantLib function sabrSwaption
##
## Copyright (C) 2005 Dominick Samperi
## Copyright (C) 2007 - 2015 Dirk Eddelbuettel
## Copyright (C) 2016 Terry Leitch and 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 .
SabrSwaption <- function(params,
ts,volCubeDF,
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual"),
tsUp01=NA,tsDn01=NA,vega=FALSE) {
UseMethod("SabrSwaption")
}
SabrSwaption.default <- function(params,
ts, volCubeDF,
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual"),
tsUp01=NA,tsDn01=NA,vega=FALSE) {
# Check that params list names
if(is.null(params$startDate)){
params$startDate=advance("UnitedStates",params$tradeDate, 1, 3)
warning("swaption start date not set, defaulting to 1 year from trade date using US calendar")
}
if(is.null(params$expiryDate)){
params$expiryDate=params$startDate
warning("swaption expiry date not set, defaulting to 1 year from trade date using US calendar")
}
if(is.null(params$maturity)){
params$maturity=advance("UnitedStates",params$startDate, 5, 3)
warning("swaption maturity not set, defaulting to 5 years from startDate using US calendar")
}
volCube=volDF2CubeK(params,volCubeDF)
if(vega){
volCubeDF$LogNormalVol=volCubeDF$LogNormalVol+.01
volCubeUp=volDF2CubeK(params,volCubeDF)
}
swapTenors=volCube$tenors
if (!is.list(params) || length(params) == 0) {
stop("The params parameter must be a non-empty list", call.=FALSE)
}
swaptionMaturities=volCube$expiries
##reshape dataframe to fit QL call
vc=volDF2CubeK(params,volCubeDF)
matYears=as.numeric(params$maturity-params$tradeDate)/365
expYears=as.numeric(params$expiryDate-params$tradeDate)/365
if (inherits(ts, "DiscountCurve")) {
matchlegs<-matchParams(legparams)
val <- sabrengine(params, matchlegs, c(ts$table$date), ts$table$zeroRates,
volCube$expiries,volCube$tenors,volCube$atmVol,volCube$strikes,volCube$smirk)
if(vega){
valUp <- sabrengine(params, matchlegs, c(ts$table$date), ts$table$zeroRates,
volCubeUp$expiries,volCubeUp$tenors,volCubeUp$atmVol,volCubeUp$strikes,volCubeUp$smirk)
val$payVega=valUp$pay-val$pay
val$rcvVega=valUp$rcv-val$rcv
if(anyNA(tsUp01)){
}else{
valTsUp <- sabrengine(params, matchlegs, c(tsUp01$table$date), tsUp01$table$zeroRates,
volCube$expiries,volCube$tenors,volCube$atmVol,volCube$strikes,volCube$smirk)
val$payDV01=valTsUp$pay-val$pay
val$rcvDV01=valTsUp$rcv-val$rcv
if(anyNA(tsDn01)){
} else{
valTsDn <- sabrengine(params, matchlegs, c(tsDn01$table$date), tsDn01$table$zeroRates,
volCube$expiries,volCube$tenors,volCube$atmVol,volCube$strikes,volCube$smirk)
val$payCnvx=(valTsUp$pay+valTsDn$pay-2*val$pay)/2
val$rcvCnvx=(valTsUp$rcv+valTsDn$rcv-2*val$rcv)/2
}
}
}
} else{
stop("DiscountCurve class term structure required", call.=FALSE)
}
val$params=params
val$atmRate=as.numeric(val$atmRate)
class(val) <- "SabrSwaption"
summary(val)
val
}
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/R/RcppExports.R 0000644 0001762 0000144 00000033004 15211270414 014725 0 ustar ligges users # Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
affineWithRebuiltCurveEngine <- function(rparam, legparams, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols) {
.Call(`_RQuantLib_affineWithRebuiltCurveEngine`, rparam, legparams, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols)
}
asianOptionEngine <- function(averageType, type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, first, length, fixings) {
.Call(`_RQuantLib_asianOptionEngine`, averageType, type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, first, length, fixings)
}
binaryOptionEngine <- function(binType, type, excType, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter) {
.Call(`_RQuantLib_binaryOptionEngine`, binType, type, excType, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter)
}
binaryOptionImpliedVolatilityEngine <- function(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter) {
.Call(`_RQuantLib_binaryOptionImpliedVolatilityEngine`, type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter)
}
barrierOptionEngine <- function(barrType, type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, barrier, rebate, dayCounter) {
.Call(`_RQuantLib_barrierOptionEngine`, barrType, type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, barrier, rebate, dayCounter)
}
bermudanFromYieldEngine <- function(rparam, yield, swaptionMat, swapLengths, swaptionVols) {
.Call(`_RQuantLib_bermudanFromYieldEngine`, rparam, yield, swaptionMat, swapLengths, swaptionVols)
}
bermudanWithRebuiltCurveEngine <- function(rparam, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols) {
.Call(`_RQuantLib_bermudanWithRebuiltCurveEngine`, rparam, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols)
}
zeroPriceByYieldEngine <- function(yield, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate) {
.Call(`_RQuantLib_zeroPriceByYieldEngine`, yield, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate)
}
zeroYieldByPriceEngine <- function(price, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate) {
.Call(`_RQuantLib_zeroYieldByPriceEngine`, price, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate)
}
fixedRateBondYieldByPriceEngine <- function(settlementDays, price, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates) {
.Call(`_RQuantLib_fixedRateBondYieldByPriceEngine`, settlementDays, price, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates)
}
fixedRateBondPriceByYieldEngine <- function(settlementDays, yield, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates) {
.Call(`_RQuantLib_fixedRateBondPriceByYieldEngine`, settlementDays, yield, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates)
}
FloatBond1 <- function(bond, gearings, caps, spreads, floors, indexparams, index, discountCurve, dateparams) {
.Call(`_RQuantLib_FloatBond1`, bond, gearings, caps, spreads, floors, indexparams, index, discountCurve, dateparams)
}
FloatBond2 <- function(bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, discountCurve, dateparams) {
.Call(`_RQuantLib_FloatBond2`, bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, discountCurve, dateparams)
}
FloatBond3 <- function(bond, gearings, caps, spreads, floors, indexparams, index, disc_params, disc_tsQuotes, disc_times, dateparams) {
.Call(`_RQuantLib_FloatBond3`, bond, gearings, caps, spreads, floors, indexparams, index, disc_params, disc_tsQuotes, disc_times, dateparams)
}
FloatBond4 <- function(bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, disc_params, disc_tsQuotes, disc_times, dateparams) {
.Call(`_RQuantLib_FloatBond4`, bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, disc_params, disc_tsQuotes, disc_times, dateparams)
}
floatingWithRebuiltCurveEngine <- function(bondparams, gearings, spreads, caps, floors, indexparams, iborDateVec, iborzeroVec, dateVec, zeroVec, dateparams) {
.Call(`_RQuantLib_floatingWithRebuiltCurveEngine`, bondparams, gearings, spreads, caps, floors, indexparams, iborDateVec, iborzeroVec, dateVec, zeroVec, dateparams)
}
FixedRateWithYield <- function(bondparam, ratesVec, scheduleparam, calcparam, yield) {
.Call(`_RQuantLib_FixedRateWithYield`, bondparam, ratesVec, scheduleparam, calcparam, yield)
}
FixedRateWithPrice <- function(bondparam, ratesVec, scheduleparam, calcparam, price) {
.Call(`_RQuantLib_FixedRateWithPrice`, bondparam, ratesVec, scheduleparam, calcparam, price)
}
FixedRateWithRebuiltCurve <- function(bondparam, ratesVec, scheduleparam, calcparam, dateVec, zeroVec) {
.Call(`_RQuantLib_FixedRateWithRebuiltCurve`, bondparam, ratesVec, scheduleparam, calcparam, dateVec, zeroVec)
}
ZeroBondWithRebuiltCurve <- function(bond, dateVec, zeroVec, dateparams) {
.Call(`_RQuantLib_ZeroBondWithRebuiltCurve`, bond, dateVec, zeroVec, dateparams)
}
convertibleZeroBondEngine <- function(rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc) {
.Call(`_RQuantLib_convertibleZeroBondEngine`, rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc)
}
convertibleFixedBondEngine <- function(rparam, rates, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc) {
.Call(`_RQuantLib_convertibleFixedBondEngine`, rparam, rates, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc)
}
convertibleFloatingBondEngine <- function(rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, iborIndexDateVec, iborIndexZeroVec, iborparams, spreads, dividendScheduleFrame, callabilityScheduleFrame, datemisc) {
.Call(`_RQuantLib_convertibleFloatingBondEngine`, rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, iborIndexDateVec, iborIndexZeroVec, iborparams, spreads, dividendScheduleFrame, callabilityScheduleFrame, datemisc)
}
callableBondEngine <- function(rparam, hwparam, coupon, callabilityScheduleFrame, datemisc) {
.Call(`_RQuantLib_callableBondEngine`, rparam, hwparam, coupon, callabilityScheduleFrame, datemisc)
}
fittedBondCurveEngine <- function(curveparam, length, coupons, marketQuotes, datemisc) {
.Call(`_RQuantLib_fittedBondCurveEngine`, curveparam, length, coupons, marketQuotes, datemisc)
}
setCalendarContext <- function(calendar, fixingDays, settleDate) {
.Call(`_RQuantLib_setCalendarContext`, calendar, fixingDays, settleDate)
}
isBusinessDay <- function(calendar, dates) {
.Call(`_RQuantLib_isBusinessDay`, calendar, dates)
}
isHoliday <- function(calendar, dates) {
.Call(`_RQuantLib_isHoliday`, calendar, dates)
}
isWeekend <- function(calendar, dates) {
.Call(`_RQuantLib_isWeekend`, calendar, dates)
}
isEndOfMonth <- function(calendar, dates) {
.Call(`_RQuantLib_isEndOfMonth`, calendar, dates)
}
getEndOfMonth <- function(calendar, dates) {
.Call(`_RQuantLib_getEndOfMonth`, calendar, dates)
}
adjust <- function(calendar, dates, bdc = 0L) {
.Call(`_RQuantLib_adjust`, calendar, dates, bdc)
}
advance1 <- function(calendar, amount, unit, bdcVal, emr, dates) {
.Call(`_RQuantLib_advance1`, calendar, amount, unit, bdcVal, emr, dates)
}
advance2 <- function(calendar, period, bdcVal, emr, dates) {
.Call(`_RQuantLib_advance2`, calendar, period, bdcVal, emr, dates)
}
businessDaysBetween <- function(calendar, from, to, includeFirst = TRUE, includeLast = FALSE) {
.Call(`_RQuantLib_businessDaysBetween`, calendar, from, to, includeFirst, includeLast)
}
getHolidayList <- function(calendar, from, to, includeWeekends = FALSE) {
.Call(`_RQuantLib_getHolidayList`, calendar, from, to, includeWeekends)
}
getBusinessDayList <- function(calendar, from, to) {
.Call(`_RQuantLib_getBusinessDayList`, calendar, from, to)
}
addHolidays <- function(calendar, dates) {
invisible(.Call(`_RQuantLib_addHolidays`, calendar, dates))
}
removeHolidays <- function(calendar, dates) {
invisible(.Call(`_RQuantLib_removeHolidays`, calendar, dates))
}
advanceDate <- function(issueDate, days) {
.Call(`_RQuantLib_advanceDate`, issueDate, days)
}
dayCount <- function(startDates, endDates, dayCounters) {
.Call(`_RQuantLib_dayCount`, startDates, endDates, dayCounters)
}
yearFraction <- function(startDates, endDates, dayCounters) {
.Call(`_RQuantLib_yearFraction`, startDates, endDates, dayCounters)
}
setEvaluationDate <- function(evalDate) {
.Call(`_RQuantLib_setEvaluationDate`, evalDate)
}
discountCurveEngine <- function(rparams, tslist, times, legParams) {
.Call(`_RQuantLib_discountCurveEngine`, rparams, tslist, times, legParams)
}
calibrateHullWhiteUsingCapsEngine <- function(termStrcDateVec, termStrcZeroVec, capDF, iborDateVec, iborZeroVec, iborType, evalDate) {
.Call(`_RQuantLib_calibrateHullWhiteUsingCapsEngine`, termStrcDateVec, termStrcZeroVec, capDF, iborDateVec, iborZeroVec, iborType, evalDate)
}
calibrateHullWhiteUsingSwapsEngine <- function(termStrcDateVec, termStrcZeroVec, swapDF, iborDateVec, iborZeroVec, iborType, evalDate) {
.Call(`_RQuantLib_calibrateHullWhiteUsingSwapsEngine`, termStrcDateVec, termStrcZeroVec, swapDF, iborDateVec, iborZeroVec, iborType, evalDate)
}
europeanOptionImpliedVolatilityEngine <- function(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, dayCounter) {
.Call(`_RQuantLib_europeanOptionImpliedVolatilityEngine`, type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, dayCounter)
}
americanOptionImpliedVolatilityEngine <- function(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volguess, timesteps, gridpoints, dayCounter) {
.Call(`_RQuantLib_americanOptionImpliedVolatilityEngine`, type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volguess, timesteps, gridpoints, dayCounter)
}
sabrengine <- function(rparam, legParams, dateVec, zeroVec, swaptionMat, swapLengths, atmVols, strikes, smirkVols) {
.Call(`_RQuantLib_sabrengine`, rparam, legParams, dateVec, zeroVec, swaptionMat, swapLengths, atmVols, strikes, smirkVols)
}
CreateSchedule <- function(params) {
.Call(`_RQuantLib_CreateSchedule`, params)
}
#' This function returns the QuantLib version string as encoded in the header
#' file \code{config.hpp} and determined at compilation time of the QuantLib library.
#'
#' @title Return the QuantLib version number
#' @return A character variable
#' @references \url{https://www.quantlib.org} for details on \code{QuantLib}.
#' @author Dirk Eddelbuettel
#' @examples
#' getQuantLibVersion()
getQuantLibVersion <- function() {
.Call(`_RQuantLib_getQuantLibVersion`)
}
#' This function returns a named vector of boolean variables describing several
#' configuration options determined at compilation time of the QuantLib library.
#'
#' Not all of these features are used (yet) by RQuantLib.
#' @title Return configuration options of the QuantLib library
#' @return A named vector of logical variables
#' @references \url{https://www.quantlib.org} for details on \code{QuantLib}.
#' @author Dirk Eddelbuettel
#' @examples
#' getQuantLibCapabilities()
getQuantLibCapabilities <- function() {
.Call(`_RQuantLib_getQuantLibCapabilities`)
}
europeanOptionEngine <- function(type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, discreteDividends, discreteDividendsTimeUntil, dayCounter) {
.Call(`_RQuantLib_europeanOptionEngine`, type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, discreteDividends, discreteDividendsTimeUntil, dayCounter)
}
americanOptionEngine <- function(type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, timeSteps, gridPoints, engine, discreteDividends, discreteDividendsTimeUntil, dayCounter) {
.Call(`_RQuantLib_americanOptionEngine`, type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, timeSteps, gridPoints, engine, discreteDividends, discreteDividendsTimeUntil, dayCounter)
}
europeanOptionArraysEngine <- function(type, par) {
.Call(`_RQuantLib_europeanOptionArraysEngine`, type, par)
}
zeroprice <- function(yield, maturity, settle, period, basis) {
.Call(`_RQuantLib_zeroprice`, yield, maturity, settle, period, basis)
}
zeroyield <- function(price, maturity, settle, period, basis) {
.Call(`_RQuantLib_zeroyield`, price, maturity, settle, period, basis)
}
# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
.Call(`_RQuantLib_RcppExport_registerCCallable`)
})
RQuantLib/R/dayCounter.R 0000644 0001762 0000144 00000002500 12313406102 014541 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Khanh Nguyen
## Copyright (C) 2012 - 2014 Dirk Eddelbuettel
##
## This file is part of the RQuantLib library for GNU R.
## It is made available under the terms of the GNU General Public
## License, version 2, or at your option, any later version,
## incorporated herein by reference.
##
## This program 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 this program; if not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
## MA 02111-1307, USA
#dayCount <- function(startDates, endDates, dayCounters) {
# val <- .Call('dayCount', startDates, endDates, dayCounters, PACKAGE="RQuantLib")
# invisible(val)
#}
#yearFraction <- function(startDates, endDates, dayCounters) {
# val <- .Call('yearFraction', startDates, endDates, dayCounters, PACKAGE="RQuantLib")
# invisible(val)
#}
#setEvaluationDate <- function(evalDate) {
# val <- .Call("setEvaluationDate", evalDate, PACKAGE="RQuantLib")
# invisible(val)
#}
RQuantLib/R/arrays.R 0000644 0001762 0000144 00000016514 14356061352 013754 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2014 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 .
oldEuropeanOptionArrays <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility) {
n.underlying <- length(underlying)
n.strike <- length(strike)
n.dividendYield <- length(dividendYield)
n.riskFreeRate <- length(riskFreeRate)
n.maturity <- length(maturity)
n.volatility <- length(volatility)
res <- numeric(n.underlying * n.strike * n.dividendYield * n.riskFreeRate *
n.maturity * n.volatility)
dim(res) <- c(n.underlying, n.strike, n.dividendYield, n.riskFreeRate,
n.maturity, n.volatility)
dimnames(res) <- list(paste("s",underlying,sep="="),
paste("k",strike,sep="="),
paste("y",dividendYield,sep="="),
paste("r",riskFreeRate,sep="="),
paste("t",maturity,sep="="),
paste("v",volatility,sep="="))
value <- delta <- gamma <- vega <- theta <- rho <- divRho <- res
for (s in 1:n.underlying) {
for (k in 1:n.strike) {
for (y in 1:n.dividendYield) {
for (r in 1:n.riskFreeRate) {
for (t in 1:n.maturity) {
for (v in 1:n.volatility) {
val <- europeanOptionEngine(type, underlying, strike,
dividendYield, riskFreeRate,
maturity, volatility)
value[s,k,y,r,t,v] <- val$value
delta[s,k,y,r,t,v] <- val$delta
gamma[s,k,y,r,t,v] <- val$gamma
vega[s,k,y,r,t,v] <- val$vega
theta[s,k,y,r,t,v] <- val$theta
rho[s,k,y,r,t,v] <- val$rho
divRho[s,k,y,r,t,v] <- val$divRho
}
}
}
}
}
}
value <- drop(value)
delta <- drop(delta)
gamma <- drop(gamma)
vega <- drop(vega)
theta <- drop(theta)
rho <- drop(rho)
divRho <- drop(divRho)
invisible(list(value=value, delta=delta, gamma=gamma, vega=vega,
theta=theta, rho=rho, divRho=divRho,
parameters=list(type=type, underlying=underlying,
strike=strike, dividendYield=dividendYield,
riskFreeRate=riskFreeRate, maturity=maturity,
volatility=volatility)))
}
EuropeanOptionArrays <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility) {
## check that we have two vectors
lv <- c(length(underlying) > 1,
length(strike) > 1,
length(dividendYield) > 1,
length(riskFreeRate) > 1, +
length(maturity) > 1, +
length(volatility) > 1)
if (sum(lv) != 2) {
warning("Need exactly two arguments as vectors")
return(NULL)
}
type <- match.arg(type, c("call", "put"))
## expand parameters
pars <- expand.grid(underlying, strike, dividendYield,
riskFreeRate, maturity, volatility)
nonconst <- which( apply(pars, 2, sd) != 0)
colnames <- c("spot", "strike", "div", "rfrate", "mat", "vol")
val <- europeanOptionArraysEngine(type, as.matrix(pars))
## turn list of vectors in to list of matrices
par1 <- unique(pars[, nonconst[1]])
par2 <- unique(pars[, nonconst[2]])
len1 <- length(par1)
len2 <- length(par2)
ml <- lapply(val, function(x) matrix(x, len1, len2, dimnames=list(par1,par2)))
return(c(ml, parameters=list(type=type, underlying=underlying,
strike=strike, dividendYield=dividendYield,
riskFreeRate=riskFreeRate, maturity=maturity,
volatility=volatility)))
}
plotOptionSurface <- function(EOres, ylabel="", xlabel="", zlabel="", fov=60) {
if (requireNamespace("rgl", quietly=TRUE)) {
if (missing(EOres)) {
message("No 'EOres' argument supplied. Calling 'EuropeanOptionArrays' to show 'delta'.\n",
"See help('EuropeanOptionArrays') for function parameters and available result\n",
"matrices in the returned list object.")
und.seq <- seq(10,180,by=2)
vol.seq <- seq(0.1,0.9,by=0.1)
## evaluate them along with three scalar parameters
EOarr <- EuropeanOptionArrays("call", underlying=und.seq,
strike=100, dividendYield=0.01,
riskFreeRate=0.03,
maturity=1, volatility=vol.seq)
EOres <- EOarr$delta
}
if (packageVersion("rgl") < "0.111.5")
surface3d <- rgl::rgl.surface
else
surface3d <- rgl::surface3d
axis.col <- "black"
text.col <- axis.col
ylab <- ylabel
xlab <- xlabel
zlab <- zlabel
y <- EOres
## clear scene:
rgl::clear3d()
rgl::clear3d(type="bbox")
rgl::clear3d(type="lights")
## setup env:
rgl::bg3d(color="#DDDDDD")
rgl::light3d()
rgl::view3d(fov=fov)
x <- 1:nrow(y)
z <- 1:ncol(y)
x <- (x-min(x))/(max(x)-min(x))
y <- (y-min(y))/(max(y)-min(y))
z <- (z-min(z))/(max(z)-min(z))
surface3d(x = x, y = y, z = z, alpha=0.6, lit=TRUE, color="blue")
rgl::lines3d(c(0,1), c(0,0), c(0,0), col=axis.col)
rgl::lines3d(c(0,0), c(0,1), c(0,0), col=axis.col)
rgl::lines3d(c(0,0),c(0,0), c(0,1), col=axis.col)
rgl::text3d(1,0,0, xlab, adj=1, col=text.col)
rgl::text3d(0,1,0, ylab, adj=1, col=text.col)
rgl::text3d(0,0,1, zlab, adj=1, col=text.col)
## add grid (credit's to John Fox scatter3d)
xgridind <- round(seq(1, nrow(y), length=25))
zgridind <- round(seq(1, ncol(y), length=25))
surface3d(x = x[xgridind], y = y[xgridind,zgridind], z = z[zgridind],
color="darkgray", alpha=0.5, lit=TRUE,
front="lines", back="lines")
## animate (credit to view3d() example)
start <- proc.time()[3]
while ((i <- 36*(proc.time()[3]-start)) < 360) {
rgl::view3d(i,i/8);
}
} else {
message("Please install the 'rgl' package before using this function.")
}
}
utils::globalVariables(c("clear3d", "bg3d", "ligh3d", "view3d", "surface3d", "text3d"))
RQuantLib/R/affine.R 0000644 0001762 0000144 00000015631 14234647545 013713 0 ustar ligges users ## RQuantLib function AffineSwaption
##
## Copyright (C) 2005 Dominick Samperi
## Copyright (C) 2007 - 2014 Dirk Eddelbuettel
## Copyright (C) 2016 - 2022 Terry Leitch and 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 .
AffineSwaption <- function(params,
ts, swaptionMaturities,
swapTenors, volMatrix,
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")) {
UseMethod("AffineSwaption")
}
AffineSwaption.default <- function(params,
ts, swaptionMaturities,
swapTenors, volMatrix,
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")) {
# Check that params list names
if (!is.list(params) || length(params) == 0) {
stop("The params parameter must be a non-empty list", call.=FALSE)
}
if(is.null(params$startDate)){
params$startDate=advance("UnitedStates",params$tradeDate, 1, 3)
warning("swaption start date not set, defaulting to 1 year from trade date using US calendar")
}
if(is.null(params$maturity)){
params$maturity=advance("UnitedStates",params$startDate, 5, 3)
warning("swaption maturity not set, defaulting to 5 years from startDate using US calendar")
}
if(is.null(params$european)){
params$european=TRUE
warning("affine swaption european flag not set defaulting to european")
}
if(is.null(params$payFix)){
params$payFix=TRUE
warning("affine swaption payFix flag not set defaulting to pay fix swap")
}
matYears=as.numeric(params$maturity-params$tradeDate)/365
expYears=as.numeric(params$startDate-params$tradeDate)/365
increment=min(matYears/6,1.0)
numObs=floor(matYears/increment)+1
optStart=as.numeric(params$startDate-params$tradeDate)/365
# find closest option to our target to ensure it is in calibration
tenor=expiry=vol=vector(length=numObs,mode="numeric")
expiryIDX=findInterval(expYears,swaptionMaturities)
tenorIDX=findInterval(matYears-expYears,swapTenors)
if(tenorIDX >0 & expiryIDX>0){
vol[1]=volMatrix[expiryIDX,tenorIDX]
expiry[1]=swaptionMaturities[expiryIDX]
tenor[1]=swapTenors[tenorIDX]
} else {
vol[1]=expiry[1]=tenor[1]=0
}
for(i in 2:numObs){
expiryIDX=findInterval(i*increment,swaptionMaturities)
tenorIDX=findInterval(matYears-(i-1)*increment,swapTenors)
if(tenorIDX >0 & expiryIDX>0){
vol[i]=volMatrix[expiryIDX,tenorIDX]
expiry[i]=swaptionMaturities[expiryIDX]
tenor[i]=swapTenors[tenorIDX]
} else {
vol[i]=volMatrix[expiryIDX,tenorIDX+1]
expiry[i]=swaptionMaturities[expiryIDX]
tenor[i]=swapTenors[tenorIDX+1]
}
}
# remove if search was out of bounds
expiry=expiry[expiry>0];tenor=tenor[tenor>0];vol=vol[vol>0]
if(length(expiry)<5){
warning("Insufficent vols to fit affine model")
return(NULL)
}
#Take 1st 5 which includes closest to initial date
expiry=expiry[1:5];tenor=tenor[1:5];vol=vol[1:5]
# Finally ready to make the call...
# We could coerce types here and pass as.integer(round(swapTenors)),
# temp <- as.double(volMatrix), dim(temp) < dim(a) [and pass temp instead
# of volMatrix]. But this is taken care of in the C/C++ code.
if (inherits(ts, "DiscountCurve")) {
matchlegs<-matchParams(legparams)
val <- affineWithRebuiltCurveEngine(params, matchlegs, c(ts$table$date), ts$table$zeroRates,
expiry,tenor,vol)
} else{
stop("DiscountCurve class term structure required", call.=FALSE)
}
class(val) <- paste(params$method, "AffineSwaption",sep="")
summary(val)
val
}
summary.G2AnalyticAffineSwaption <- function(object,...) {
cat('\n\tSummary of pricing results for Affine Swaption\n')
cat('\nPrice (in bp) of Affine swaption is ', object$NPV)
cat('\nStike is ', format(object$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: G2/Jamshidian using analytic formulas')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nb = ', format(object$b,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\neta = ', format(object$eta,digits=4))
cat('\nrho = ', format(object$rho,digits=4))
cat('\n\n')
}
summary.HWAnalyticAffineSwaption <- function(object,...) {
cat('\n\tSummary of pricing results for Affine Swaption\n')
cat('\nPrice (in bp) of Affine swaption is ', object$NPV)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Hull-White using analytic formulas')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
summary.HWTreeAffineSwaption <- function(object,...) {
cat('\n\tSummary of pricing results for Affine Swaption\n')
cat('\nPrice (in bp) of Affine swaption is ', object$NPV)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Hull-White using a tree')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
summary.BKTreeAffineSwaption <- function(object,...) {
cat('\n\tSummary of pricing results for Affine Swaption\n')
cat('\nPrice (in bp) of Affine swaption is ', object$NPV)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Black-Karasinski using a tree')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
RQuantLib/R/option.R 0000644 0001762 0000144 00000013205 15165305444 013757 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002-2026 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 .
EuropeanOption <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
discreteDividends = NULL, discreteDividendsTimeUntil = NULL,
dayCounter = 0) {
UseMethod("EuropeanOption")
}
EuropeanOption.default <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
discreteDividends = NULL, discreteDividendsTimeUntil = NULL,
dayCounter = 0) {
type <- match.arg(type, c("call", "put"))
val <- europeanOptionEngine(type, underlying, strike, dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, discreteDividends, discreteDividendsTimeUntil, dayCounter)
class(val) <- c("EuropeanOption", "Option")
val
}
AmericanOption <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
timeSteps=150, gridPoints=149, engine="BaroneAdesiWhaley",
discreteDividends = NULL, discreteDividendsTimeUntil = NULL,
dayCounter = 0) {
UseMethod("AmericanOption")
}
AmericanOption.default <- function(type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
timeSteps=150, gridPoints=149, engine="BaroneAdesiWhaley",
discreteDividends = NULL, discreteDividendsTimeUntil = NULL,
dayCounter = 0) {
type <- match.arg(type, c("call", "put"))
engine <- match.arg(engine, c("BaroneAdesiWhaley", "CrankNicolson"))
val <- americanOptionEngine(type, underlying, strike, dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, timeSteps, gridPoints, engine,
discreteDividends, discreteDividendsTimeUntil, dayCounter)
class(val) <- c("AmericanOption","Option")
val
}
BinaryOption <- function(binType, type, excType, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility, cashPayoff, dayCounter=0) {
UseMethod("BinaryOption")
}
BinaryOption.default <- function(binType, type, excType, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility, cashPayoff, dayCounter=0) {
type <- match.arg(type, c("call", "put"))
binType <- match.arg(binType, c("cash", "asset", "gap"))
excType <- match.arg(excType, c("american", "european"))
val <- binaryOptionEngine(binType, type, excType, underlying,
strike, dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, cashPayoff, dayCounter)
class(val) <- c("BinaryOption", "Option")
val
}
BarrierOption <- function(barrType, type, underlying, strike,
dividendYield, riskFreeRate, maturity,
volatility, barrier, rebate=0.0, dayCounter=0) {
UseMethod("BarrierOption")
}
BarrierOption.default <- function(barrType, type, underlying, strike,
dividendYield, riskFreeRate, maturity,
volatility, barrier, rebate=0.0, dayCounter=0) {
type <- match.arg(type, c("call", "put"))
barrType <- match.arg(barrType, c("downin", "upin", "downout", "upout"))
val <- barrierOptionEngine(barrType, type, underlying, strike, dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, barrier, rebate, dayCounter)
class(val) <- c("BarrierOption", "Option")
val
}
plot.Option <- function(x, ...) {
warning("No plotting available for class", class(x)[1],"\n")
invisible(x)
}
print.Option <- function(x, digits=4, ...) {
cat("Concise summary of valuation for", class(x)[1], "\n")
print(round(unlist(x[1:7]), digits))
invisible(x)
}
summary.Option <- function(object, digits=4, ...) {
cat("Detailed summary of valuation for", class(object)[1], "\n")
print(round(unlist(object[1:7]), digits))
cat("with parameters\n")
print(unlist(object[["parameters"]]))
invisible(object)
}
RQuantLib/R/hullWhiteCalibration.R 0000644 0001762 0000144 00000004021 12315613340 016547 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2010 Dirk Eddelbuettel and Khanh Nguyen
##
## 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 .
hullWhiteCalibrateUsingCap <- function(termStrc, capHelpers,
index, evaluationDate) {
capData <- capHelpers$data
ibor <- index$term
val <- calibrateHullWhiteUsingCapsEngine(termStrc$table$date,
termStrc$table$zeroRates,
capData,
ibor$table$date,
ibor$table$zeroRates,
index$type,
evaluationDate)
}
hullWhiteCalibrateUsingSwap <- function(termStrc, swapHelpers,
index, evaluationDate) {
swapData <- swapHelpers$data
ibor <- index$term
val <- calibrateHullWhiteUsingSwapsEngine(termStrc$table$date,
termStrc$table$zeroRates,
swapData,
ibor$table$date,
ibor$table$zeroRates,
index$type,
evaluationDate)
}
RQuantLib/R/implied.R 0000644 0001762 0000144 00000011254 15152151466 014073 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002-2026 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 .
## also dumps core (0.3.7)
## no longer under 0.3.9 and 0.3.10 with g++ 3.4/4.0
EuropeanOptionImpliedVolatility <- function(type, value, underlying,
strike, dividendYield,
riskFreeRate, maturity,
volatility, dayCounter=0) {
UseMethod("EuropeanOptionImpliedVolatility")
}
EuropeanOptionImpliedVolatility.default <- function(type, value, underlying,
strike, dividendYield,
riskFreeRate, maturity,
volatility, dayCounter=0) {
val <- europeanOptionImpliedVolatilityEngine(type, value, underlying, strike,
dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, dayCounter)
class(val) <- c("EuropeanOptionImpliedVolatility","ImpliedVolatility")
val
}
# also dumps core (0.3.7)
## no longer under 0.3.9 and 0.3.10 with g++ 3.4/4.0
AmericanOptionImpliedVolatility <- function(type, value, underlying, strike,
dividendYield, riskFreeRate,
maturity, volatility,
timeSteps=150, gridPoints=151,
dayCounter=0) {
UseMethod("AmericanOptionImpliedVolatility")
}
AmericanOptionImpliedVolatility.default <- function(type, value, underlying, strike,
dividendYield, riskFreeRate, maturity,
volatility, timeSteps=150, gridPoints=151,
dayCounter=0) {
val <- americanOptionImpliedVolatilityEngine(type, value, underlying, strike,
dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, timeSteps, gridPoints,
dayCounter)
val
}
BinaryOptionImpliedVolatility <- function(type, value, underlying, strike, dividendYield, riskFreeRate,
maturity, volatility, cashPayoff=1, dayCounter=0) {
UseMethod("BinaryOptionImpliedVolatility")
}
BinaryOptionImpliedVolatility.default <- function(type, value, underlying, strike, dividendYield, riskFreeRate,
maturity, volatility, cashPayoff=1, dayCounter=0) {
val <- binaryOptionImpliedVolatilityEngine(type, value, underlying, strike, dividendYield, riskFreeRate,
if (inherits(maturity, "numeric")) maturity else NULL,
if (inherits(maturity, "Date")) maturity else NULL,
volatility, cashPayoff, dayCounter)
class(val) <- c("BinaryOptionImpliedVolatility","ImpliedVolatility")
val
}
print.ImpliedVolatility <- function(x, digits=3, ...) {
impvol <- x[[1]]
cat("Implied Volatility for", class(x)[1], "is", round(impvol, digits), "\n")
invisible(x)
}
summary.ImpliedVolatility <- function(object, digits=3, ...) {
impvol <- object[[1]]
cat("Implied Volatility for", class(object)[1], "is", round(impvol, digits), "\n")
#cat("with parameters\n")
#print(unlist(object[[2]]))
invisible(object)
}
RQuantLib/R/zzz.R 0000644 0001762 0000144 00000003634 14611016101 013271 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2024 Dirk Eddelbuettel
##
## This file is part of the RQuantLib library for GNU R.
## It is made available under the terms of the GNU General Public
## License, version 2, or at your option, any later version,
## incorporated herein by reference.
##
## This program 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 this program; if not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
## MA 02111-1307, USA
#.First.lib <- function(lib, pkg) {
# #cat("This is a pre-release. The interface might change...\n")
# library.dynam("RQuantLib", pkg, lib )
#}
.onAttach <- function(libname, pkgname) {
## if it is not interactive (as eg in testing or cronjobs), do nothing
if (!interactive()) return(invisible(NULL))
## else let's test the QuantLib version, and then the intraday capability
qlver <- gsub("-[a-z]+", "", getQuantLibVersion())
if (compareVersion(qlver, "1.7") < 0) {
packageStartupMessage("QuantLib version ", qlver, " detected which is older than 1.7.")
packageStartupMessage("Intra-daily options analytics unavailable with that version.")
} else if (!getQuantLibCapabilities()[["intradayDate"]]) {
packageStartupMessage("Sufficient QuantLib version with insufficient configuration.")
packageStartupMessage("Try configuring your build with the --enable-intraday argument.")
}
packageStartupMessage("RQuantLib ", packageVersion("RQuantLib"), " built with QuantLib version ",
qlver, ". See https://www.quantlib.org for more on QuantLib.")
}
RQuantLib/R/bond.R 0000644 0001762 0000144 00000074473 12722576357 013420 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2014 Dirk Eddelbuettel
## Copyright (C) 2009 Khanh Nguyen
## Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Khanh Nguyen
##
## 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 .
ZeroCouponBond <- function(bond, discountCurve, dateparams ) {
UseMethod("ZeroCouponBond")
}
## TODO: redo interface here
ZeroCouponBond.default <- function(bond,
discountCurve,
dateparams=list(refDate=bond$issueDate,
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
businessDayConvention='Following')) {
val <- 0
if (is.null(bond$faceAmount)) bond$faceAmount <- 100
if (is.null(bond$redemption)) bond$redemption <- 100
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$refDate)) dateparams$refDate <- bond$issueDate
dateparams <- matchParams(dateparams)
val <- ZeroBondWithRebuiltCurve(bond, c(discountCurve$table$date),
discountCurve$table$zeroRates, dateparams)
class(val) <- c("ZeroCouponBond", "Bond")
val
}
ZeroPriceByYield <- function(yield, faceAmount,
issueDate, maturityDate,
dayCounter, frequency,
compound, businessDayConvention){
UseMethod("ZeroPriceByYield")
}
ZeroPriceByYield.default <- function(yield, faceAmount=100,
issueDate, maturityDate,
dayCounter=2, frequency=2,
compound=0, businessDayConvention=4) {
val <- zeroPriceByYieldEngine(yield, faceAmount, dayCounter,
frequency, businessDayConvention,
compound, maturityDate, issueDate)
class(val) <- c("ZeroPriceByYield")
val
}
ZeroYield <- function(price, faceAmount, issueDate, maturityDate,
dayCounter, frequency, compound, businessDayConvention) {
UseMethod("ZeroYield")
}
ZeroYield.default <- function(price, faceAmount=100,
issueDate, maturityDate,
dayCounter=2, frequency=2,
compound=0, businessDayConvention=4) {
val <- zeroYieldByPriceEngine(price, faceAmount, dayCounter, frequency,
businessDayConvention, compound,
maturityDate, issueDate)
class(val) <- c("ZeroYield")
val
}
FixedRateBond <- function(bond, rates, schedule, calc, discountCurve, yield, price){
UseMethod("FixedRateBond")
}
FixedRateBond.default <- function(bond = list(),
rates,
schedule,
calc=list(
dayCounter='ActualActual.ISMA',
compounding='Compounded',
freq='Annual',
durationType='Modified'),
discountCurve = NULL,
yield = NA,
price = NA){
val <- 0
# check bond params
if (is.null(bond$settlementDays)) bond$settlementDays <- 1
if (is.null(bond$faceAmount)) bond$faceAmount <- 100
if (is.null(bond$dayCounter)) bond$dayCounter <- 'Thirty360'
# additional parameters have default values on cpp side (see QuantLib::FixedRateBond first ctor)
# paymentConvention
# redemption
# issueDate
# paymentCalendar
# exCouponPeriod
# exCouponCalendar
# exCouponConvention
# exCouponEndOfMonth
bond <- matchParams(bond)
# check schedule params
if (is.null(schedule$effectiveDate)){
stop("schedule effective date undefined.")
}
if (is.null(schedule$maturityDate)){
stop("schedule maturity date undefined.")
}
if (is.null(schedule$period)) schedule$period <- 'Semiannual'
if (is.null(schedule$calendar)) schedule$calendar <- 'TARGET'
if (is.null(schedule$businessDayConvention)) schedule$businessDayConvention <- 'Following'
if (is.null(schedule$terminationDateConvention)) schedule$terminationDateConvention <- 'Following'
if (is.null(schedule$dateGeneration)) schedule$dateGeneration <- 'Backward'
if (is.null(schedule$endOfMonth)) schedule$endOfMonth <- 0
schedule <- matchParams(schedule)
# check calc params
if (is.null(calc$dayCounter)) calc$dayCounter <- 'ActualActual.ISMA'
if (is.null(calc$compounding)) calc$compounding <- 'Compounded'
if (is.null(calc$freq)) calc$freq <- 'Annual'
if (is.null(calc$durationType)) calc$durationType <- 'Simple'
if (is.null(calc$accuracy)) calc$accuracy <- 1.0e-8
if (is.null(calc$maxEvaluations)) calc$maxEvaluations <- 100
calc <- matchParams(calc)
which.calc <- !c(is.null(discountCurve), is.na(yield), is.na(price))
if (sum(which.calc) != 1)
stop("one and only one of discountCurve, yield or price must be defined.")
if (!is.null(discountCurve)) {
val <- FixedRateWithRebuiltCurve(
bond, rates, schedule, calc, c(discountCurve$table$date), discountCurve$table$zeroRates)
} else if (!is.na(yield)) {
val <- FixedRateWithYield(bond, rates, schedule, calc, yield)
} else if (!is.na(price)) {
val <- FixedRateWithPrice(bond, rates, schedule, calc, price)
}
class(val) <- c("FixedRateBond", "Bond")
val
}
FixedRateBondYield <- function(settlementDays, price, faceAmount,
effectiveDate, maturityDate,
period, calendar, rates,
dayCounter, businessDayConvention,
compound, redemption, issueDate) {
UseMethod("FixedRateBondYield")
}
FixedRateBondYield.default <- function(settlementDays = 1, price, faceAmount=100,
effectiveDate, maturityDate,
period, calendar = "UnitedStates/GovernmentBond", rates,
dayCounter=2, businessDayConvention=0,
compound = 0, redemption = 100, issueDate) {
val <- fixedRateBondYieldByPriceEngine(settlementDays, price, calendar, faceAmount,
businessDayConvention,
compound, redemption, dayCounter,
period, ## aka frequency
maturityDate, issueDate, effectiveDate,
rates)
class(val) <- c("FixedRateBondYield")
val
}
FixedRateBondPriceByYield <- function(settlementDays, yield, faceAmount,
effectiveDate, maturityDate,
period, calendar, rates,
dayCounter, businessDayConvention,
compound, redemption, issueDate) {
UseMethod("FixedRateBondPriceByYield")
}
FixedRateBondPriceByYield.default <- function(settlementDays = 1, yield, faceAmount=100,
effectiveDate=issueDate, maturityDate,
period, calendar = "UnitedStates/GovernmentBond", rates,
dayCounter=2, businessDayConvention=0,
compound = 0, redemption = 100, issueDate) {
val <- fixedRateBondPriceByYieldEngine(settlementDays, yield, calendar, faceAmount,
businessDayConvention,
compound, redemption, dayCounter, period,
maturityDate, issueDate, effectiveDate,
rates)
class(val) <- c("FixedRateBondPriceByYield")
val
}
FloatingRateBond <- function(bond, gearings, spreads, caps, floors,
index, curve, dateparams){
UseMethod("FloatingRateBond")
}
FloatingRateBond.default <- function(bond,
gearings=vector(),
spreads=vector(),
caps=vector(),
floors=vector(),
index,
curve,
dateparams=list(refDate=bond$issueDate-2,
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
businessDayConvention='Following',
terminationDateConvention='Following',
dayCounter='Thirty360',
period='Semiannual',
dateGeneration='Backward',
endOfMonth=0,
fixingDays=2)
) {
val <- 0
if (is.null(bond$faceAmount)) bond$faceAmount <- 100
if (is.null(bond$redemption)) bond$redemption <- 100
if (is.null(bond$effectiveDate)) bond$effectiveDate <- bond$issueDate
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$terminationDateConvention)) dateparams$terminationDateConvention <- 'Following'
if (is.null(dateparams$dayCounter)) dateparams$dayCounter <- 'Thirty360'
if (is.null(dateparams$period)) dateparams$period <- 'Semiannual'
if (is.null(dateparams$dateGeneration)) dateparams$dateGeneration <- 'Backward'
if (is.null(dateparams$endOfMonth)) dateparams$endOfMonth <- 0
if (is.null(dateparams$fixingDays)) dateparams$fixingDays <- 2
if (is.null(dateparams$refDate)) dateparams$refDate <- bond$issueDate-2
dateparams <- matchParams(dateparams)
indexparams <- list(type=index$type, length=index$length, inTermOf=index$inTermOf)
ibor <- index$term
val <- floatingWithRebuiltCurveEngine(bond, gearings, spreads, caps, floors, indexparams,
c(ibor$table$date), ibor$table$zeroRates,
c(curve$table$date), curve$table$zeroRates,
dateparams)
class(val) <- c("FloatingRateBond", "Bond")
val
}
ConvertibleZeroCouponBond <- function(bondparams, process, dateparams){
UseMethod("ConvertibleZeroCouponBond")
}
ConvertibleZeroCouponBond.default <- function(bondparams,
process,
dateparams=list(
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
dayCounter='Thirty360',
period='Semiannual',
businessDayConvention='Following'
)
) {
val <- 0
if (is.null(bondparams$exercise)) bondparams$exercise <- 'am'
if (is.null(bondparams$faceAmount)) bondparams$faceAmount <- 100
if (is.null(bondparams$redemption)) bondparams$redemption <- 100
if (is.null(bondparams$divSch)) {
bondparams$divSch <- data.frame(Type=character(0), Amount=numeric(0),
Rate <- numeric(0), Date = as.Date(character(0)))
}
if (is.null(bondparams$callSch)){
bondparams$callSch <- data.frame(Price=numeric(0), Type=character(0),
Date <- as.Date(character(0)))
}
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$dayCounter)) dateparams$dayCounter <- 'Thirty360'
if (is.null(dateparams$period)) dateparams$period <- 'Semiannual'
dateparams <- matchParams(dateparams)
callabilitySchedule <- bondparams$callSch
dividendSchedule <- bondparams$divSch
dividendYield <- process$divYield
riskFreeRate <- process$rff
val <- convertibleZeroBondEngine(bondparams, process,
c(dividendYield$table$date),
dividendYield$table$zeroRates,
c(riskFreeRate$table$date),
riskFreeRate$table$zeroRates,
dividendSchedule, callabilitySchedule, dateparams)
class(val) <- c("ConvertibleZeroCouponBond", "Bond")
val
}
ConvertibleFixedCouponBond <- function(bondparams, coupon, process, dateparams){
UseMethod("ConvertibleFixedCouponBond")
}
ConvertibleFixedCouponBond.default <- function(bondparams,
coupon,
process,
dateparams=list(
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
dayCounter='Thirty360',
period='Semiannual',
businessDayConvention='Following'
)
){
val <- 0
if (is.null(bondparams$exercise)) bondparams$exercise <- 'am'
if (is.null(bondparams$faceAmount)) bondparams$faceAmount <- 100
if (is.null(bondparams$redemption)) bondparams$redemption <- 100
if (is.null(bondparams$divSch)) {
bondparams$divSch <- data.frame(Type=character(0), Amount=numeric(0),
Rate = numeric(0), Date = as.Date(character(0)))
}
if (is.null(bondparams$callSch)) {
bondparams$callSch <- data.frame(Price=numeric(0), Type=character(0),
Date=as.Date(character(0)))
}
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$dayCounter)) dateparams$dayCounter <- 'Thirty360'
if (is.null(dateparams$period)) dateparams$period <- 'Semiannual'
dateparams <- matchParams(dateparams)
callabilitySchedule <- bondparams$callSch
dividendSchedule <- bondparams$divSch
dividendYield <- process$divYield
riskFreeRate <- process$rff
val <- convertibleFixedBondEngine(bondparams, coupon, process,
c(dividendYield$table$date),
dividendYield$table$zeroRates,
c(riskFreeRate$table$date),
riskFreeRate$table$zeroRates,
dividendSchedule, callabilitySchedule, dateparams)
class(val) <- c("ConvertibleFixedCouponBond", "Bond")
val
}
ConvertibleFloatingCouponBond <- function(bondparams, iborindex,spread, process, dateparams){
UseMethod("ConvertibleFloatingCouponBond")
}
ConvertibleFloatingCouponBond.default <- function(bondparams,
iborindex,
spread,
process,
dateparams=list(
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
dayCounter='Thirty360',
period='Semiannual',
businessDayConvention='Following'
)){
val <- 0
if (is.null(bondparams$exercise)) bondparams$exercise <- 'am'
if (is.null(bondparams$faceAmount)) bondparams$faceAmount <- 100
if (is.null(bondparams$redemption)) bondparams$redemption <- 100
if (is.null(bondparams$divSch)) {
bondparams$divSch <- data.frame(Type=character(0), Amount=numeric(0),
Rate = numeric(0), Date = as.Date(character(0)))
}
if (is.null(bondparams$callSch)) {
bondparams$callSch <- data.frame(Price=numeric(0), Type=character(0),
Date=as.Date(character(0)))
}
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$dayCounter)) dateparams$dayCounter <- 'Thirty360'
if (is.null(dateparams$period)) dateparams$period <- 'Semiannual'
dateparams <- matchParams(dateparams)
callabilitySchedule <- bondparams$callSch
dividendSchedule <- bondparams$divSch
dividendYield <- process$divYield
riskFreeRate <- process$rff
indexparams <- list(type=iborindex$type, length=iborindex$length,
inTermOf=iborindex$inTermOf)
ibor <- iborindex$term
val <- convertibleFloatingBondEngine(bondparams, process,
c(dividendYield$table$date),
dividendYield$table$zeroRates,
c(riskFreeRate$table$date),
riskFreeRate$table$zeroRates,
c(ibor$table$date),
ibor$table$zeroRates,
indexparams,spread,
dividendSchedule, callabilitySchedule,
dateparams)
class(val) <- c("ConvertibleFloatingCouponBond", "Bond")
val
}
CallableBond <- function(bondparams, hullWhite, coupon, dateparams){
UseMethod("CallableBond")
}
CallableBond.default <- function(bondparams, hullWhite,
coupon,
dateparams=list(
settlementDays=1,
calendar='UnitedStates/GovernmentBond',
dayCounter='Thirty360',
period='Semiannual',
businessDayConvention='Following',
terminationDateConvention='Following'
)){
val <- 0
if (is.null(bondparams$faceAmount)) bondparams$faceAmount <- 100
if (is.null(bondparams$redemption)) bondparams$redemption <- 100
if (is.null(bondparams$callSch)) {
bondparams$callSch <- data.frame(Price=numeric(0), Type=character(0),
Date=as.Date(character(0)))
}
if (is.null(dateparams$settlementDays)) dateparams$settlementDays <- 1
if (is.null(dateparams$calendar)) dateparams$calendar <- 'UnitedStates/GovernmentBond'
if (is.null(dateparams$businessDayConvention)) dateparams$businessDayConvention <- 'Following'
if (is.null(dateparams$terminationDateConvention)) dateparams$terminationDateConvention <- 'Following'
if (is.null(dateparams$dayCounter)) dateparams$dayCounter <- 'Thirty360'
if (is.null(dateparams$period)) dateparams$period <- 'Semiannual'
dateparams <- matchParams(dateparams)
callSch <- bondparams$callSch
# hw.termStructure <- hullWhite$term
val <- callableBondEngine(bondparams, hullWhite,coupon,
## c(hw.termStructure$table$date),
## hw.termStructure$table$zeroRates,
callSch, dateparams)
class(val) <- c("CallableBond", "Bond")
val
}
FittedBondCurve <- function(curveparams,
lengths,
coupons,
marketQuotes,
dateparams){
UseMethod("FittedBondCurve")
}
FittedBondCurve.default <- function(curveparams,
lengths,
coupons,
marketQuotes,
dateparams){
val <- 0
dateparams <- matchParams(dateparams)
val <- fittedBondCurveEngine(curveparams, lengths, coupons, marketQuotes, dateparams)
class(val) <- c("DiscountCurve")
val
}
#CMSBond <- function(bondparams, swapIndex, cap, floor, gearings, spreads
# pricer, iborIndex){
# UseMethod("CMSBond")
#}
#CMSBond.default <- function(bondparams, iborIndex, swapIndex, cap, floor, gearings,
# spreads, pricer){
# val <- 0
# swaptionVol <- pricer$swaptionVol
# atmOptionTenors <- swaptionVol$atmOptionTenors
# atmSwapTenors <- swaptionVol$atmSwapTenors
# volMatrix <- swaptionVol$volatilityMatrix
# swapIndex <- matchParams(swapIndex)
# ibor <- iborIndex$term
# val <- .Call("CMSBond", bondparams, iborIndex, swapIndex, cap, floor, gearings, spreads,
# swaptionVol, atmOptionTenors, atmSwapTenors, volMatrix, pricer
# ibor$table$dates, ibor$table$zeroRates)
#}
# matching functions
matchDayCounter <- function(daycounter = c("Actual360", "ActualFixed", "ActualActual",
"Business252", "OneDayCounter", "SimpleDayCounter", "Thirty360", "Actual365NoLeap",
"ActualActual.ISMA", "ActualActual.Bond", "ActualActual.ISDA", "ActualActual.Historical", "ActualActual.AFB", "ActualActual.Euro"))
{
if (!is.numeric(daycounter)) {
daycounter <- match.arg(daycounter)
daycounter <- switch(daycounter,
Actual360 = 0,
ActualFixed = 1,
ActualActual = 2,
Business252 = 3,
OneDayCounter = 4,
SimpleDayCounter = 5,
Thirty360 = 6,
Actual365NoLeap = 7,
ActualActual.ISMA = 8,
ActualActual.Bond = 9,
ActualActual.ISDA = 10,
ActualActual.Historical = 11,
ActualActual.AFB = 12,
ActualActual.Euro = 13)
}
daycounter
}
matchBDC <- function(bdc = c("Following", "ModifiedFollowing",
"Preceding", "ModifiedPreceding",
"Unadjusted", "HalfMonthModifiedFollowing", "Nearest")) {
if (!is.numeric(bdc)){
bdc <- match.arg(bdc)
bdc <- switch(bdc,
Following = 0,
ModifiedFollowing = 1,
Preceding = 2,
ModifiedPreceding = 3,
Unadjusted = 4,
HalfMonthModifiedFollowing = 5,
Nearest = 6)
}
bdc
}
matchCompounding <- function(cp = c("Simple", "Compounded",
"Continuous", "SimpleThenCompounded")) {
if (!is.numeric(cp)){
cp <- match.arg(cp)
cp <- switch(cp,
Simple = 0,
Compounded = 1,
Continuous = 2,
SimpleThenCompounded = 3)
}
cp
}
matchFrequency <- function(freq = c("NoFrequency","Once", "Annual",
"Semiannual", "EveryFourthMonth",
"Quarterly", "Bimonthly", "Monthly",
"EveryFourthWeek", "Biweekly",
"Weekly", "Daily")) {
if (!is.numeric(freq)){
freq <- match.arg(freq)
freq <- switch(freq,
NoFrequency = -1, Once = 0, Annual = 1,
Semiannual = 2, EveryFourthMonth = 3,
Quarterly = 4, Bimonthly = 6,
Monthly = 12, EveryFourthWeek = 13,
Biweekly = 26, Weekly = 52, Daily = 365)
}
freq
}
matchFloatFrequency <- function(freq = c( "Annual",
"Semiannual", "EveryFourthMonth",
"Quarterly", "Bimonthly", "Monthly")) {
if (!is.numeric(freq)){
freq <- match.arg(freq)
freq <- switch(freq,
Annual = 12,
Semiannual = 6, EveryFourthMonth = 4,
Quarterly = 3, Bimonthly = 2,
Monthly = 1)
}
freq
}
matchDateGen <- function(dg = c("Backward", "Forward", "Zero",
"ThirdWednesday", "Twentieth",
"TwentiethIMM", "OldCDS", "CDS")){
if (!is.numeric(dg)){
dg <- match.arg(dg)
dg <- switch(dg,
Backward = 0, Forward = 1,
Zero = 2, ThirdWednesday = 3,
Twentieth = 4, TwentiethIMM = 5, OldCDS=6, CDS=7)
}
dg
}
matchDurationType <- function(dt = c("Simple", "Macaulay", "Modified")) {
if (!is.numeric(dt)){
dt <- match.arg(dt)
dt <- switch(dt,
Simple = 0,
Macaulay = 1,
Modified = 2)
}
dt
}
matchParams <- function(params) {
if (!is.null(params$dayCounter)) {
params$dayCounter <- matchDayCounter(params$dayCounter)
}
if (!is.null(params$compounding)) {
params$compounding <- matchCompounding(params$compounding)
}
if (!is.null(params$period)) {
params$period <- matchFrequency(params$period)
}
if (!is.null(params$freq)) {
params$freq <- matchFrequency(params$freq)
}
if (!is.null(params$fixFreq)) {
params$fixFreq <- matchFrequency(params$fixFreq)
}
if (!is.null(params$floatFreq)) {
params$floatFreq <- matchFloatFrequency(params$floatFreq)
}
if (!is.null(params$businessDayConvention)) {
params$businessDayConvention <- matchBDC(params$businessDayConvention)
}
if (!is.null(params$terminationDateConvention)) {
params$terminationDateConvention <- matchBDC(params$terminationDateConvention)
}
if (!is.null(params$paymentConvention)) {
params$paymentConvention <- matchBDC(params$paymentConvention)
}
if (!is.null(params$exCouponConvention)) {
params$exCouponConvention <- matchBDC(params$exCouponConvention)
}
if (!is.null(params$dateGeneration)) {
params$dateGeneration <- matchDateGen(params$dateGeneration)
}
if (!is.null(params$fixedLegConvention)) {
params$fixedLegConvention <- matchBDC(params$fixedLegConvention)
}
if (!is.null(params$fixedLegDayCounter)) {
params$fixedLegDayCounter <- matchDayCounter(params$fixedLegDayCounter)
}
if (!is.null(params$durationType)) {
params$durationType <- matchDurationType(params$durationType)
}
params
}
# Generic methods
plot.Bond <- function(x, ...) {
warning("No plotting available for class", class(x)[1],"\n")
invisible(x)
}
print.Bond <- function(x, digits=5, ...) {
cat("Concise summary of valuation for", class(x)[1], "\n")
cat(" Net present value : ", format(x$NPV), "\n")
cat(" clean price : ", format(x$cleanPrice, digits=digits), "\n")
cat(" dirty price : ", format(x$dirtyPrice, digits=digits), "\n")
cat(" accrued coupon : ", format(x$accruedCoupon, digits=digits), "\n")
cat(" yield : ", format(x$yield, digits=digits), "\n")
cat(" cash flows : \n")
print(x$cashFlow, row.names=FALSE, digits=digits)
#print(round(unlist(x[1:5]), digits))
invisible(x)
}
print.FixedRateBond <- function(x, digits=5, ...) {
cat("Concise summary of valuation for", class(x)[1], "\n")
cat(" Net present value : ", format(x$NPV), "\n")
cat(" clean price : ", format(x$cleanPrice, digits=digits), "\n")
cat(" dirty price : ", format(x$dirtyPrice, digits=digits), "\n")
cat(" accrued coupon : ", format(x$accruedCoupon, digits=digits), "\n")
cat(" yield : ", format(x$yield, digits=digits), "\n")
cat(" duration : ", format(x$duration, digits=digits), "\n")
cat(" settlement date : ", format(x$settlementDate, format="%Y-%m-%d"), "\n")
cat(" cash flows : \n")
print(x$cashFlow, row.names=FALSE, digits=digits)
#print(round(unlist(x[1:5]), digits))
invisible(x)
}
summary.Bond <- function(object, digits=5, ...) {
cat("Detailed summary of valuation for", class(object)[1], "\n")
print(round(unlist(object[1:5]), digits))
cat("with parameters\n")
print(unlist(object[["parameters"]]))
invisible(object)
}
RQuantLib/R/calendars.R 0000644 0001762 0000144 00000017273 14140644011 014400 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2021 Dirk Eddelbuettel
## Copyright (C) 2010 Dirk Eddelbuettel and Khanh Nguyen
##
## This file is part of the RQuantLib library for GNU R.
## It is made available under the terms of the GNU General Public
## License, version 2, or at your option, any later version,
## incorporated herein by reference.
##
## This program 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 this program; if not, write to the Free
## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
## MA 02111-1307, USA
calendars <- c("TARGET",
"UnitedStates",
"UnitedStates/LiborImpact",
"UnitedStates/NYSE",
"UnitedStates/GovernmentBond",
"UnitedStates/NERC",
"UnitedStates/FederalReserve",
"Argentina",
"Australia",
"Austria",
"Austria/Exchange",
"Bespoke",
"Botswana",
"Brazil",
"Brazil/Exchange",
"Canada",
"Canada/TSX",
"Chile",
"China",
"China/IB",
"CzechRepublic",
"Denmark",
"Finland",
"France",
"France/Exchange",
"Germany",
"Germany/FrankfurtStockExchange",
"Germany/Xetra",
"Germany/Eurex",
"Germany/Euwax",
"HongKong",
"Hungary",
"Iceland",
"India",
"Indonesia",
"Israel",
"Italy",
"Italy/Exchange",
"Japan",
"Mexico",
"NewZealand",
"Norway",
"Null",
"Poland",
"Romania",
"Russia",
"SaudiArabia",
"Singapore",
"Slovakia",
"SouthAfrica",
"SouthKorea",
"SouthKorea/KRX",
"Sweden",
"Switzerland",
"Taiwan",
"Thailand",
"Turkey",
"Ukraine",
"UnitedKingdom",
"UnitedKingdom/Exchange",
"UnitedKingdom/Metals",
"WeekendsOnly")
## isBusinessDay <- function(calendar="TARGET", dates=Sys.Date()) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("isBusinessDay", calendar, dates, PACKAGE="RQuantLib")
## val <- as.logical(val)
## names(val) <- dates
## val
## }
businessDay <- function(calendar="TARGET", dates=Sys.Date()) { ## may get deprecated one day
isBusinessDay(calendar, dates)
}
## isHoliday <- function(calendar="TARGET", dates=Sys.Date()) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("isHoliday", calendar, dates, PACKAGE="RQuantLib")
## val <- as.logical(val)
## names(val) <- dates
## val
## }
## isWeekend <- function(calendar="TARGET", dates=Sys.Date()) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("isWeekend", calendar, dates, PACKAGE="RQuantLib")
## val <- as.logical(val)
## names(val) <- dates
## val
## }
## isEndOfMonth <- function(calendar="TARGET", dates=Sys.Date()) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("isEndOfMonth", calendar, dates, PACKAGE="RQuantLib")
## val <- as.logical(val)
## names(val) <- dates
## val
## }
## getEndOfMonth <- function(calendar="TARGET", dates=Sys.Date()) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("endOfMonth", calendar, dates, PACKAGE="RQuantLib")
## names(val) <- dates
## val
## }
endOfMonth <- function(calendar="TARGET", dates=Sys.Date()) {
getEndOfMonth(calendar, dates)
}
## adjust <- function(calendar="TARGET", dates=Sys.Date(), bdc = 0 ) {
## stopifnot(is.character(calendar))
## stopifnot(class(dates)=="Date")
## val <- .Call("adjust", calendar, as.double(bdc), dates, PACKAGE="RQuantLib")
## names(val) <- dates
## val
## }
advance <- function(calendar="TARGET", dates=Sys.Date(),
n, timeUnit, # call 1
period, # call 2
bdc = 0, emr = 0) {
stopifnot(is.character(calendar))
stopifnot(class(dates)=="Date")
call1 <- missing(period) && !missing(n) && !missing(timeUnit)
call2 <- !missing(period) && missing(n) && missing(timeUnit)
stopifnot(call1 | call2)
val <- NULL
if (call1) {
## val <- .Call("advance1",
## calendar,
## list(amount = as.double(n),
## unit = as.double(timeUnit),
## bdc = as.double(bdc),
## emr = as.double(emr)),
## dates,
## PACKAGE="RQuantLib")
val <- advance1(calendar, n, timeUnit, bdc, emr, dates)
}
if (call2) {
## val <- .Call("advance2",
## calendar,
## list(period = as.double(period),
## bdc = as.double(bdc),
## emr = as.double(emr)),
## dates,
## PACKAGE="RQuantLib")
val <- advance2(calendar, period, bdc, emr, dates)
}
stopifnot( !is.null(val) )
val
}
## businessDaysBetween <- function(calendar="TARGET",
## from=Sys.Date(),
## to = Sys.Date() + 5,
## includeFirst = 1,
## includeLast = 0
## ) {
## stopifnot(is.character(calendar))
## stopifnot(class(from)=="Date")
## stopifnot(class(to)=="Date")
## val <- .Call("businessDaysBetween",
## calendar,
## list(includeFirst = as.double(includeFirst),
## includeLast = as.double(includeLast)),
## from, to,
## PACKAGE="RQuantLib")
## val <- val
## val
## }
## getHolidayList <- function(calendar="TARGET",
## from=Sys.Date(),
## to=Sys.Date() + 5,
## includeWeekends=0) {
## stopifnot(is.character(calendar))
## stopifnot(class(from)=="Date")
## stopifnot(class(to)=="Date")
## val <- .Call("holidayList",
## calendar,
## list(includeWeekends=as.double(includeWeekends), from=from, to=to),
## PACKAGE="RQuantLib")
## val
## }
holidayList <- function(calendar="TARGET", from=Sys.Date(), to=Sys.Date() + 5, includeWeekends=FALSE) {
getHolidayList(calendar, from, to, includeWeekends)
}
businessDayList <- function(calendar="TARGET", from=Sys.Date(), to=Sys.Date() + 5) {
getBusinessDayList(calendar, from, to)
}
#setCalendarContext <- function(calendar="TARGET",
# fixingDays = 2,
# settleDate = Sys.Date() + 2) {
# val <- .Call("setContext",
# list(calendar = calendar,
# fixingDays = fixingDays,
# settleDate = settleDate),
# PACKAGE="RQuantLib")
#}
RQuantLib/R/schedule.R 0000644 0001762 0000144 00000003207 12427163453 014244 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2014 Michele Salvadore and 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 .
Schedule <- function(params){
UseMethod("Schedule")
}
Schedule.default <- function(params) {
val <- 0
# check schedule params
if (is.null(params$effectiveDate)){
stop("schedule effective date undefined.")
}
if (is.null(params$maturityDate)){
stop("schedule maturity date undefined.")
}
if (is.null(params$period)) params$period <- 'Semiannual'
if (is.null(params$calendar)) params$calendar <- 'TARGET'
if (is.null(params$businessDayConvention)) params$businessDayConvention <- 'Following'
if (is.null(params$terminationDateConvention)) params$terminationDateConvention <- 'Following'
if (is.null(params$dateGeneration)) params$dateGeneration <- 'Backward'
if (is.null(params$endOfMonth)) params$endOfMonth <- 0
params <- matchParams(params)
CreateSchedule(params)
}
RQuantLib/R/asian.R 0000644 0001762 0000144 00000003736 14573064151 013551 0 ustar ligges users
## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2014 Dirk Eddelbuettel
## Copyright (C) 2009 Khanh Nguyen
##
## 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 .
AsianOption <- function(averageType, type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
first, length, fixings) {
UseMethod("AsianOption")
}
AsianOption.default <- function(averageType, type, underlying, strike, dividendYield,
riskFreeRate, maturity, volatility,
first=0, length=11.0/12.0, fixings=26) {
averageType <- match.arg(averageType, c("geometric", "arithmetic"))
type <- match.arg(type, c("call", "put"))
if (missing(maturity)) {
if (averageType=="geometric") {
warning("Geometric Asian Option requires maturity argument")
return(NULL)
} else {
maturity <- 1.0 # actually unused for arithmetic option case
}
}
val <- asianOptionEngine(averageType, type, underlying,
strike, dividendYield, riskFreeRate,
maturity, volatility,
first, length, fixings)
class(val) <- c("AsianOption","Option")
val
}
RQuantLib/R/datasets.R 0000644 0001762 0000144 00000001026 12750761663 014263 0 ustar ligges users #' Vol Cube Example Data
#'
#' Data for valuing swaption examples including rates and a lognormal vol cube
#'
#' @name vcube
#' @docType data
#' @usage data(vcube)
#' @format two data frames: \code{vcube}, a data frame with four columns: \code{Expiry}, \code{Tenor},
#' \code{LogNormalVol}, and \code{Spread}
#' @source TBA
NULL
#' Vol Cube Example Data
#'
#' Short time series examples
#'
#' @name tsQuotes
#' @docType data
#' @format A series of tenors and rates approppriate for calling DiscountCurve
#' @source TBA
NULL
RQuantLib/R/discount.R 0000644 0001762 0000144 00000010457 12714226467 014311 0 ustar ligges users ## RQuantLib function DiscountCurve
##
## Copyright (C) 2005 Dominick Samperi
## Copyright (C) 2007 - 2016 Dirk Eddelbuettel
## Copyright (C) 2009 - 2010 Dirk Eddelbuettel and Khanh Nguyen
##
## 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 .
DiscountCurve <- function(params, tsQuotes, times=seq(0,10,.1),
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")) {
UseMethod("DiscountCurve")
}
DiscountCurve.default <- function(params, tsQuotes, times=seq(0,10,.1),
legparams=list(dayCounter="Thirty360",
fixFreq="Annual",
floatFreq="Semiannual")) {
## Check that params is properly formatted.
if (!is.list(params) || length(params) == 0) {
stop("The params parameter must be a non-empty list", call.=FALSE)
}
## Check that the term structure quotes are properly formatted.
if (!is.list(tsQuotes) || length(tsQuotes) == 0) {
stop("Term structure quotes must be a non-empty list", call.=FALSE)
}
if (length(tsQuotes) != length(names(tsQuotes))) {
stop("Term structure quotes must include labels", call.=FALSE)
}
if (!is.numeric(unlist(tsQuotes))) {
stop("Term structure quotes must have numeric values", call.=FALSE)
}
## Check the times vector
if (!is.numeric(times) || length(times) == 0) {
stop("The times parameter must be a non-emptry numeric vector", call.=FALSE)
}
## Finally ready to make the call...
##val <- .Call("DiscountCurve", params, tsQuotes, times, PACKAGE="RQuantLib")
matchlegs<-matchParams(legparams)
##val <- discountCurveEngine(params, tsQuotes, times,matchCpnmonthFreq=as.integer(monthFreq))
val <- discountCurveEngine(params, tsQuotes, times,matchlegs)
val[["table"]] <- as.data.frame(val[["table"]]) ## Windows all of a sudden needs this
class(val) <- c("DiscountCurve")
val
}
plot.DiscountCurve <- function(x, setpar=TRUE, dolegend=TRUE,...) {
if (setpar) {
savepar <- par(mfrow=c(3,1))
}
if (x$flatQuotes) {
## Don't want to plot noise when we look at a flat yield curve
plot(c(x$times[1],x$times[length(x$times)]), c(0,.5),type='n',
main='forwards', xlab='time',ylab='forward rate')
lines(x$times, x$forwards, type='l')
if (dolegend) {
legend('center','center','flat',bty='n',text.col='red')
}
plot(c(x$times[1],x$times[length(x$times)]), c(0,.5),type='n',
main='zero rates', xlab='time',ylab='zero rate')
lines(x$times, x$zerorates, type='l')
if (dolegend) {
legend('center','center','flat',bty='n',text.col='red')
}
} else {
plot(x$times, x$forwards, type='l', main='forwards',xlab='time',ylab='fwd rate')
if (dolegend) {
legend('center','center',paste(x$params$interpHow, 'discount'), bty='n', text.col='red')
}
plot(x$times, x$zerorates, type='l', main='zero rates',xlab='time',ylab='zero rate')
if (dolegend) {
legend('center','center',paste(x$params$interpHow, 'discount'),bty='n', text.col='red')
}
}
plot(x$times, x$discounts, type='l', main='discounts',xlab='time',ylab='discount')
if (dolegend) {
if (x$flatQuotes) {
legend('center','center','flat',bty='n',text.col='red')
} else {
legend('center','center',paste(x$params$interpHow, 'discount'),bty='n', text.col='red')
}
}
if (setpar) {
par(savepar)
}
}
RQuantLib/R/bermudan.R 0000644 0001762 0000144 00000016616 14234647573 014265 0 ustar ligges users ## RQuantLib function BermudanSwaption
##
## Copyright (C) 2005 Dominick Samperi
## Copyright (C) 2007 - 2014 Dirk Eddelbuettel
## Copyright (C) 2016 Terry Leitch
##
## 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 .
BermudanSwaption <- function(params, ts, swaptionMaturities,
swapTenors, volMatrix) {
UseMethod("BermudanSwaption")
}
BermudanSwaption.default <- function(params, ts, swaptionMaturities,
swapTenors, volMatrix) {
# Check that params list names
if (!is.list(params) || length(params) == 0) {
stop("The params parameter must be a non-empty list", call.=FALSE)
}
if(is.null(params$startDate)){
params$startDate=advance("UnitedStates",params$tradeDate, 1, 3)
warning("swaption start date not set, defaulting to 1 year from trade date using US calendar")
}
if(is.null(params$maturity)){
params$maturity=advance("UnitedStates",params$startDate, 5, 3)
warning("swaption maturity not set, defaulting to 5 years from startDate using US calendar")
}
matYears=as.numeric(params$maturity-params$tradeDate)/365
expYears=as.numeric(params$startDate-params$tradeDate)/365
increment=min(matYears/6,1.0)
numObs=floor(matYears/increment)+1
optStart=as.numeric(params$startDate-params$tradeDate)/365
# find closest option to our target to ensure it is in calibration
tenor=expiry=vol=vector(length=numObs,mode="numeric")
expiryIDX=findInterval(expYears,swaptionMaturities)
tenorIDX=findInterval(matYears-expYears,swapTenors)
if(tenorIDX >0 & expiryIDX>0){
vol[1]=volMatrix[expiryIDX,tenorIDX]
expiry[1]=swaptionMaturities[expiryIDX]
tenor[1]=swapTenors[tenorIDX]
} else {
vol[1]=expiry[1]=tenor[1]=0
}
for(i in 2:numObs){
expiryIDX=findInterval(i*increment,swaptionMaturities)
tenorIDX=findInterval(matYears-(i-1)*increment,swapTenors)
if(tenorIDX >0 & expiryIDX>0){
vol[i]=volMatrix[expiryIDX,tenorIDX]
expiry[i]=swaptionMaturities[expiryIDX]
tenor[i]=swapTenors[tenorIDX]
} else {
vol[i]=volMatrix[expiryIDX,tenorIDX+1]
expiry[i]=swaptionMaturities[expiryIDX]
tenor[i]=swapTenors[tenorIDX+1]
}
}
# remove if search was out of bounds
expiry=expiry[expiry>0];tenor=tenor[tenor>0];vol=vol[vol>0]
if(length(expiry)<5){
warning("Insufficent vols to fit affine model")
return(NULL)
}
#Take 1st 5 which includes closest to initial date
expiry=expiry[1:5];tenor=tenor[1:5];vol=vol[1:5]
#
# Check that the term structure quotes are properly formatted.
# if(is)
# if (!is.list(ts) || length(ts) == 0) {
# stop("Term structure quotes must be a non-empty list", call.=FALSE)
# }
# if (length(ts) != length(names(ts))) {
# stop("Term structure quotes must include labels", call.=FALSE)
# }
# if (!is.numeric(unlist(ts))) {
# stop("Term structure quotes must have numeric values", call.=FALSE)
# }
# Check for correct matrix/vector types
if (!is.matrix(volMatrix)
|| !is.vector(swaptionMaturities)
|| !is.vector(swapTenors)) {
stop("Swaption vol must be a matrix, maturities/tenors must be vectors",
call.=FALSE)
}
# Check that matrix/vectors have compatible dimensions
if (prod(dim(volMatrix)) != length(swaptionMaturities)*length(swapTenors)) {
stop("Dimensions of swaption vol matrix not compatible with maturity/tenor vectors",
call.=FALSE)
}
# Finally ready to make the call...
# We could coerce types here and pass as.integer(round(swapTenors)),
# temp <- as.double(volMatrix), dim(temp) < dim(a) [and pass temp instead
# of volMatrix]. But this is taken care of in the C/C++ code.
if (inherits(ts, "DiscountCurve")) {
val <- bermudanWithRebuiltCurveEngine(params, c(ts$table$date), ts$table$zeroRates,
swaptionMaturities,
swapTenors, volMatrix)
} else{
if (!is.numeric(ts) | length(ts) !=1) {
stop("Flat Term structure yield must have single numeric value", call.=FALSE)
}
val <- bermudanFromYieldEngine(params, ts,
swaptionMaturities,
swapTenors, volMatrix)
}
class(val) <- c(params$method, "BermudanSwaption")
val
}
summary.G2Analytic <- function(object,...) {
cat('\n\tSummary of pricing results for Bermudan Swaption\n')
cat('\nPrice (in bp) of Bermudan swaption is ', object$price)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: G2/Jamshidian using analytic formulas')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nb = ', format(object$b,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\neta = ', format(object$eta,digits=4))
cat('\nrho = ', format(object$rho,digits=4))
cat('\n\n')
}
summary.HWAnalytic <- function(object,...) {
cat('\n\tSummary of pricing results for Bermudan Swaption\n')
cat('\nPrice (in bp) of Bermudan swaption is ', object$price)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Hull-White using analytic formulas')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
summary.HWTree <- function(object,...) {
cat('\n\tSummary of pricing results for Bermudan Swaption\n')
cat('\nPrice (in bp) of Bermudan swaption is ', object$price)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Hull-White using a tree')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
summary.BKTree <- function(object,...) {
cat('\n\tSummary of pricing results for Bermudan Swaption\n')
cat('\nPrice (in bp) of Bermudan swaption is ', object$price)
cat('\nStike is ', format(object$params$strike,digits=6))
cat(' (ATM strike is ', format(object$ATMStrike,digits=6), ')')
cat('\nModel used is: Black-Karasinski using a tree')
cat('\nCalibrated model parameters are:')
cat('\na = ', format(object$a,digits=4))
cat('\nsigma = ', format(object$sigma,digits=4))
cat('\n\n')
}
RQuantLib/R/inline.R 0000644 0001762 0000144 00000006075 12753434160 013732 0 ustar ligges users ## RQuantLib -- R interface to the QuantLib libraries
##
## Copyright (C) 2002 - 2016 Dirk Eddelbuettel
##
## This file is part of the RQuantLib library for GNU R.
## It is made available under the terms of the GNU General Public
## License, version 2, or at your option, any later version,
## incorporated herein by reference.
##
## This program 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 Rcpp. If not, see .
.pkgglobalenv <- new.env(parent=emptyenv())
.onLoad <- function(libname, pkgname) {
## default to NULL
qlcflags <- qllibs <- NULL
if (.Platform$OS.type=="windows") {
if (Sys.getenv("QUANTLIB_ROOT") != "") {
## by convention with CRAN, on Windows we expect these two
## variables to be set, and to be pointing to the respective
## helper installations
qlroot <- Sys.getenv("QUANTLIB_ROOT")
boostlib <- Sys.getenv("BOOSTLIB")
rarch <- Sys.getenv("R_ARCH")
qlcflags <- sprintf("-I%s -I. -I\"%s\"", qlroot, boostlib)
qllibs <- sprintf("-L%s/lib%s -lQuantLib", qlroot, rarch)
}
} else {
## on Linux and OS X, see if we have quantlib-config which may well be
## false in the case of prebuild binary packages as eg r-cran-rquantlib
## on Debian / Ubuntu as well as the OS X package from CRAN
## first we check whether we have quantlib-config in the path
if (isTRUE(unname(Sys.which("quantlib-config")) != "")) {
qc <- system("bash -c 'type -p quantlib-config'", ignore.stderr=TRUE, intern=TRUE)
if (is.character(qc) && nchar(qc) > 1) {
qlcflags <- system(paste(qc, "--cflags"), intern = TRUE)
qllibs <- system(paste(qc, "--libs"), intern = TRUE)
}
}
}
assign("ql_cflags", qlcflags, envir=.pkgglobalenv)
assign("ql_libs", qllibs, envir=.pkgglobalenv)
}
LdFlags <- function(print = TRUE) {
if (is.null(.pkgglobalenv$ql_libs)) stop("Cannot supply LdFlags as none set.")
if (print) cat(.pkgglobalenv$ql_libs) else .pkgglobalenv$ql_libs
}
CFlags <- function(print = TRUE) {
if (is.null(.pkgglobalenv$ql_cflags)) stop("Cannot supply CFlags as none set.")
if (print) cat(.pkgglobalenv$ql_cflags) else .pkgglobalenv$ql_cflags
}
inlineCxxPlugin <- function(...) {
plugin <- Rcpp.plugin.maker(include.before = "#include ",
libs = sprintf("%s $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)", LdFlags(FALSE)),
package = "RQuantLib",
Makevars = NULL,
Makevars.win = NULL)
settings <- plugin()
settings$env$PKG_CPPFLAGS <- paste("-DRQuantLib_Plugin", CFlags(FALSE))
settings
}
RQuantLib/R/mod.R 0000644 0001762 0000144 00000000075 12271333436 013224 0 ustar ligges users
#loadModule("BondsMod", TRUE)
#loadModule("BlackMod", TRUE)
RQuantLib/cleanup 0000755 0001762 0000144 00000000503 15211270414 013463 0 ustar ligges users #!/bin/sh
Rscript -e 'library(Rcpp); compileAttributes(".")'
rm -rf config.log config.status confdefs.h autom4te.cache \
src/Makevars src/libRQuantLib.a src/libRQuantLib.def src/*.o src/*.so src/symbols.rds \
RcppSrc/*.a RcppSrc/*.o RcppSrc/config.* inst/Rcpp-version.txt
find . -name \*~ | xargs rm -f
exit 0
RQuantLib/demo/ 0000755 0001762 0000144 00000000000 14356056760 013053 5 ustar ligges users RQuantLib/demo/00Index 0000644 0001762 0000144 00000000172 12466654326 014207 0 ustar ligges users OptionSurfaces European Option surfaces (requires rgl)
ShinyDiscountCurves Shiny application with Discount Curve example
RQuantLib/demo/ShinyDiscountCurves.R 0000644 0001762 0000144 00000000462 12466654326 017175 0 ustar ligges users
## use shiny, if installed to show Shiny App installed with package
if (require("shiny")) {
library(RQuantLib)
runApp(system.file("shiny", "DiscountCurve", package="RQuantLib"),
port=8765
## add host="0.0.0.0" if access from outside current machine needed
)
}
RQuantLib/demo/OptionSurfaces.R 0000644 0001762 0000144 00000004757 14356056760 016157 0 ustar ligges users
## RQuantLib Demo for (European) Option surfaces
## Dirk Eddelbuettel, September 2005
## $Id: OptionSurfaces.R,v 1.1 2005/10/12 03:42:45 edd Exp $
OptionSurface <- function(EOres, label, fov=60) {
#
# This can be removed when rgl 0.111.5 is released:
if (packageVersion("rgl") < "0.111.5")
surface3d <- rgl.surface
# End of old workaround
axis.col <- "black"
text.col <- axis.col
ylab <- label
xlab <- "Underlying"
zlab <- "Volatility"
y <- EOres
## clear scene:
clear3d()
clear3d(type="bbox")
clear3d(type="lights")
## setup env:
## bg3d(color="#887777")
bg3d(color="#DDDDDD")
light3d()
view3d(fov=fov)
##bg3d(col="white", fogtype="exp2")
##bg3d(col="black", fogtype="exp2")
##bg3d(col="black", fogtype="exp")
##bg3d(col="white", fogtype="exp")
x <- (1:nrow(y))
z <- (1:ncol(y))
x <- (x-min(x))/(max(x)-min(x))
y <- (y-min(y))/(max(y)-min(y))
z <- (z-min(z))/(max(z)-min(z))
surface3d(x = x, y = y, z = z, alpha=0.6, lit=TRUE, color="blue")
lines3d(c(0,1), c(0,0), c(0,0), col=axis.col)
lines3d(c(0,0), c(0,1), c(0,0), col=axis.col)
lines3d(c(0,0),c(0,0), c(0,1), col=axis.col)
text3d(1,0,0, xlab, adj=1, col=text.col)
text3d(0,1,0, ylab, adj=1, col=text.col)
text3d(0,0,1, zlab, adj=1, col=text.col)
## add grid (credit's to John Fox scatter3d)
xgridind <- round(seq(1, nrow(y), length=25))
zgridind <- round(seq(1, ncol(y), length=25))
surface3d(x = x[xgridind], y = y[xgridind,zgridind], z = z[zgridind],
color="darkgray", alpha=0.5, lit=TRUE,
front="lines", back="lines")
## animate (credit to view3d() example)
start <- proc.time()[3]
while ((i <- 36*(proc.time()[3]-start)) < 360) {
view3d(i,i/8);
}
}
RQuantLib.demo.OptionSurfaces <- function() {
und.seq <- seq(10, 200, by = 2.5)
vol.seq <- seq(0.05, 2, by = 0.025)
cat("Calculating surface ...")
EOarr <- EuropeanOptionArrays("call", underlying = und.seq, strike = 100,
dividendYield = 0.01, riskFreeRate = 0.03,
maturity = 1, volatility = vol.seq)
cat(" done.\n")
open3d()
OptionSurface(EOarr$value, "Value")
OptionSurface(EOarr$delta, "Delta")
OptionSurface(EOarr$gamma, "Gamma")
OptionSurface(EOarr$vega, "Vega")
OptionSurface(EOarr$theta, "Theta")
}
require(rgl,quiet=TRUE)
require(RQuantLib,quiet=TRUE)
RQuantLib.demo.OptionSurfaces()
RQuantLib/data/ 0000755 0001762 0000144 00000000000 13376525200 013027 5 ustar ligges users RQuantLib/data/vcube.RData 0000644 0001762 0000144 00000013600 15211270414 015042 0 ustar ligges users ‹ í\”UÚf’QÌ(b@ ˆ.bA ²‚¨;À º£(*+"‹Y,¢®b^Öœ³®¢.¤®®ª®Î]Õa"iAEaß{}«æ_øýÏÙÙŸsDzÎyLOO׫îw¿ûÝWÃèó®è×îŠvyyyùy-[‹ÄË–ùâŸy-óÚŠïnš<{RQ^^Áò7â{GñÔþó–¿ZA3ZËf´V»¡µnFkÓŒ¶O3ZÛf´vÍhí›Ñ:4£ulFËa<‡ñƽß1‹‘ÿ>Fr1´çÄP.ryâ·Žñ\žøuÆH.†öœÊÅ@.Oä0žÃxãÿn¶..º©¨x¦xÕIý6ûnAß>ãù2¿ïï•÷^?ïUï·ý½÷Nõ^
ð^
ô>7Ð{ï4ïÕ ïÕéãwvp'ÎtÇçzjáäY%¥âÕöÿÒÓ͵\Û“ÚîÈ5¹–k¿¦¶;jä\˵½©íO(×rí×ÔvGíšk¹¶7µæx5¹–k{RkŽ·˜k¹¶5i™æïÈ˺¤mòvqqú6Y±ž[ЯϮŽnAÿ>ÿÓ¾U=¸=ÿ¯þkžò_wìØ1H´ëE{J´¢UŠV“—ýê*Z?ц‹6E´ÇDûæ—®mh¢mmûùJzëû‰Öù?í³9ãØÛÆž»&‡“ßúØs×ìÙ8Ù›ûÜÛöú×<ßܺþ¶Çž»fÏÆÉÞÜç޶׿æùæÖõ·=öÜ59œüÖÇž»æÿ¾F´}¥ŠêZ}Òâ…Hè_8äR„´‘gTø¬w¶=}â6˜K®;ïÚA0n9+4oÒûÐÏ~uàû=¿üÔ·@›ZuΦ,ø><öù§n~¾“Ï\¶öo£Ò¬z¥bÙŸPñã¹Û'>¢ÍÛ(‡Òæy|?zìï_™ò%êO¿¢Ó¤:Ò+{ÜñôÅ£aÛ³·üÜm¢“Fø_þ ‘Eߎ¸¾Ë‘û2¿?çÞÓ>¡{û9"ôç7/íø§ulsM‰Áw–Ô9o݇ ¯÷Fuß%ï:òLX™ÕGtN}Šààm·?¼c)BsêZ‰ÈÕO'Ÿ…øEµË¨þìǯi½åÏxã\Ÿý™6ß¿ª|
’³» Ý_/}Oå
ƒ·ÍCü°}žÌŸ}"e>qÕ«e<Á·6Ý&–ÖûuûýPz!,ÙËÌ;:aýä£îƒ¹£·¸ã‘CZúhU§²QŸ§½ðI¤ù鲋ºl„Ó~¿ã?>e-â
‡Ÿ{òK·"zí #þø‹·Í#¸òûÓþþü©°nº&øú«Ï Fsû#y0_˜Ñûí¯úÃX<ë“ëoÿFõ†7ŸÍÓÚKé‰Ú¿}1võÂHË]ºòwpÄ&ŠE\vÛÿ)ÄÏnÍç@L}+A¬í>|àö_’7-ò ¢üà£Uû#²´û¬1‹¾ED ááÇ>A8©Œð}>ë¸îD„ÕtÛ"ôN¯}ǵìŠÐ»¾¹ZC¸óÎ…otFdر§Þ°ÑÇ>~|UòNlV·éŽšCN=ìG gAº‰3¦L8ü5ÄÔò÷A¸ñåm5Å÷#¤àöX¯ÝØá%õÌ)>fZ[¦X¬yeÂxÿŽS§€þ´ ü?DŽPÂÆ¥^*ºDæ 3ëß{áÝ‹cK· Îý‹,™ßº{섞_OÂÚ|÷Oû-g.[“ø1‘2:ãÆÿåêõeÛºÀä¥bgÞÀºÂôÖ¢ŸïGjÕ-]Ñ~?$ä¶üAtEôŸè| Â7}ów>}ñ¨;_^«³
D¨°Y†Á}ÖÅdÏ]2ú©çD—ð÷jßÏ/B[º¥çõ5¦·¿2,^ŠjÆ]ŠóvÎR F<»ÝˆŽ“xá‡&žðÝʇ*½ðüA hüüí{ç?àý쎇݈ ñ’«q賨Qç.$9ï˜@ÓIOôEDFc‹3üèÆô€¥–ýt*>~üq¿ˆ˜3 'ï"¶:çé/Þ|T·^7CãzúÖ=2ôn¨å8â&ºDaÎ;¨èåJˆ3“÷5‘ÀŸýÄ«—‰Ð„ªú‚Æõ÷Õ¼ù~]'øÈ5ŸèÞýg8Õ÷¿v#"w)"BsÅHfºª|rã9GÔa0ãq½bç _ûìmÿðüwÈ{ÚWýÖünùÝÐzÝÜ÷¡¯[Á§Âi2ªD3}¨¿½kåñ°Õm:",Q{ÙÛJ4£5áªËÝ=ó;k“‚Ç$h
ü`ÔZhT Â÷Òé¨"¿T*ú‰´d£Ú#¶Rnì—ŠMœ½èˆkƒûîWaY ŸóU*¯eý°JÞ·‚8,WÓ´$Ö<¼mhynÍÈ(šš‡ãsy"(a0è.Xrø
¬üìý?lóÆàù0ã×½>ôË50EŠ%…)XúýJ
æSa7܆q»"~\?ƒ|o*ú?ÖÑ«&ß3a
S«åõ[^}æò¿œµjÛ* Â1e¢:‰¯[Š^‡(óUø’SÜ6ìXEVZùý Èc&×ÇP0íC¢áÊÏ¡ûÚ”^tô7Õ qQ·ÇFz&2Ï/3l‘dºÏ‹˜¢›¡ˆ)"çr„È_–
çÖ2Ôƒ¸7º«¡K¶Û§/ütÉã×´_u?pH«—··ã:Öéaêp$›—\‡¸ H!Ëå¹÷Y„óUÂòò]P†÷se.ºïF±ôÊèŸx",•ÆÏ†5W
–J7w Òewˆ‡ ód Pvx(ÌËA9ŠÖ[*Q„õÌ©u2ñ?Š,}ïƒè•ÐÊæ?ïºÀ ¬~0m7 õƒ>fke¨ËÝð“×4‰¦ñáIøœçC=÷9)oש1ÁB‚
¼<TéõdúlÊ"ɶ~ðCèò§Á'Á/Ó×ÇO@“Ýû>î·OɑިSÛt0œ7TâBTmÏñ¥ä †‘ B¬ñgHvoõ t ¿6ß4_Ê3ŸñÆï›¥U?I ÎÁv)#nYŽú·Žþê//¥’´:x1lq·u· öÒþOÙ³·",§uõ2ÉÖÉêE“¾X &ñèæ“ q^s›L¼ka‡?ünü»>DävQƒ `ùg>»æW“¸2²"þ´ÎõÐ~¾O\9ÚP•ðà{]ªW•äïêR9‘¿Â¦î
KöŸþOE0‹E€|n,WBºˆæ£6eà—éóõ× Ýð‚Õî¬á,Â5ð©áF%÷·òà/>}iÿ§‘Q4=‰{Š„2Ü!î³¥–8L9Üñ‡A>ôËÕ8îMh\'o¿‰‹*y›Ó¿@e6îPÁqdzÈ€¸Ëßršg¿Š ãÒð-Ì@gù/Þ~“Ǫˆ£Ê7þ8N¤@TŒS‰åÜg9Ù‚7?z0«ƒâ2}ô˜ÈgJ0 Ä}µbR Ô"@]gÊí»i5ê_ߌM¦§–óÝõty|çïØ*¢ÅŠ|‡æ›z6¡äÖ(Äû\Þ¯pîáˆ1.¢‡”;‚y-Ìxs]Â*íÏ@XM·›ÇOÑ“TG¼»ìN21¿§HÉ,^vß¼o¥P>•Œj:Ö™1jƒVt5iEÓ¥HIu9D¬§JCG!ÉuNª´U‡ºÄ!~ÜŽp)LC¿¸ï[ˆûU~üiê½u^ª›8H’¯ÖWÎýR€?§§JL°ešîð.lê{в‚N”J æO[-c!lâá>NBlé]Æ·‘¼ÔÀý¬a>ȰnJ¹:„¶¿–#Îþ¢EŠH<¾
R—YÌãÖ‰&ëBƒúVg|nf^«f^s¨÷Œ·Î
³Ÿ u·ÅýˆIô[sLÖ®^÷ê%ú-•|;i׫0ìÄ.”‰å"„¥j¹¨!Öžþ–ôшɼbPÿé“Þœ¿¢ñ^^ÞM“×£¾‹ãžÎ0ç:ùÂOùÈc>®C%up…ÚŽ³QN½SF½¾æS¹ð¯÷êeöŸàº»>B€õ¢[™§
ÿçò
Ë`0?¬u ›,èó¥2û:ë_]½ÝÎÓ1~ÖM:ùÎP²k,Lêù`?oT‚Ó¤ y
•öÂf=»S&ºÂrÓ3«$ÔvŸSÚ\þM0†«€†.]œ÷P-´ÙjbÐDsèÀ¾çúÕSo%U}äõˆë›QG{õœ²iÚ{uW@É€ñÜ®ˆEóí›ê»e*aÀTt`Ó¾Q?Ìæ%ÊpC€úÀRò¿'êË$a6 ɸñpÎÏYžQ &ãNß ~e#Šzšú\“a}ô×ðQ§ûX÷Õ2:ÄaDªÛƒV $鯽Kûéw¼ùxxcþñsÞ},ýuM}Ï®ƒýž"~„ýÊPDüçòŒÑ ‘ptúQ~ê'üã£ñÉôsXUô‡*é+m&þk8GuÛqê׿sëB×§4©;ß/ŸÔçrôKŒl^†¡ì»Û`Èðóªé³Ø²lœWŽý
‹þI}î^ï§Ï¨QOi¬‡,ž
Ÿ@“ à&}Lý\¡düÕȸ~ ù6Dž°èߘjFAg|ú¥ŒÝ|4Ö¥>ê‘*âºR…ë¨`¼—Óʨe¸ëÏÑÏÐ5žUtÁ®t54U&^õëW‘·Ý:¥œõU¹¸h þˆ4ã-æúŒÔE&ý$ƒ¸ñS‡yúã©¢ÿ[ɼPÁ<]N¬Œz¶~B’ù3v¯Àˆu. ‡u¼u™$Ò0¹/ý>™ŸºÉO} ©´s|Jþ÷˺ƒ¸«#Ϧ橄ƒ$ýÍ$y×!ê'[•ŸçÁ&îíó aË2탑PvÌ¡žŸc·T÷t§Cß%Iý™:Oé»ê^ÆÃúÑuÌ×%'f!M¿,M¿Îõ5RôUR²,ßò3’ªiä( £áHµz®ÐÅô¡<ÝÈ<gïêt·¢ÿ¼Ë8™GÈï5¼šù/M¤¨_S<—Iµ’…ÑgH.W„(Æ'NnhÒîr˜\ß=NŸÊÓ/ÔQô{~qß¿í º·Ñ@PMÜgx®“®U éqj㢯•¢Jþ d¼%G+Á€$õŽ“5^àпpÈ_.~ú¯É¬®óêÇVôßÝ:ÛÕ…Ö
)ÖiÏlú¹qÆk”~v„ø©í:Á³¥ >ºiþÌ_µôG2Œƒ”’]áP—Ù®.f=¥NpϽBä?‹çLô½›Î©”ü‚á1H±~u¨ëYß1æ½y4ÌûËåW…w^àûfÖ÷ßµþV9ï¡‘ç`õóÔÀÉÖÈ0O¦©«ÓœŸWÏ2ÿ'9¿$y:ÉzÊñËBo:âÄ«#ݸOPy~„õw½õ¨cþHQG;¬ŸÜúÄ=GŠPφȇAuìq,êDw)N[÷ýŽç&5.Þ\ŸÄÕáä7·îIÄ/‚*\Û À¼cÒo4ˆsxsý©FúkÞǦ£>Œ(¹0!ÖYAúÜòŠù"Fâ‡1[«<ßÚ/a|ðJhôOÖ³^IeÏ“ ïuõ/ë[÷|ÕóÇ]ÄzÊË»Êîêìõ¯õFÊfdTº€çeÑŸòò6}I?Ï|<®
ª B%ëÂ
ÖÕåôËÔ1ìXCÝ´…¾^=ë>‡þgŒ>Q~¢)?5ᮦsMª0€>3ë/éÊà÷ÖËOÞtÇçÍu²ÆóRÍVF£—/]¿9@’¨¾
ëÙoZÉÐ|$ŽQÈZYø‰¼L?ËõãMúÛçKz«zÕ«4úê÷]#®^RF5’R®-AŒç-aÖÕAÖ™Ö“F½:X€NžØÅ¿¦/ìc}î“é"Ù€Í<¯¥.v¨s½s yÌxª‹ç…îùA€õûœ©Ê‹90©/¹MïÁsRÖõÞ9ëOëÔ:yßÏ]ÿ×=¨£ïâWQ~ÎãYâД.\ïwšê6úKžÎ§oâ*aõoë»Unw„Íxˆ§A>WàÖ9îùN¾óÏP†!4êï|Žú¹JÙ4‡¡RÉ¿q¨‘²j\ 6Ÿ+z ‹829wÝÜ:XÛ¤6š²OoÒߊžB%qYÁ¼Ñ¨ì¦«PMÝf£^«°j KÑɦó3Ö5.¿¹¾´‹_:Ö(P%ª9}ÙùÔâ9’9>›tæC?ý¸öt>Ïe*Y_Uð\ÀÕáž»$8×ï | òNÎÏç=´•°lÚêJêºrÆO¹¬
[/BFº}×>‡8u†wî«¶á,
~ãá§Ï ñ9 Ï9«¾Q D%Ï›½z…çPe¾,¹y7FßÀâû¦úq,têV/˜}Äwù®‚üY.Ýœ ëQÆ}+£ÏX+g?v
—¯Èû!ƃE?Øä9‘ëÏèÌW~ê¾…Æóï<,›§vÑ“ßõ•‰d;Öó|£†þyŠº:¹JI®«ÃºÀqõë›Ï…¸øµyŽj»çÌ£ æ[û¶wá¸:Ÿ|—š¡6|—q®c]RË<“¡âó&îxlƋ뗺υDÈ×aê]>?Ó´<e½™¡¾N ˆŸÏJ,WD‡ýP¯_žÃyçÑÔQ¬µ«Ž§¿²Žzµöpu€‚4u…w^Áüš".’ÊÎ?Iú+Iò†ÃúÖḞ9Ìë6ý3›ç^¶´‘Vo€MŸÉÉâÌßÖ;·îQ˵Ìnþÿ@Œy+¢l ¡1ÉóG@–ë~„™}Ä»O½’Y}âsVñl“·<ÝÇsŒŸ; ÒW¶è[¸Ï?¸þ‰{^·…¼[Ãç^ÜºØæõq®·yÏ›…è;7Võ… ñäúi†Ü9&ô¬ŽØµ®¤Nm Ö0§ÉgIúf6óP‚þjœÏ;y~ÿçʰBLÚg÷EÐHýåÖ{6ë&ÏoÏÖK³n
ò¹"KÙ%då"LŽÇ`]íú.nž\—ZP¤Ý¸%ïŘ×Â|*¨lº6°¸?žßÎsAƒãщs?õûüPu^’¼çõúÔ!ê—wÝç$Lž;ä/]•á§N×ÈÏù¥NÑx/8j;Ú"J}–6ñЯ$o²Ós
ÌÞóIôC5úëq_6çíô_–Î(œ^43/û'ó-Ý?™?Î
וÞâ~dlÑŒ’R÷Wcn(-*œÂŸ:\RríÈ’Òé…ÅãJŠwê¹miÉͽÝÞå皇øgÇŽ¿ØéõóyA»)…³
{Ï*œT\ôoïL-ìÔùþ½¯›1«¨tFaqï™EÅSK‹¦Š7»°mgûÿ˜R¶³è]J½k RQuantLib/data/tsQuotes.RData 0000644 0001762 0000144 00000000266 15211270414 015571 0 ustar ligges users ‹ r‰0âŠàb```b`a’Ì@&`d`aàÒ%Å¥ù%©Å@Iaˆù@òöI¾—>®üç·µk3ñxî‚ó»æï+;±ÅÎï4ØÇûV£ÎŸhýH/öa,œ?ù…HÀû;sàüiA{mÌM|˜ù(îcÍKÌ9ŽA ì8ˆ sŠa.ŒYlT g#˜¦0&K±¡IÜIÜÈf`øÂ ôø`ù4 RQuantLib/src/ 0000755 0001762 0000144 00000000000 15174005166 012707 5 ustar ligges users RQuantLib/src/RcppExports.cpp 0000644 0001762 0000144 00000336703 15165305402 015714 0 ustar ligges users // Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#include "../inst/include/RQuantLib.h"
#include
#include
#include
using namespace Rcpp;
#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif
// affineWithRebuiltCurveEngine
Rcpp::List affineWithRebuiltCurveEngine(Rcpp::List rparam, Rcpp::List legparams, std::vector dateVec, std::vector zeroVec, Rcpp::NumericVector swaptionMat, Rcpp::NumericVector swapLengths, Rcpp::NumericVector swaptionVols);
RcppExport SEXP _RQuantLib_affineWithRebuiltCurveEngine(SEXP rparamSEXP, SEXP legparamsSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP swaptionMatSEXP, SEXP swapLengthsSEXP, SEXP swaptionVolsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type legparams(legparamsSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swaptionMat(swaptionMatSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swapLengths(swapLengthsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swaptionVols(swaptionVolsSEXP);
rcpp_result_gen = Rcpp::wrap(affineWithRebuiltCurveEngine(rparam, legparams, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols));
return rcpp_result_gen;
END_RCPP
}
// asianOptionEngine
Rcpp::List asianOptionEngine(std::string averageType, std::string type, double underlying, double strike, double dividendYield, double riskFreeRate, double maturity, double volatility, double first, double length, size_t fixings);
RcppExport SEXP _RQuantLib_asianOptionEngine(SEXP averageTypeSEXP, SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP volatilitySEXP, SEXP firstSEXP, SEXP lengthSEXP, SEXP fixingsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type averageType(averageTypeSEXP);
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< double >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< double >::type first(firstSEXP);
Rcpp::traits::input_parameter< double >::type length(lengthSEXP);
Rcpp::traits::input_parameter< size_t >::type fixings(fixingsSEXP);
rcpp_result_gen = Rcpp::wrap(asianOptionEngine(averageType, type, underlying, strike, dividendYield, riskFreeRate, maturity, volatility, first, length, fixings));
return rcpp_result_gen;
END_RCPP
}
// binaryOptionEngine
Rcpp::List binaryOptionEngine(std::string binType, std::string type, std::string excType, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, double cashPayoff, int dayCounter);
RcppExport SEXP _RQuantLib_binaryOptionEngine(SEXP binTypeSEXP, SEXP typeSEXP, SEXP excTypeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP cashPayoffSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type binType(binTypeSEXP);
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< std::string >::type excType(excTypeSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< double >::type cashPayoff(cashPayoffSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(binaryOptionEngine(binType, type, excType, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter));
return rcpp_result_gen;
END_RCPP
}
// binaryOptionImpliedVolatilityEngine
double binaryOptionImpliedVolatilityEngine(std::string type, double value, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, double cashPayoff, int dayCounter);
RcppExport SEXP _RQuantLib_binaryOptionImpliedVolatilityEngine(SEXP typeSEXP, SEXP valueSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP cashPayoffSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type value(valueSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< double >::type cashPayoff(cashPayoffSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(binaryOptionImpliedVolatilityEngine(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, cashPayoff, dayCounter));
return rcpp_result_gen;
END_RCPP
}
// barrierOptionEngine
Rcpp::List barrierOptionEngine(std::string barrType, std::string type, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, double barrier, double rebate, int dayCounter);
RcppExport SEXP _RQuantLib_barrierOptionEngine(SEXP barrTypeSEXP, SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP barrierSEXP, SEXP rebateSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type barrType(barrTypeSEXP);
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< double >::type barrier(barrierSEXP);
Rcpp::traits::input_parameter< double >::type rebate(rebateSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(barrierOptionEngine(barrType, type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, barrier, rebate, dayCounter));
return rcpp_result_gen;
END_RCPP
}
// bermudanFromYieldEngine
Rcpp::List bermudanFromYieldEngine(Rcpp::List rparam, Rcpp::NumericVector yield, Rcpp::NumericVector swaptionMat, Rcpp::NumericVector swapLengths, Rcpp::NumericMatrix swaptionVols);
RcppExport SEXP _RQuantLib_bermudanFromYieldEngine(SEXP rparamSEXP, SEXP yieldSEXP, SEXP swaptionMatSEXP, SEXP swapLengthsSEXP, SEXP swaptionVolsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type yield(yieldSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swaptionMat(swaptionMatSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swapLengths(swapLengthsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type swaptionVols(swaptionVolsSEXP);
rcpp_result_gen = Rcpp::wrap(bermudanFromYieldEngine(rparam, yield, swaptionMat, swapLengths, swaptionVols));
return rcpp_result_gen;
END_RCPP
}
// bermudanWithRebuiltCurveEngine
Rcpp::List bermudanWithRebuiltCurveEngine(Rcpp::List rparam, std::vector dateVec, std::vector zeroVec, Rcpp::NumericVector swaptionMat, Rcpp::NumericVector swapLengths, Rcpp::NumericMatrix swaptionVols);
RcppExport SEXP _RQuantLib_bermudanWithRebuiltCurveEngine(SEXP rparamSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP swaptionMatSEXP, SEXP swapLengthsSEXP, SEXP swaptionVolsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swaptionMat(swaptionMatSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swapLengths(swapLengthsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type swaptionVols(swaptionVolsSEXP);
rcpp_result_gen = Rcpp::wrap(bermudanWithRebuiltCurveEngine(rparam, dateVec, zeroVec, swaptionMat, swapLengths, swaptionVols));
return rcpp_result_gen;
END_RCPP
}
// zeroPriceByYieldEngine
double zeroPriceByYieldEngine(double yield, double faceAmount, double dayCounter, double frequency, double businessDayConvention, double compound, QuantLib::Date maturityDate, QuantLib::Date issueDate);
static SEXP _RQuantLib_zeroPriceByYieldEngine_try(SEXP yieldSEXP, SEXP faceAmountSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< double >::type yield(yieldSEXP);
Rcpp::traits::input_parameter< double >::type faceAmount(faceAmountSEXP);
Rcpp::traits::input_parameter< double >::type dayCounter(dayCounterSEXP);
Rcpp::traits::input_parameter< double >::type frequency(frequencySEXP);
Rcpp::traits::input_parameter< double >::type businessDayConvention(businessDayConventionSEXP);
Rcpp::traits::input_parameter< double >::type compound(compoundSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturityDate(maturityDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type issueDate(issueDateSEXP);
rcpp_result_gen = Rcpp::wrap(zeroPriceByYieldEngine(yield, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_zeroPriceByYieldEngine(SEXP yieldSEXP, SEXP faceAmountSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_zeroPriceByYieldEngine_try(yieldSEXP, faceAmountSEXP, dayCounterSEXP, frequencySEXP, businessDayConventionSEXP, compoundSEXP, maturityDateSEXP, issueDateSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// zeroYieldByPriceEngine
double zeroYieldByPriceEngine(double price, double faceAmount, double dayCounter, double frequency, double businessDayConvention, double compound, QuantLib::Date maturityDate, QuantLib::Date issueDate);
static SEXP _RQuantLib_zeroYieldByPriceEngine_try(SEXP priceSEXP, SEXP faceAmountSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< double >::type price(priceSEXP);
Rcpp::traits::input_parameter< double >::type faceAmount(faceAmountSEXP);
Rcpp::traits::input_parameter< double >::type dayCounter(dayCounterSEXP);
Rcpp::traits::input_parameter< double >::type frequency(frequencySEXP);
Rcpp::traits::input_parameter< double >::type businessDayConvention(businessDayConventionSEXP);
Rcpp::traits::input_parameter< double >::type compound(compoundSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturityDate(maturityDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type issueDate(issueDateSEXP);
rcpp_result_gen = Rcpp::wrap(zeroYieldByPriceEngine(price, faceAmount, dayCounter, frequency, businessDayConvention, compound, maturityDate, issueDate));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_zeroYieldByPriceEngine(SEXP priceSEXP, SEXP faceAmountSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_zeroYieldByPriceEngine_try(priceSEXP, faceAmountSEXP, dayCounterSEXP, frequencySEXP, businessDayConventionSEXP, compoundSEXP, maturityDateSEXP, issueDateSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// fixedRateBondYieldByPriceEngine
double fixedRateBondYieldByPriceEngine(double settlementDays, double price, std::string cal, double faceAmount, double businessDayConvention, double compound, double redemption, double dayCounter, double frequency, QuantLib::Date maturityDate, QuantLib::Date issueDate, QuantLib::Date effectiveDate, std::vector rates);
static SEXP _RQuantLib_fixedRateBondYieldByPriceEngine_try(SEXP settlementDaysSEXP, SEXP priceSEXP, SEXP calSEXP, SEXP faceAmountSEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP redemptionSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP, SEXP effectiveDateSEXP, SEXP ratesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< double >::type settlementDays(settlementDaysSEXP);
Rcpp::traits::input_parameter< double >::type price(priceSEXP);
Rcpp::traits::input_parameter< std::string >::type cal(calSEXP);
Rcpp::traits::input_parameter< double >::type faceAmount(faceAmountSEXP);
Rcpp::traits::input_parameter< double >::type businessDayConvention(businessDayConventionSEXP);
Rcpp::traits::input_parameter< double >::type compound(compoundSEXP);
Rcpp::traits::input_parameter< double >::type redemption(redemptionSEXP);
Rcpp::traits::input_parameter< double >::type dayCounter(dayCounterSEXP);
Rcpp::traits::input_parameter< double >::type frequency(frequencySEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturityDate(maturityDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type issueDate(issueDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type effectiveDate(effectiveDateSEXP);
Rcpp::traits::input_parameter< std::vector >::type rates(ratesSEXP);
rcpp_result_gen = Rcpp::wrap(fixedRateBondYieldByPriceEngine(settlementDays, price, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_fixedRateBondYieldByPriceEngine(SEXP settlementDaysSEXP, SEXP priceSEXP, SEXP calSEXP, SEXP faceAmountSEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP redemptionSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP, SEXP effectiveDateSEXP, SEXP ratesSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_fixedRateBondYieldByPriceEngine_try(settlementDaysSEXP, priceSEXP, calSEXP, faceAmountSEXP, businessDayConventionSEXP, compoundSEXP, redemptionSEXP, dayCounterSEXP, frequencySEXP, maturityDateSEXP, issueDateSEXP, effectiveDateSEXP, ratesSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// fixedRateBondPriceByYieldEngine
double fixedRateBondPriceByYieldEngine(double settlementDays, double yield, std::string cal, double faceAmount, double businessDayConvention, double compound, double redemption, double dayCounter, double frequency, QuantLib::Date maturityDate, QuantLib::Date issueDate, QuantLib::Date effectiveDate, std::vector rates);
static SEXP _RQuantLib_fixedRateBondPriceByYieldEngine_try(SEXP settlementDaysSEXP, SEXP yieldSEXP, SEXP calSEXP, SEXP faceAmountSEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP redemptionSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP, SEXP effectiveDateSEXP, SEXP ratesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< double >::type settlementDays(settlementDaysSEXP);
Rcpp::traits::input_parameter< double >::type yield(yieldSEXP);
Rcpp::traits::input_parameter< std::string >::type cal(calSEXP);
Rcpp::traits::input_parameter< double >::type faceAmount(faceAmountSEXP);
Rcpp::traits::input_parameter< double >::type businessDayConvention(businessDayConventionSEXP);
Rcpp::traits::input_parameter< double >::type compound(compoundSEXP);
Rcpp::traits::input_parameter< double >::type redemption(redemptionSEXP);
Rcpp::traits::input_parameter< double >::type dayCounter(dayCounterSEXP);
Rcpp::traits::input_parameter< double >::type frequency(frequencySEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturityDate(maturityDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type issueDate(issueDateSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type effectiveDate(effectiveDateSEXP);
Rcpp::traits::input_parameter< std::vector >::type rates(ratesSEXP);
rcpp_result_gen = Rcpp::wrap(fixedRateBondPriceByYieldEngine(settlementDays, yield, cal, faceAmount, businessDayConvention, compound, redemption, dayCounter, frequency, maturityDate, issueDate, effectiveDate, rates));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_fixedRateBondPriceByYieldEngine(SEXP settlementDaysSEXP, SEXP yieldSEXP, SEXP calSEXP, SEXP faceAmountSEXP, SEXP businessDayConventionSEXP, SEXP compoundSEXP, SEXP redemptionSEXP, SEXP dayCounterSEXP, SEXP frequencySEXP, SEXP maturityDateSEXP, SEXP issueDateSEXP, SEXP effectiveDateSEXP, SEXP ratesSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_fixedRateBondPriceByYieldEngine_try(settlementDaysSEXP, yieldSEXP, calSEXP, faceAmountSEXP, businessDayConventionSEXP, compoundSEXP, redemptionSEXP, dayCounterSEXP, frequencySEXP, maturityDateSEXP, issueDateSEXP, effectiveDateSEXP, ratesSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FloatBond1
Rcpp::List FloatBond1(Rcpp::List bond, std::vector gearings, std::vector caps, std::vector spreads, std::vector floors, Rcpp::List indexparams, Rcpp::List index, Rcpp::List discountCurve, Rcpp::List dateparams);
static SEXP _RQuantLib_FloatBond1_try(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP indexSEXP, SEXP discountCurveSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bond(bondSEXP);
Rcpp::traits::input_parameter< std::vector >::type gearings(gearingsSEXP);
Rcpp::traits::input_parameter< std::vector >::type caps(capsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< std::vector >::type floors(floorsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type indexparams(indexparamsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index(indexSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type discountCurve(discountCurveSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(FloatBond1(bond, gearings, caps, spreads, floors, indexparams, index, discountCurve, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FloatBond1(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP indexSEXP, SEXP discountCurveSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FloatBond1_try(bondSEXP, gearingsSEXP, capsSEXP, spreadsSEXP, floorsSEXP, indexparamsSEXP, indexSEXP, discountCurveSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FloatBond2
Rcpp::List FloatBond2(Rcpp::List bond, std::vector gearings, std::vector caps, std::vector spreads, std::vector floors, Rcpp::List indexparams, Rcpp::List index_params, Rcpp::List index_tsQuotes, Rcpp::List index_times, Rcpp::List discountCurve, Rcpp::List dateparams);
static SEXP _RQuantLib_FloatBond2_try(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP index_paramsSEXP, SEXP index_tsQuotesSEXP, SEXP index_timesSEXP, SEXP discountCurveSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bond(bondSEXP);
Rcpp::traits::input_parameter< std::vector >::type gearings(gearingsSEXP);
Rcpp::traits::input_parameter< std::vector >::type caps(capsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< std::vector >::type floors(floorsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type indexparams(indexparamsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_params(index_paramsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_tsQuotes(index_tsQuotesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_times(index_timesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type discountCurve(discountCurveSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(FloatBond2(bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, discountCurve, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FloatBond2(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP index_paramsSEXP, SEXP index_tsQuotesSEXP, SEXP index_timesSEXP, SEXP discountCurveSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FloatBond2_try(bondSEXP, gearingsSEXP, capsSEXP, spreadsSEXP, floorsSEXP, indexparamsSEXP, index_paramsSEXP, index_tsQuotesSEXP, index_timesSEXP, discountCurveSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FloatBond3
Rcpp::List FloatBond3(Rcpp::List bond, std::vector gearings, std::vector caps, std::vector spreads, std::vector floors, Rcpp::List indexparams, Rcpp::List index, Rcpp::List disc_params, Rcpp::List disc_tsQuotes, Rcpp::List disc_times, Rcpp::List dateparams);
static SEXP _RQuantLib_FloatBond3_try(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP indexSEXP, SEXP disc_paramsSEXP, SEXP disc_tsQuotesSEXP, SEXP disc_timesSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bond(bondSEXP);
Rcpp::traits::input_parameter< std::vector >::type gearings(gearingsSEXP);
Rcpp::traits::input_parameter< std::vector >::type caps(capsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< std::vector >::type floors(floorsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type indexparams(indexparamsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index(indexSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_params(disc_paramsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_tsQuotes(disc_tsQuotesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_times(disc_timesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(FloatBond3(bond, gearings, caps, spreads, floors, indexparams, index, disc_params, disc_tsQuotes, disc_times, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FloatBond3(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP indexSEXP, SEXP disc_paramsSEXP, SEXP disc_tsQuotesSEXP, SEXP disc_timesSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FloatBond3_try(bondSEXP, gearingsSEXP, capsSEXP, spreadsSEXP, floorsSEXP, indexparamsSEXP, indexSEXP, disc_paramsSEXP, disc_tsQuotesSEXP, disc_timesSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FloatBond4
Rcpp::List FloatBond4(Rcpp::List bond, std::vector gearings, std::vector caps, std::vector spreads, std::vector floors, Rcpp::List indexparams, Rcpp::List index_params, Rcpp::List index_tsQuotes, Rcpp::List index_times, Rcpp::List disc_params, Rcpp::List disc_tsQuotes, Rcpp::List disc_times, Rcpp::List dateparams);
static SEXP _RQuantLib_FloatBond4_try(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP index_paramsSEXP, SEXP index_tsQuotesSEXP, SEXP index_timesSEXP, SEXP disc_paramsSEXP, SEXP disc_tsQuotesSEXP, SEXP disc_timesSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bond(bondSEXP);
Rcpp::traits::input_parameter< std::vector >::type gearings(gearingsSEXP);
Rcpp::traits::input_parameter< std::vector >::type caps(capsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< std::vector >::type floors(floorsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type indexparams(indexparamsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_params(index_paramsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_tsQuotes(index_tsQuotesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type index_times(index_timesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_params(disc_paramsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_tsQuotes(disc_tsQuotesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type disc_times(disc_timesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(FloatBond4(bond, gearings, caps, spreads, floors, indexparams, index_params, index_tsQuotes, index_times, disc_params, disc_tsQuotes, disc_times, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FloatBond4(SEXP bondSEXP, SEXP gearingsSEXP, SEXP capsSEXP, SEXP spreadsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP index_paramsSEXP, SEXP index_tsQuotesSEXP, SEXP index_timesSEXP, SEXP disc_paramsSEXP, SEXP disc_tsQuotesSEXP, SEXP disc_timesSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FloatBond4_try(bondSEXP, gearingsSEXP, capsSEXP, spreadsSEXP, floorsSEXP, indexparamsSEXP, index_paramsSEXP, index_tsQuotesSEXP, index_timesSEXP, disc_paramsSEXP, disc_tsQuotesSEXP, disc_timesSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// floatingWithRebuiltCurveEngine
Rcpp::List floatingWithRebuiltCurveEngine(Rcpp::List bondparams, std::vector gearings, std::vector spreads, std::vector caps, std::vector floors, Rcpp::List indexparams, std::vector iborDateVec, std::vector iborzeroVec, std::vector dateVec, std::vector zeroVec, Rcpp::List dateparams);
static SEXP _RQuantLib_floatingWithRebuiltCurveEngine_try(SEXP bondparamsSEXP, SEXP gearingsSEXP, SEXP spreadsSEXP, SEXP capsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP iborDateVecSEXP, SEXP iborzeroVecSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bondparams(bondparamsSEXP);
Rcpp::traits::input_parameter< std::vector >::type gearings(gearingsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< std::vector >::type caps(capsSEXP);
Rcpp::traits::input_parameter< std::vector >::type floors(floorsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type indexparams(indexparamsSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborDateVec(iborDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborzeroVec(iborzeroVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(floatingWithRebuiltCurveEngine(bondparams, gearings, spreads, caps, floors, indexparams, iborDateVec, iborzeroVec, dateVec, zeroVec, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_floatingWithRebuiltCurveEngine(SEXP bondparamsSEXP, SEXP gearingsSEXP, SEXP spreadsSEXP, SEXP capsSEXP, SEXP floorsSEXP, SEXP indexparamsSEXP, SEXP iborDateVecSEXP, SEXP iborzeroVecSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_floatingWithRebuiltCurveEngine_try(bondparamsSEXP, gearingsSEXP, spreadsSEXP, capsSEXP, floorsSEXP, indexparamsSEXP, iborDateVecSEXP, iborzeroVecSEXP, dateVecSEXP, zeroVecSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FixedRateWithYield
Rcpp::List FixedRateWithYield(Rcpp::List bondparam, std::vector ratesVec, Rcpp::List scheduleparam, Rcpp::List calcparam, double yield);
static SEXP _RQuantLib_FixedRateWithYield_try(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP yieldSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bondparam(bondparamSEXP);
Rcpp::traits::input_parameter< std::vector >::type ratesVec(ratesVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type scheduleparam(scheduleparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type calcparam(calcparamSEXP);
Rcpp::traits::input_parameter< double >::type yield(yieldSEXP);
rcpp_result_gen = Rcpp::wrap(FixedRateWithYield(bondparam, ratesVec, scheduleparam, calcparam, yield));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FixedRateWithYield(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP yieldSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FixedRateWithYield_try(bondparamSEXP, ratesVecSEXP, scheduleparamSEXP, calcparamSEXP, yieldSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FixedRateWithPrice
Rcpp::List FixedRateWithPrice(Rcpp::List bondparam, std::vector ratesVec, Rcpp::List scheduleparam, Rcpp::List calcparam, double price);
static SEXP _RQuantLib_FixedRateWithPrice_try(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP priceSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bondparam(bondparamSEXP);
Rcpp::traits::input_parameter< std::vector >::type ratesVec(ratesVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type scheduleparam(scheduleparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type calcparam(calcparamSEXP);
Rcpp::traits::input_parameter< double >::type price(priceSEXP);
rcpp_result_gen = Rcpp::wrap(FixedRateWithPrice(bondparam, ratesVec, scheduleparam, calcparam, price));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FixedRateWithPrice(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP priceSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FixedRateWithPrice_try(bondparamSEXP, ratesVecSEXP, scheduleparamSEXP, calcparamSEXP, priceSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// FixedRateWithRebuiltCurve
Rcpp::List FixedRateWithRebuiltCurve(Rcpp::List bondparam, std::vector ratesVec, Rcpp::List scheduleparam, Rcpp::List calcparam, std::vector dateVec, std::vector zeroVec);
static SEXP _RQuantLib_FixedRateWithRebuiltCurve_try(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bondparam(bondparamSEXP);
Rcpp::traits::input_parameter< std::vector >::type ratesVec(ratesVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type scheduleparam(scheduleparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type calcparam(calcparamSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
rcpp_result_gen = Rcpp::wrap(FixedRateWithRebuiltCurve(bondparam, ratesVec, scheduleparam, calcparam, dateVec, zeroVec));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_FixedRateWithRebuiltCurve(SEXP bondparamSEXP, SEXP ratesVecSEXP, SEXP scheduleparamSEXP, SEXP calcparamSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_FixedRateWithRebuiltCurve_try(bondparamSEXP, ratesVecSEXP, scheduleparamSEXP, calcparamSEXP, dateVecSEXP, zeroVecSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// ZeroBondWithRebuiltCurve
Rcpp::List ZeroBondWithRebuiltCurve(Rcpp::List bond, std::vector dateVec, std::vector zeroVec, Rcpp::List dateparams);
static SEXP _RQuantLib_ZeroBondWithRebuiltCurve_try(SEXP bondSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP dateparamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type bond(bondSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type dateparams(dateparamsSEXP);
rcpp_result_gen = Rcpp::wrap(ZeroBondWithRebuiltCurve(bond, dateVec, zeroVec, dateparams));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_ZeroBondWithRebuiltCurve(SEXP bondSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP dateparamsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_ZeroBondWithRebuiltCurve_try(bondSEXP, dateVecSEXP, zeroVecSEXP, dateparamsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// convertibleZeroBondEngine
Rcpp::List convertibleZeroBondEngine(Rcpp::List rparam, Rcpp::List processParam, std::vector dividendYieldDateVec, std::vector dividendYieldZeroVec, std::vector rffDateVec, std::vector rffZeroVec, Rcpp::DataFrame dividendScheduleFrame, Rcpp::DataFrame callabilityScheduleFrame, Rcpp::List datemisc);
static SEXP _RQuantLib_convertibleZeroBondEngine_try(SEXP rparamSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type processParam(processParamSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldDateVec(dividendYieldDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldZeroVec(dividendYieldZeroVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffDateVec(rffDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffZeroVec(rffZeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type dividendScheduleFrame(dividendScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type callabilityScheduleFrame(callabilityScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type datemisc(datemiscSEXP);
rcpp_result_gen = Rcpp::wrap(convertibleZeroBondEngine(rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_convertibleZeroBondEngine(SEXP rparamSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_convertibleZeroBondEngine_try(rparamSEXP, processParamSEXP, dividendYieldDateVecSEXP, dividendYieldZeroVecSEXP, rffDateVecSEXP, rffZeroVecSEXP, dividendScheduleFrameSEXP, callabilityScheduleFrameSEXP, datemiscSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// convertibleFixedBondEngine
Rcpp::List convertibleFixedBondEngine(Rcpp::List rparam, Rcpp::NumericVector rates, Rcpp::List processParam, std::vector dividendYieldDateVec, std::vector dividendYieldZeroVec, std::vector rffDateVec, std::vector rffZeroVec, Rcpp::DataFrame dividendScheduleFrame, Rcpp::DataFrame callabilityScheduleFrame, Rcpp::List datemisc);
static SEXP _RQuantLib_convertibleFixedBondEngine_try(SEXP rparamSEXP, SEXP ratesSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type rates(ratesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type processParam(processParamSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldDateVec(dividendYieldDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldZeroVec(dividendYieldZeroVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffDateVec(rffDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffZeroVec(rffZeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type dividendScheduleFrame(dividendScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type callabilityScheduleFrame(callabilityScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type datemisc(datemiscSEXP);
rcpp_result_gen = Rcpp::wrap(convertibleFixedBondEngine(rparam, rates, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, dividendScheduleFrame, callabilityScheduleFrame, datemisc));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_convertibleFixedBondEngine(SEXP rparamSEXP, SEXP ratesSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_convertibleFixedBondEngine_try(rparamSEXP, ratesSEXP, processParamSEXP, dividendYieldDateVecSEXP, dividendYieldZeroVecSEXP, rffDateVecSEXP, rffZeroVecSEXP, dividendScheduleFrameSEXP, callabilityScheduleFrameSEXP, datemiscSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// convertibleFloatingBondEngine
Rcpp::List convertibleFloatingBondEngine(Rcpp::List rparam, Rcpp::List processParam, std::vector dividendYieldDateVec, std::vector dividendYieldZeroVec, std::vector rffDateVec, std::vector rffZeroVec, std::vector iborIndexDateVec, std::vector iborIndexZeroVec, Rcpp::List iborparams, std::vector spreads, Rcpp::DataFrame dividendScheduleFrame, Rcpp::DataFrame callabilityScheduleFrame, Rcpp::List datemisc);
static SEXP _RQuantLib_convertibleFloatingBondEngine_try(SEXP rparamSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP iborIndexDateVecSEXP, SEXP iborIndexZeroVecSEXP, SEXP iborparamsSEXP, SEXP spreadsSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type processParam(processParamSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldDateVec(dividendYieldDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type dividendYieldZeroVec(dividendYieldZeroVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffDateVec(rffDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type rffZeroVec(rffZeroVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborIndexDateVec(iborIndexDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborIndexZeroVec(iborIndexZeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type iborparams(iborparamsSEXP);
Rcpp::traits::input_parameter< std::vector >::type spreads(spreadsSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type dividendScheduleFrame(dividendScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type callabilityScheduleFrame(callabilityScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type datemisc(datemiscSEXP);
rcpp_result_gen = Rcpp::wrap(convertibleFloatingBondEngine(rparam, processParam, dividendYieldDateVec, dividendYieldZeroVec, rffDateVec, rffZeroVec, iborIndexDateVec, iborIndexZeroVec, iborparams, spreads, dividendScheduleFrame, callabilityScheduleFrame, datemisc));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_convertibleFloatingBondEngine(SEXP rparamSEXP, SEXP processParamSEXP, SEXP dividendYieldDateVecSEXP, SEXP dividendYieldZeroVecSEXP, SEXP rffDateVecSEXP, SEXP rffZeroVecSEXP, SEXP iborIndexDateVecSEXP, SEXP iborIndexZeroVecSEXP, SEXP iborparamsSEXP, SEXP spreadsSEXP, SEXP dividendScheduleFrameSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_convertibleFloatingBondEngine_try(rparamSEXP, processParamSEXP, dividendYieldDateVecSEXP, dividendYieldZeroVecSEXP, rffDateVecSEXP, rffZeroVecSEXP, iborIndexDateVecSEXP, iborIndexZeroVecSEXP, iborparamsSEXP, spreadsSEXP, dividendScheduleFrameSEXP, callabilityScheduleFrameSEXP, datemiscSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// callableBondEngine
Rcpp::List callableBondEngine(Rcpp::List rparam, Rcpp::List hwparam, Rcpp::NumericVector coupon, Rcpp::DataFrame callabilityScheduleFrame, Rcpp::List datemisc);
static SEXP _RQuantLib_callableBondEngine_try(SEXP rparamSEXP, SEXP hwparamSEXP, SEXP couponSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type hwparam(hwparamSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type coupon(couponSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type callabilityScheduleFrame(callabilityScheduleFrameSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type datemisc(datemiscSEXP);
rcpp_result_gen = Rcpp::wrap(callableBondEngine(rparam, hwparam, coupon, callabilityScheduleFrame, datemisc));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_callableBondEngine(SEXP rparamSEXP, SEXP hwparamSEXP, SEXP couponSEXP, SEXP callabilityScheduleFrameSEXP, SEXP datemiscSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_callableBondEngine_try(rparamSEXP, hwparamSEXP, couponSEXP, callabilityScheduleFrameSEXP, datemiscSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// fittedBondCurveEngine
Rcpp::List fittedBondCurveEngine(Rcpp::List curveparam, Rcpp::NumericVector length, Rcpp::NumericVector coupons, Rcpp::NumericVector marketQuotes, Rcpp::List datemisc);
static SEXP _RQuantLib_fittedBondCurveEngine_try(SEXP curveparamSEXP, SEXP lengthSEXP, SEXP couponsSEXP, SEXP marketQuotesSEXP, SEXP datemiscSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type curveparam(curveparamSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type length(lengthSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type coupons(couponsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type marketQuotes(marketQuotesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type datemisc(datemiscSEXP);
rcpp_result_gen = Rcpp::wrap(fittedBondCurveEngine(curveparam, length, coupons, marketQuotes, datemisc));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_fittedBondCurveEngine(SEXP curveparamSEXP, SEXP lengthSEXP, SEXP couponsSEXP, SEXP marketQuotesSEXP, SEXP datemiscSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_fittedBondCurveEngine_try(curveparamSEXP, lengthSEXP, couponsSEXP, marketQuotesSEXP, datemiscSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// setCalendarContext
bool setCalendarContext(std::string calendar, int fixingDays, QuantLib::Date settleDate);
RcppExport SEXP _RQuantLib_setCalendarContext(SEXP calendarSEXP, SEXP fixingDaysSEXP, SEXP settleDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< int >::type fixingDays(fixingDaysSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type settleDate(settleDateSEXP);
rcpp_result_gen = Rcpp::wrap(setCalendarContext(calendar, fixingDays, settleDate));
return rcpp_result_gen;
END_RCPP
}
// isBusinessDay
std::vector isBusinessDay(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_isBusinessDay(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(isBusinessDay(calendar, dates));
return rcpp_result_gen;
END_RCPP
}
// isHoliday
std::vector isHoliday(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_isHoliday(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(isHoliday(calendar, dates));
return rcpp_result_gen;
END_RCPP
}
// isWeekend
std::vector isWeekend(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_isWeekend(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(isWeekend(calendar, dates));
return rcpp_result_gen;
END_RCPP
}
// isEndOfMonth
std::vector isEndOfMonth(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_isEndOfMonth(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(isEndOfMonth(calendar, dates));
return rcpp_result_gen;
END_RCPP
}
// getEndOfMonth
std::vector getEndOfMonth(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_getEndOfMonth(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(getEndOfMonth(calendar, dates));
return rcpp_result_gen;
END_RCPP
}
// adjust
std::vector adjust(std::string calendar, std::vector dates, int bdc);
RcppExport SEXP _RQuantLib_adjust(SEXP calendarSEXP, SEXP datesSEXP, SEXP bdcSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
Rcpp::traits::input_parameter< int >::type bdc(bdcSEXP);
rcpp_result_gen = Rcpp::wrap(adjust(calendar, dates, bdc));
return rcpp_result_gen;
END_RCPP
}
// advance1
std::vector advance1(std::string calendar, double amount, double unit, int bdcVal, double emr, std::vector dates);
RcppExport SEXP _RQuantLib_advance1(SEXP calendarSEXP, SEXP amountSEXP, SEXP unitSEXP, SEXP bdcValSEXP, SEXP emrSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< double >::type amount(amountSEXP);
Rcpp::traits::input_parameter< double >::type unit(unitSEXP);
Rcpp::traits::input_parameter< int >::type bdcVal(bdcValSEXP);
Rcpp::traits::input_parameter< double >::type emr(emrSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(advance1(calendar, amount, unit, bdcVal, emr, dates));
return rcpp_result_gen;
END_RCPP
}
// advance2
std::vector advance2(std::string calendar, double period, int bdcVal, double emr, std::vector dates);
RcppExport SEXP _RQuantLib_advance2(SEXP calendarSEXP, SEXP periodSEXP, SEXP bdcValSEXP, SEXP emrSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< double >::type period(periodSEXP);
Rcpp::traits::input_parameter< int >::type bdcVal(bdcValSEXP);
Rcpp::traits::input_parameter< double >::type emr(emrSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
rcpp_result_gen = Rcpp::wrap(advance2(calendar, period, bdcVal, emr, dates));
return rcpp_result_gen;
END_RCPP
}
// businessDaysBetween
std::vector businessDaysBetween(std::string calendar, std::vector from, std::vector to, bool includeFirst, bool includeLast);
RcppExport SEXP _RQuantLib_businessDaysBetween(SEXP calendarSEXP, SEXP fromSEXP, SEXP toSEXP, SEXP includeFirstSEXP, SEXP includeLastSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type from(fromSEXP);
Rcpp::traits::input_parameter< std::vector >::type to(toSEXP);
Rcpp::traits::input_parameter< bool >::type includeFirst(includeFirstSEXP);
Rcpp::traits::input_parameter< bool >::type includeLast(includeLastSEXP);
rcpp_result_gen = Rcpp::wrap(businessDaysBetween(calendar, from, to, includeFirst, includeLast));
return rcpp_result_gen;
END_RCPP
}
// getHolidayList
std::vector getHolidayList(std::string calendar, QuantLib::Date from, QuantLib::Date to, bool includeWeekends);
RcppExport SEXP _RQuantLib_getHolidayList(SEXP calendarSEXP, SEXP fromSEXP, SEXP toSEXP, SEXP includeWeekendsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type from(fromSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type to(toSEXP);
Rcpp::traits::input_parameter< bool >::type includeWeekends(includeWeekendsSEXP);
rcpp_result_gen = Rcpp::wrap(getHolidayList(calendar, from, to, includeWeekends));
return rcpp_result_gen;
END_RCPP
}
// getBusinessDayList
std::vector getBusinessDayList(std::string calendar, QuantLib::Date from, QuantLib::Date to);
RcppExport SEXP _RQuantLib_getBusinessDayList(SEXP calendarSEXP, SEXP fromSEXP, SEXP toSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type from(fromSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type to(toSEXP);
rcpp_result_gen = Rcpp::wrap(getBusinessDayList(calendar, from, to));
return rcpp_result_gen;
END_RCPP
}
// addHolidays
void addHolidays(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_addHolidays(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
addHolidays(calendar, dates);
return R_NilValue;
END_RCPP
}
// removeHolidays
void removeHolidays(std::string calendar, std::vector dates);
RcppExport SEXP _RQuantLib_removeHolidays(SEXP calendarSEXP, SEXP datesSEXP) {
BEGIN_RCPP
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::string >::type calendar(calendarSEXP);
Rcpp::traits::input_parameter< std::vector >::type dates(datesSEXP);
removeHolidays(calendar, dates);
return R_NilValue;
END_RCPP
}
// advanceDate
QuantLib::Date advanceDate(QuantLib::Date issueDate, int days);
static SEXP _RQuantLib_advanceDate_try(SEXP issueDateSEXP, SEXP daysSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< QuantLib::Date >::type issueDate(issueDateSEXP);
Rcpp::traits::input_parameter< int >::type days(daysSEXP);
rcpp_result_gen = Rcpp::wrap(advanceDate(issueDate, days));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_advanceDate(SEXP issueDateSEXP, SEXP daysSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_advanceDate_try(issueDateSEXP, daysSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// dayCount
std::vector dayCount(std::vector startDates, std::vector endDates, std::vector dayCounters);
static SEXP _RQuantLib_dayCount_try(SEXP startDatesSEXP, SEXP endDatesSEXP, SEXP dayCountersSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::vector >::type startDates(startDatesSEXP);
Rcpp::traits::input_parameter< std::vector >::type endDates(endDatesSEXP);
Rcpp::traits::input_parameter< std::vector >::type dayCounters(dayCountersSEXP);
rcpp_result_gen = Rcpp::wrap(dayCount(startDates, endDates, dayCounters));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_dayCount(SEXP startDatesSEXP, SEXP endDatesSEXP, SEXP dayCountersSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_dayCount_try(startDatesSEXP, endDatesSEXP, dayCountersSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// yearFraction
std::vector yearFraction(std::vector startDates, std::vector endDates, std::vector dayCounters);
static SEXP _RQuantLib_yearFraction_try(SEXP startDatesSEXP, SEXP endDatesSEXP, SEXP dayCountersSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::vector >::type startDates(startDatesSEXP);
Rcpp::traits::input_parameter< std::vector >::type endDates(endDatesSEXP);
Rcpp::traits::input_parameter< std::vector >::type dayCounters(dayCountersSEXP);
rcpp_result_gen = Rcpp::wrap(yearFraction(startDates, endDates, dayCounters));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_yearFraction(SEXP startDatesSEXP, SEXP endDatesSEXP, SEXP dayCountersSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_yearFraction_try(startDatesSEXP, endDatesSEXP, dayCountersSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// setEvaluationDate
bool setEvaluationDate(QuantLib::Date evalDate);
static SEXP _RQuantLib_setEvaluationDate_try(SEXP evalDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< QuantLib::Date >::type evalDate(evalDateSEXP);
rcpp_result_gen = Rcpp::wrap(setEvaluationDate(evalDate));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_setEvaluationDate(SEXP evalDateSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_setEvaluationDate_try(evalDateSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// discountCurveEngine
Rcpp::List discountCurveEngine(Rcpp::List rparams, Rcpp::List tslist, Rcpp::NumericVector times, Rcpp::List legParams);
RcppExport SEXP _RQuantLib_discountCurveEngine(SEXP rparamsSEXP, SEXP tslistSEXP, SEXP timesSEXP, SEXP legParamsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparams(rparamsSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type tslist(tslistSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type times(timesSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type legParams(legParamsSEXP);
rcpp_result_gen = Rcpp::wrap(discountCurveEngine(rparams, tslist, times, legParams));
return rcpp_result_gen;
END_RCPP
}
// calibrateHullWhiteUsingCapsEngine
Rcpp::List calibrateHullWhiteUsingCapsEngine(std::vector termStrcDateVec, std::vector termStrcZeroVec, Rcpp::DataFrame capDF, std::vector iborDateVec, std::vector iborZeroVec, std::string iborType, QuantLib::Date evalDate);
RcppExport SEXP _RQuantLib_calibrateHullWhiteUsingCapsEngine(SEXP termStrcDateVecSEXP, SEXP termStrcZeroVecSEXP, SEXP capDFSEXP, SEXP iborDateVecSEXP, SEXP iborZeroVecSEXP, SEXP iborTypeSEXP, SEXP evalDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::vector >::type termStrcDateVec(termStrcDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type termStrcZeroVec(termStrcZeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type capDF(capDFSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborDateVec(iborDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborZeroVec(iborZeroVecSEXP);
Rcpp::traits::input_parameter< std::string >::type iborType(iborTypeSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type evalDate(evalDateSEXP);
rcpp_result_gen = Rcpp::wrap(calibrateHullWhiteUsingCapsEngine(termStrcDateVec, termStrcZeroVec, capDF, iborDateVec, iborZeroVec, iborType, evalDate));
return rcpp_result_gen;
END_RCPP
}
// calibrateHullWhiteUsingSwapsEngine
Rcpp::List calibrateHullWhiteUsingSwapsEngine(std::vector termStrcDateVec, std::vector termStrcZeroVec, Rcpp::DataFrame swapDF, std::vector iborDateVec, std::vector iborZeroVec, std::string iborType, QuantLib::Date evalDate);
RcppExport SEXP _RQuantLib_calibrateHullWhiteUsingSwapsEngine(SEXP termStrcDateVecSEXP, SEXP termStrcZeroVecSEXP, SEXP swapDFSEXP, SEXP iborDateVecSEXP, SEXP iborZeroVecSEXP, SEXP iborTypeSEXP, SEXP evalDateSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< std::vector >::type termStrcDateVec(termStrcDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type termStrcZeroVec(termStrcZeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::DataFrame >::type swapDF(swapDFSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborDateVec(iborDateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type iborZeroVec(iborZeroVecSEXP);
Rcpp::traits::input_parameter< std::string >::type iborType(iborTypeSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type evalDate(evalDateSEXP);
rcpp_result_gen = Rcpp::wrap(calibrateHullWhiteUsingSwapsEngine(termStrcDateVec, termStrcZeroVec, swapDF, iborDateVec, iborZeroVec, iborType, evalDate));
return rcpp_result_gen;
END_RCPP
}
// europeanOptionImpliedVolatilityEngine
double europeanOptionImpliedVolatilityEngine(std::string type, double value, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, int dayCounter);
static SEXP _RQuantLib_europeanOptionImpliedVolatilityEngine_try(SEXP typeSEXP, SEXP valueSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type value(valueSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(europeanOptionImpliedVolatilityEngine(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, dayCounter));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_europeanOptionImpliedVolatilityEngine(SEXP typeSEXP, SEXP valueSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP dayCounterSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_europeanOptionImpliedVolatilityEngine_try(typeSEXP, valueSEXP, underlyingSEXP, strikeSEXP, dividendYieldSEXP, riskFreeRateSEXP, maturitySEXP, exDateSEXP, volatilitySEXP, dayCounterSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// americanOptionImpliedVolatilityEngine
double americanOptionImpliedVolatilityEngine(std::string type, double value, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volguess, int timesteps, int gridpoints, int dayCounter);
static SEXP _RQuantLib_americanOptionImpliedVolatilityEngine_try(SEXP typeSEXP, SEXP valueSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volguessSEXP, SEXP timestepsSEXP, SEXP gridpointsSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type value(valueSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volguess(volguessSEXP);
Rcpp::traits::input_parameter< int >::type timesteps(timestepsSEXP);
Rcpp::traits::input_parameter< int >::type gridpoints(gridpointsSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(americanOptionImpliedVolatilityEngine(type, value, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volguess, timesteps, gridpoints, dayCounter));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_americanOptionImpliedVolatilityEngine(SEXP typeSEXP, SEXP valueSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volguessSEXP, SEXP timestepsSEXP, SEXP gridpointsSEXP, SEXP dayCounterSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_americanOptionImpliedVolatilityEngine_try(typeSEXP, valueSEXP, underlyingSEXP, strikeSEXP, dividendYieldSEXP, riskFreeRateSEXP, maturitySEXP, exDateSEXP, volguessSEXP, timestepsSEXP, gridpointsSEXP, dayCounterSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// sabrengine
Rcpp::List sabrengine(Rcpp::List rparam, Rcpp::List legParams, std::vector dateVec, std::vector zeroVec, Rcpp::NumericVector swaptionMat, Rcpp::NumericVector swapLengths, Rcpp::NumericMatrix atmVols, Rcpp::NumericVector strikes, Rcpp::NumericMatrix smirkVols);
RcppExport SEXP _RQuantLib_sabrengine(SEXP rparamSEXP, SEXP legParamsSEXP, SEXP dateVecSEXP, SEXP zeroVecSEXP, SEXP swaptionMatSEXP, SEXP swapLengthsSEXP, SEXP atmVolsSEXP, SEXP strikesSEXP, SEXP smirkVolsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type rparam(rparamSEXP);
Rcpp::traits::input_parameter< Rcpp::List >::type legParams(legParamsSEXP);
Rcpp::traits::input_parameter< std::vector >::type dateVec(dateVecSEXP);
Rcpp::traits::input_parameter< std::vector >::type zeroVec(zeroVecSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swaptionMat(swaptionMatSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type swapLengths(swapLengthsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type atmVols(atmVolsSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericVector >::type strikes(strikesSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type smirkVols(smirkVolsSEXP);
rcpp_result_gen = Rcpp::wrap(sabrengine(rparam, legParams, dateVec, zeroVec, swaptionMat, swapLengths, atmVols, strikes, smirkVols));
return rcpp_result_gen;
END_RCPP
}
// CreateSchedule
Rcpp::DateVector CreateSchedule(Rcpp::List params);
static SEXP _RQuantLib_CreateSchedule_try(SEXP paramsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< Rcpp::List >::type params(paramsSEXP);
rcpp_result_gen = Rcpp::wrap(CreateSchedule(params));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_CreateSchedule(SEXP paramsSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_CreateSchedule_try(paramsSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// getQuantLibVersion
std::string getQuantLibVersion();
static SEXP _RQuantLib_getQuantLibVersion_try() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
rcpp_result_gen = Rcpp::wrap(getQuantLibVersion());
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_getQuantLibVersion() {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_getQuantLibVersion_try());
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// getQuantLibCapabilities
Rcpp::LogicalVector getQuantLibCapabilities();
static SEXP _RQuantLib_getQuantLibCapabilities_try() {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
rcpp_result_gen = Rcpp::wrap(getQuantLibCapabilities());
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_getQuantLibCapabilities() {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_getQuantLibCapabilities_try());
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// europeanOptionEngine
Rcpp::List europeanOptionEngine(std::string type, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, Rcpp::Nullable discreteDividends, Rcpp::Nullable discreteDividendsTimeUntil, int dayCounter);
static SEXP _RQuantLib_europeanOptionEngine_try(SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP discreteDividendsSEXP, SEXP discreteDividendsTimeUntilSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type discreteDividends(discreteDividendsSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type discreteDividendsTimeUntil(discreteDividendsTimeUntilSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(europeanOptionEngine(type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, discreteDividends, discreteDividendsTimeUntil, dayCounter));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_europeanOptionEngine(SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP discreteDividendsSEXP, SEXP discreteDividendsTimeUntilSEXP, SEXP dayCounterSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_europeanOptionEngine_try(typeSEXP, underlyingSEXP, strikeSEXP, dividendYieldSEXP, riskFreeRateSEXP, maturitySEXP, exDateSEXP, volatilitySEXP, discreteDividendsSEXP, discreteDividendsTimeUntilSEXP, dayCounterSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// americanOptionEngine
Rcpp::List americanOptionEngine(std::string type, double underlying, double strike, double dividendYield, double riskFreeRate, Rcpp::Nullable maturity, Rcpp::Nullable exDate, double volatility, int timeSteps, int gridPoints, std::string engine, Rcpp::Nullable discreteDividends, Rcpp::Nullable discreteDividendsTimeUntil, int dayCounter);
static SEXP _RQuantLib_americanOptionEngine_try(SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP timeStepsSEXP, SEXP gridPointsSEXP, SEXP engineSEXP, SEXP discreteDividendsSEXP, SEXP discreteDividendsTimeUntilSEXP, SEXP dayCounterSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< double >::type underlying(underlyingSEXP);
Rcpp::traits::input_parameter< double >::type strike(strikeSEXP);
Rcpp::traits::input_parameter< double >::type dividendYield(dividendYieldSEXP);
Rcpp::traits::input_parameter< double >::type riskFreeRate(riskFreeRateSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type exDate(exDateSEXP);
Rcpp::traits::input_parameter< double >::type volatility(volatilitySEXP);
Rcpp::traits::input_parameter< int >::type timeSteps(timeStepsSEXP);
Rcpp::traits::input_parameter< int >::type gridPoints(gridPointsSEXP);
Rcpp::traits::input_parameter< std::string >::type engine(engineSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type discreteDividends(discreteDividendsSEXP);
Rcpp::traits::input_parameter< Rcpp::Nullable >::type discreteDividendsTimeUntil(discreteDividendsTimeUntilSEXP);
Rcpp::traits::input_parameter< int >::type dayCounter(dayCounterSEXP);
rcpp_result_gen = Rcpp::wrap(americanOptionEngine(type, underlying, strike, dividendYield, riskFreeRate, maturity, exDate, volatility, timeSteps, gridPoints, engine, discreteDividends, discreteDividendsTimeUntil, dayCounter));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_americanOptionEngine(SEXP typeSEXP, SEXP underlyingSEXP, SEXP strikeSEXP, SEXP dividendYieldSEXP, SEXP riskFreeRateSEXP, SEXP maturitySEXP, SEXP exDateSEXP, SEXP volatilitySEXP, SEXP timeStepsSEXP, SEXP gridPointsSEXP, SEXP engineSEXP, SEXP discreteDividendsSEXP, SEXP discreteDividendsTimeUntilSEXP, SEXP dayCounterSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_americanOptionEngine_try(typeSEXP, underlyingSEXP, strikeSEXP, dividendYieldSEXP, riskFreeRateSEXP, maturitySEXP, exDateSEXP, volatilitySEXP, timeStepsSEXP, gridPointsSEXP, engineSEXP, discreteDividendsSEXP, discreteDividendsTimeUntilSEXP, dayCounterSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// europeanOptionArraysEngine
Rcpp::List europeanOptionArraysEngine(std::string type, Rcpp::NumericMatrix par);
static SEXP _RQuantLib_europeanOptionArraysEngine_try(SEXP typeSEXP, SEXP parSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::traits::input_parameter< std::string >::type type(typeSEXP);
Rcpp::traits::input_parameter< Rcpp::NumericMatrix >::type par(parSEXP);
rcpp_result_gen = Rcpp::wrap(europeanOptionArraysEngine(type, par));
return rcpp_result_gen;
END_RCPP_RETURN_ERROR
}
RcppExport SEXP _RQuantLib_europeanOptionArraysEngine(SEXP typeSEXP, SEXP parSEXP) {
SEXP rcpp_result_gen;
{
Rcpp::RNGScope rcpp_rngScope_gen;
rcpp_result_gen = PROTECT(_RQuantLib_europeanOptionArraysEngine_try(typeSEXP, parSEXP));
}
Rboolean rcpp_isInterrupt_gen = Rf_inherits(rcpp_result_gen, "interrupted-error");
if (rcpp_isInterrupt_gen) {
UNPROTECT(1);
Rf_onintr();
}
bool rcpp_isLongjump_gen = Rcpp::internal::isLongjumpSentinel(rcpp_result_gen);
if (rcpp_isLongjump_gen) {
Rcpp::internal::resumeJump(rcpp_result_gen);
}
Rboolean rcpp_isError_gen = Rf_inherits(rcpp_result_gen, "try-error");
if (rcpp_isError_gen) {
SEXP rcpp_msgSEXP_gen = Rf_asChar(rcpp_result_gen);
UNPROTECT(1);
(Rf_error)("%s", CHAR(rcpp_msgSEXP_gen));
}
UNPROTECT(1);
return rcpp_result_gen;
}
// zeroprice
double zeroprice(double yield, QuantLib::Date maturity, QuantLib::Date settle, int period, int basis);
RcppExport SEXP _RQuantLib_zeroprice(SEXP yieldSEXP, SEXP maturitySEXP, SEXP settleSEXP, SEXP periodSEXP, SEXP basisSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double >::type yield(yieldSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type settle(settleSEXP);
Rcpp::traits::input_parameter< int >::type period(periodSEXP);
Rcpp::traits::input_parameter< int >::type basis(basisSEXP);
rcpp_result_gen = Rcpp::wrap(zeroprice(yield, maturity, settle, period, basis));
return rcpp_result_gen;
END_RCPP
}
// zeroyield
double zeroyield(double price, QuantLib::Date maturity, QuantLib::Date settle, int period, int basis);
RcppExport SEXP _RQuantLib_zeroyield(SEXP priceSEXP, SEXP maturitySEXP, SEXP settleSEXP, SEXP periodSEXP, SEXP basisSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< double >::type price(priceSEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type maturity(maturitySEXP);
Rcpp::traits::input_parameter< QuantLib::Date >::type settle(settleSEXP);
Rcpp::traits::input_parameter< int >::type period(periodSEXP);
Rcpp::traits::input_parameter< int >::type basis(basisSEXP);
rcpp_result_gen = Rcpp::wrap(zeroyield(price, maturity, settle, period, basis));
return rcpp_result_gen;
END_RCPP
}
// validate (ensure exported C++ functions exist before calling them)
static int _RQuantLib_RcppExport_validate(const char* sig) {
static std::set signatures;
if (signatures.empty()) {
signatures.insert("double(*zeroPriceByYieldEngine)(double,double,double,double,double,double,QuantLib::Date,QuantLib::Date)");
signatures.insert("double(*zeroYieldByPriceEngine)(double,double,double,double,double,double,QuantLib::Date,QuantLib::Date)");
signatures.insert("double(*fixedRateBondYieldByPriceEngine)(double,double,std::string,double,double,double,double,double,double,QuantLib::Date,QuantLib::Date,QuantLib::Date,std::vector)");
signatures.insert("double(*fixedRateBondPriceByYieldEngine)(double,double,std::string,double,double,double,double,double,double,QuantLib::Date,QuantLib::Date,QuantLib::Date,std::vector)");
signatures.insert("Rcpp::List(*FloatBond1)(Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List)");
signatures.insert("Rcpp::List(*FloatBond2)(Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List)");
signatures.insert("Rcpp::List(*FloatBond3)(Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List)");
signatures.insert("Rcpp::List(*FloatBond4)(Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List,Rcpp::List)");
signatures.insert("Rcpp::List(*floatingWithRebuiltCurveEngine)(Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List,std::vector,std::vector,std::vector,std::vector,Rcpp::List)");
signatures.insert("Rcpp::List(*FixedRateWithYield)(Rcpp::List,std::vector,Rcpp::List,Rcpp::List,double)");
signatures.insert("Rcpp::List(*FixedRateWithPrice)(Rcpp::List,std::vector