New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure bond examples have evaluation dates set #124

Closed
ilpxx opened this Issue Nov 27, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@ilpxx
Copy link

ilpxx commented Nov 27, 2018

No description provided.

@ilpxx ilpxx changed the title RQuantLib - Callable Bond support asap RQuantLib Nov 27, 2018

@tleitch

This comment has been minimized.

Copy link
Contributor

tleitch commented Nov 27, 2018

@eddelbuettel

This comment has been minimized.

Copy link
Owner

eddelbuettel commented Nov 28, 2018

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>

@eddelbuettel eddelbuettel changed the title RQuantLib Ensure bond examples have evaluation dates set Nov 28, 2018

@eddelbuettel

This comment has been minimized.

Copy link
Owner

eddelbuettel commented Dec 8, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment