|
From: Luigi B. <lui...@gm...> - 2020-11-26 09:15:30
|
Hello Brian,
the ZeroCurve class expects the passed rates to be consistent, so no,
you won't get the correct curve this way (and anyway, you're
explicitly passing Continuous to the curve, so you're telling it that those
rates are continuously compounded).
You can either convert some of your rates so that they are all annually
compounded (or all simple, or all continuous) and pass to ZeroCurve the
corresponding compounding; or it might be simple to calculate the
corresponding discount factors and use DiscountCurve instead. You can do
it by writing something like:
spotDates = [
todaysDate,
todaysDate + Period("6m"),
todaysDate + Period("1y"),
todaysDate + Period("2y"),
todaysDate + Period("3y")
]
discounts = [
1.0,
InterestRate(0.061682, dayCount, Simple,
NoFrequency).discountFactor(todaysDate, todaysDate + Period("6m")),
InterestRate(0.066682, dayCount, Simple,
NoFrequency).discountFactor(todaysDate, todaysDate + Period("1y")),
InterestRate(0.067199, dayCount, Compounded,
Annual).discountFactor(todaysDate, todaysDate + Period("2y")),
InterestRate(0.067502, dayCount, Compounded,
Annual).discountFactor(todaysDate, todaysDate + Period("3y")),
]
spotCurve = DiscountCurve(spotDates, discounts, dayCount)
Hope this helps,
Luigi
On Tue, Nov 24, 2020 at 9:26 PM Brian Smith <bri...@gm...>
wrote:
> Hi,
>
> Typically we build interest rate term structure as below -
>
> from QuantLib import *
> import math
>
> todaysDate = Date(1, 9, 2019)
> Settings.instance().evaluationDate = todaysDate
> dayCount = Actual365Fixed()
> calendar = Canada()
> interpolation = Linear()
> compounding = Compounded
> compoundingFrequency = Continuous
>
> spotDates = [todaysDate, todaysDate + Period("6m"), todaysDate +
> Period("1y"), todaysDate + Period("2y"), todaysDate + Period("3y")]
> spotRates = [0, 0.061682, 0.066682, 0.067199, 0.067502]
>
> spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar,
> interpolation, compoundingFrequency)
> spotCurveHandle = YieldTermStructureHandle(spotCurve)
>
> However in my spotRates object, the interest rates upto 1 year i.e.
> [0.061682, 0.066682] are defined as simple interest, however for the
> remaining cases it is Annually compounded.
>
> Under this scenario, is the building term structure using the above
> approach still correct?
>
> Your insight is highly appreciated.
>
> Many thanks,
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|