Re: Formula for the discount of a yield curve?
Posted by mihai.bunea on
URL: http://quantlib.414.s1.nabble.com/Formula-for-the-discount-of-a-yield-curve-tp6098p6100.html
Hello Peter,
thanks for your response.
I tried to use simple interest rate to explain the results of YieldTermStructure.discount() on the example described in my mail.
But:
- When using the YieldTermStructure to compute the discount for 1 year, the result is 0.424343 while simple InterestRate computes 1 / (1 + 1 * 365 / 365.0) = 1/2 = 0.5.
- When using the YieldTermStructure to compute the discount for 30 days, the result is 0.931969 while simple InterestRate computes 1 / (1 + 1 * 30 / 365.0) = 0.924051.
So it looks like the yield curve computation of discount() cannot be exaplaind by assuming simple interest rate.
I also tried using Compounded interest rate, as in the following code:
InterestRate *interestRateAnnual = new InterestRate(d1Quote, Actual365Fixed(), Compounded, Annual);
double discountFactorAnnual = interestRateAnnual ->discountFactor(elapsedTime);
InterestRate *interestRateDaily = new InterestRate(d1Quote, Actual365Fixed(), Compounded, Daily);
double discountFactorDaily = interestRateDaily ->discountFactor(elapsedTime);
Got the following results:
- computed by YieldTermStructure.discount(): 0.809476
- discountFactorAnnual: 0.842895
- discountFactorDaily: 0.781736 (close to Continuous compounding 1 / e^(r * t) = 1 / e^(1 * 90/365.0))
I also tried placing a breakpoint in the constructor of InterestRate with the intention to see if used inside YieldTermStructure.discount() - but the breakpoint never got hit so it seems the code doesn't use InterestRate for computation.
So it looks like YieldTermStructure.discount() does a computation of it's own, which doesn't fall on any known pattern. Perhaps it is a bug?
-----
P.S. Now i got into another source of confusement: QuantLib Compounded InterestRate results in the values presented above for annual and daily.
But replicating the result by hand, results in:
- annual: 1 / (1 + 1 / 1) ^ (1 * (90/365)) = 0.842895 (same as QuantLib)
- daily: 1 / (1 + 1 / 365) ^ (365 * (90/365)) = 0.7838777 (different from QuantLib!)
I have to dig deeper into these calculations...
Regards,
Mihai Bunea.