Closed ilpxx closed 5 years ago
That is entirely correct and needs fixing in the examples -- I'll look into it.
Here is the earlier example with a (somewhat arbitrary) evaluation date:
R> #set-up a HullWhite according to example from QuantLib
R> HullWhite <- list(term = 0.055, alpha = 0.03, sigma = 0.01, gridIntervals = 40)
R> Price <- rep(as.double(100),24)
R> Type <- rep(as.character("C"), 24)
R> Date <- seq(as.Date("2006-09-15"), by = '3 months', length = 24)
R> callSch <- data.frame(Price, Type, Date)
R> callSch$Type <- as.character(callSch$Type)
R> bondparams <- list(faceAmount=100, issueDate = as.Date("2004-09-16"), maturityDate=as.Date("2012-09-16"), redemption=100, callSch = callSch)
R> dateparams <- list(settlementDays=3, calendar="UnitedStates/GovernmentBond", dayCounter = "ActualActual", period="Quarterly", businessDayConvention = "Unadjusted", terminationDateConvention= "Unadjusted")
R> coupon <- c(0.0465)
R> setEvaluationDate(as.Date("2008-09-20"))
[1] TRUE
R> CallableBond(bondparams, HullWhite, coupon, dateparams)
Concise summary of valuation for CallableBond
Net present value : 76.3318
clean price : 76.23
dirty price : 76.332
accrued coupon : 0.10164
yield : 0.12294
cash flows :
Date Amount
2004-12-16 1.1561
2005-03-16 1.1460
2005-06-16 1.1721
2005-09-16 1.1721
2005-12-16 1.1593
2006-03-16 1.1466
2006-06-16 1.1721
2006-09-16 1.1721
2006-12-16 1.1593
2007-03-16 1.1466
2007-06-16 1.1721
2007-09-16 1.1721
2007-12-16 1.1593
2008-03-16 1.1567
2008-06-16 1.1689
2008-09-16 1.1689
2008-12-16 1.1561
2009-03-16 1.1460
2009-06-16 1.1721
2009-09-16 1.1721
2009-12-16 1.1593
2010-03-16 1.1466
2010-06-16 1.1721
2010-09-16 1.1721
2010-12-16 1.1593
2011-03-16 1.1466
2011-06-16 1.1721
2011-09-16 1.1721
2011-12-16 1.1593
2012-03-16 1.1567
2012-06-16 1.1689
2012-09-16 1.1689
2012-09-16 100.0000
R>
We can close this as I fixed it in the sources which "soon" (== within days) get to CRAN.
I checked the other bond examples, they all seem to have an evaluation date set. If I missed one we can always open a new ticket.
What is the evaluation date? You need it to be during the life of the bond, so it may have defaulted to today, meaning bond has matured since the maturity is 2016.
Sent from my iPad
On Nov 27, 2018, at 11:03 AM, IlariaPastore notifications@github.com<mailto:notifications@github.com> wrote:
Hi,
I'm writing because I need a support asap concerning the callable bond evaluation code in RQuantLib. Actually, I run this code in R version 3.15.0 and the function "CallableBond" always returns zero (for NPV, cleanPrice, dirtyPrice, etc..). How can I fix this?
The code is the following:
set-up a HullWhite according to example from QuantLib
HullWhite <- list(term = 0.055, alpha = 0.03, sigma = 0.01, gridIntervals = 40)
callability schedule dataframe
Price <- rep(as.double(100),24) Type <- rep(as.character("C"), 24) Date <- seq(as.Date("2006-09-15"), by = '3 months', length = 24) callSch <- data.frame(Price, Type, Date) callSch$Type <- as.character(callSch$Type) bondparams <- list(faceAmount=100, issueDate = as.Date("2004-09-16"), maturityDate=as.Date("2012-09-16"), redemption=100, callSch = callSch) dateparams <- list(settlementDays=3, calendar="UnitedStates/GovernmentBond", dayCounter = "ActualActual", period="Quarterly", businessDayConvention = "Unadjusted", terminationDateConvention= "Unadjusted") coupon <- c(0.0465) CallableBond(bondparams, HullWhite, coupon, dateparams)
examples using default values
CallableBond(bondparams, HullWhite, coupon) dateparams <- list( period="Quarterly", businessDayConvention = "Unadjusted", terminationDateConvention= "Unadjusted") CallableBond(bondparams, HullWhite, coupon, dateparams) bondparams <- list(issueDate = as.Date("2004-09-16"), maturityDate=as.Date("2012-09-16") ) CallableBond(bondparams, HullWhite, coupon, dateparams)
Many thanks for the time.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/eddelbuettel/rquantlib/issues/124, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHBCohyxgpgFrz1gAoshi1Z4ZDQApwQ6ks5uzWJBgaJpZM4Y1zwE.