# How to manage evaluation date changes in QuantLib while using ImpliedTermStructure Class

I will not attach the whole code 'cause it would be just a huge waste of space and it would be not useful for this question's purpose.

What I am going to attach here is a snippet code and its output, which shows what I'm not able to understand.

The output

Today is November 29th, 2013
Settlement date is December 4th, 2013
Evaluation date is November 29th, 2013

Actual and implied curve evaluated at November 29th, 2013
The reference date is December 4th, 2013 for the Actual curve
The reference date is June 3rd, 2014 for the Implied curve

---- Actual ----- Implied

1 - 0.995917 --- 0.995485
2 - 0.990663 --- 0.987753
3 - 0.981329 --- 0.975887
4 - 0.966947 --- 0.959062
5 - 0.947756 --- 0.938374
6 - 0.925654 --- 0.914803
7 - 0.900713 --- 0.889055
8 - 0.874264 --- 0.862391
9 - 0.847481 --- 0.835015
10 - 0.819623 --- 0.806789

We've just amended the evaluation date from November 29th, 2013 to May 29th, 2014

Actual and implied curve evaluated at May 29th, 2014
The reference date is June 3rd, 2014 for the Actual curve
The reference date is June 3rd, 2014 for the Implied curve

---- Actual ----- Implied

1 - 0.995917 --- 0.995917
2 - 0.990673 --- 0.990673
3 - 0.981353 --- 0.981353
4 - 0.966986 --- 0.966986
5 - 0.947756 --- 0.947756
6 - 0.925689 --- 0.925689
7 - 0.900707 --- 0.900707
8 - 0.874121 --- 0.874121
9 - 0.847552 --- 0.847552
10 - 0.819667 --- 0.819667


This output shows that, if your evaluation date is equal to November 29th, 2013 and you ask for an implied term structure whose reference date is on June 3rd, 2014, you get two curves that are different, as you would expect.

But, if you amend the evaluation date setting it to June 3rd, 2014 and ask for the implied term structure, the latter changes its shape.

The snippet code

...
// +---------------------------------
// | Dates at which to forecast term structures
// +---------------------------------

Period forwardPeriod = 6 * Months;

Date forwardSettlementDate = calendar.advance(forwardDate, settlementDays, Days);

// +---------------------------------
// | Implied term structure
// +---------------------------------

boost::shared_ptr<YieldTermStructure> impliedDiscountCurve(new ImpliedTermStructure(    actualDiscountCurve,        // Handle<YieldTermStructure>
forwardSettlementDate       // Date referenceDate
));

// +---------------------------------
// | Printing today's discount factors
// +---------------------------------

std::cout << std::endl;
std::cout << "Actual and implied curve evaluated at " << todaysDate << std::endl;
std::cout << "The reference date is " << actualDiscountCurve->referenceDate() << " for the Actual curve" << std::endl;
std::cout << "The reference date is " << impliedDiscountCurve->referenceDate() << " for the Implied curve" << std::endl;
std::cout << std::endl;
std::cout << "---- Actual ----- Implied" << std::endl;
std::cout << std::endl;

for(Time d = 1; d <= 10.0; d+= 1.0)
{
std::cout << d << " - " << depoSwapTermStructure->discount(d) << " --- " << impliedDiscountCurve->discount(d) << std::endl;
}

// +---------------------------------
// | Evaluate the bond with the implied curve at forward date
// +---------------------------------

Settings::instance().evaluationDate() = forwardDate;
std::cout << std::endl;
std::cout << "We've just amended the evaluation date from " << todaysDate << " to " << forwardDate << std::endl;

// +---------------------------------
// | Printing discount factors at forward date
// +---------------------------------

std::cout << std::endl;
std::cout << "Actual and implied curve evaluated at " << forwardDate << std::endl;
std::cout << "The reference date is " << actualDiscountCurve->referenceDate() << " for the Actual curve" << std::endl;
std::cout << "The reference date is " << impliedDiscountCurve->referenceDate() << " for the Implied curve" << std::endl;
std::cout << std::endl;
std::cout << "---- Actual ----- Implied" << std::endl;
std::cout << std::endl;

for(Time d = 1; d <= 10.0; d+= 1.0)
{
std::cout << d << " - " << depoSwapTermStructure->discount(d) << " --- " << impliedDiscountCurve->discount(d) << std::endl;

...


My question is related to my goal, which I briefly describe in the following points:

1. with the evaluation date equal to today, I want to get the implied term structure with reference date equal to today + 6M;
2. with the evaluation date equal to today + 6M, I want to price a bond whose DiscountingBondEngine() uses the implied term structure above;
3. this would allow me to estimate a kind of "Theta" for the bond according to a forecast (*) of the discount curve and not of a constant curve.

Anyone could clarify how to do such a thing without having a completely changed implied term structure after the evaluation date amending?

(*) Actually, the forecast coming from the forward rates curve.

-

It's hard to be sure without seeing the inputs, but I'm guessing that the implied curve changes shape because the original curve does (which you can see from your output: except for the 1-year and 5-years points, the actual discounts are different).

The reason the original curve changes is probably the different position of weekends or holidays (so that, for instance, the 1-month deposit might span 30, 31 or 32 calendar days); when you move the evaluation date, the actual curve uses the same rates over slightly different tenors which causes the discount factors to come out different.

The implied curve is not so smart that it takes this into account; as you probably saw from its implementation, it's just a rescaling of the discount factors so that the discount factor at the new reference date is 1. Therefore, when the evaluation date is at today, it has the same shape as the original curve, and not the shape that the original curve would have at today+6M; when the evaluation date moves, the implied curve takes the new shape of the actual curve (as a matter of fact, it equals the actual curve).

If you want the implied curve to maintain the same shape, you have to force the original curve to do the same. The way to do it depends on what specific term-structure class you're using; but for most of them, one workable solution should be to prevent the reference date of the original curve to move when you move the evaluation date. Instead of using the constructor that takes a number of settlement days and a calendar (as I'm guessing you're doing now) try using the one that takes an explicit reference date. The curve you'll build this way will keep that same reference date (and thus its shape) when the evaluation date changes, and in turn this should conserve the shape of the implied curve.

More information on the way that term structures move with the evaluation date is at http://implementingquantlib.blogspot.com/2013/09/chapter-3-part-1-of-n-term-structures.html.

Oh, and thanks for the question. You just gave me one of my next blog posts...

-
Luigi, can you clarify this doubt? If I build the curve using the constructor that takes an explicit reference date, then I move the evaluation date 6M-forward and finally I price a bond with this new evaluation date, is this equivalent to pricing the bond on the implied curve today+6M? (And of course with 6M-less time to maturity for the bond) –  Enrico Detoma Dec 2 '13 at 9:07
It depends. The cleanPrice and dirtyPrice methods discount to the settlement date (which moves with the evaluation date) and thus would return the same figures as when using the implied curve. On the other hand, the NPV method discounts to the reference date of the curve, so the result would be different. But even if it worked, it feels more like an unintended side effect than like something I'd document... –  Luigi Ballabio Dec 2 '13 at 9:13