QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

Negative rates

Open Mfan85 opened this issue 3 years ago • 6 comments

Hello all,

I'm new to R-Quantlib so trying to learn by examples.

I've just started with the sample below with the objective of pricing a ZCB given a swap structure with the first part having negative rates. I get the following error "Error in ZeroBondWithRebuiltCurve(bond, c(discountCurve$table$date), discountCurve$table$zeroRates, : invalid value (-0.0393288) at index 0" which seems related to the negative rates. Any idea if the RQuantlib version can handle negative rates?


params <- list(tradeDate=as.Date('2004-09-20'),
               settleDate=as.Date('2004-09-22'),
               dt=.25,
               interpWhat= "discount",
               interpHow="linear")
setEvaluationDate(as.Date("2004-09-20"))

## We got numerical issues for the spline interpolation if we add
## any on of these three extra futures, at least with QuantLib 0.9.7
## The curve data comes from QuantLib's Examples/Swap/swapvaluation.cpp
## Removing s2y helps, as kindly pointed out by Luigi Ballabio


tsQuotes <- list( 
                  s2y = -0.037125,  
                  s3y = 0.0398,
                  s5y = 0.0443,
                  s10y = 0.05165,
                  s15y = 0.055175)
times <- seq(0,10,.1)

setEvaluationDate(params$tradeDate)
discountCurve <- DiscountCurve(params, tsQuotes, times)

# price a zero coupon bond
bondparams <- 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=4)
ZeroCouponBond(bondparams, discountCurve, dateparams)

Mfan85 avatar Aug 05 '22 16:08 Mfan85

Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.

boring-cyborg[bot] avatar Aug 05 '22 16:08 boring-cyborg[bot]

@eddelbuettel — pinging you since I'm not sure that you monitor this channel. Thanks!

lballabio avatar Aug 05 '22 17:08 lballabio

Grazie Luigi

Appreciate your help since I'm struggling with this one. I saw some "solutions" like recompiling in cpp but I'm not familiar with this procedure.

Il ven 5 ago 2022, 19:27 Luigi Ballabio @.***> ha scritto:

@eddelbuettel https://github.com/eddelbuettel — pinging you since I'm not sure that you monitor this channel. Thanks!

— Reply to this email directly, view it on GitHub https://github.com/lballabio/QuantLib/issues/1449#issuecomment-1206682710, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2MO6WWMKEPTSHIRQ7WSX2TVXVFHFANCNFSM55WTPGHA . You are receiving this because you authored the thread.Message ID: @.***>

Mfan85 avatar Aug 05 '22 17:08 Mfan85

Hi there. The RQuantLib "port" of (parts of) QuantLib to R has its own repo here: https://github.com/eddelbuettel/rquantlib We also have a (fairly slow) mailing list you could try: https://groups.io/g/rquantlib/topics

The Fixed Income routines were all contributed and "mostly" derived from the QuantLib C++ examples. They should work, but there can of course be sticky issues. From the top of my head, I think it should deal with negative rates as QL does but I don't have "proof".

eddelbuettel avatar Aug 05 '22 20:08 eddelbuettel

Hi Dirk,

Thank you for your help. I'll try to rise the question in the groups you provided.

Best regards.

Mfan85 avatar Aug 06 '22 06:08 Mfan85

I just 'cleared' your flag as first-time poster (a common spam check) so the post is up, and I hope someone can help you. Replies and new posts by you will now go through immediately.

eddelbuettel avatar Aug 06 '22 14:08 eddelbuettel

This issue was automatically marked as stale because it has been open 60 days with no activity. Remove stale label or comment, or this will be closed in two weeks.

github-actions[bot] avatar Oct 06 '22 02:10 github-actions[bot]