I'm trying to bootstrap a zero curve using US Treasury products of maturity (1m, 2m, 3m, 6m, 1y, 2y, 3y, 5y, 7y, 10y, 20y, 30y). For the T-Bills, I'm using a DepositRateHelper but I don't see how to set the valuation date like I do with FixedBondRateHelper used by the Notes/Bonds. The problem is when I look at the nodes in the PiecewiseYieldCurve, the node dates are taken from the valuationDate of the DepositRateHelper, which is unavoidably set to DateTime.Today(). I want to be able to create a fixed reference date and perform curve calculations for prior dates.
For example, I have code that constructs a list of rateHelpers such as the 1mo T-Bill:
rateHelpers.Add(GetDepositRateHelper(new Period(1, TimeUnit.Months), (double)DailyTreasuryRates.Yield1Mo / 100));
Where the GetDepositRateHelper() method is
private DepositRateHelper GetDepositRateHelper(Period tenor, double treasuryYield)
{
return new DepositRateHelper(treasuryYield, tenor, 2, _calendar, _convention, false, _dayCounter);
}
As you can see, there's no way to set the fixed reference date for the helper so the evaluationDate when I inspect it is set to DateTime.Today.
When I inspect the discountFactors in the PiecewiseYieldCurve, it's clear that the evaluationDates from the DepositRateHelpers have been used and creates a mess:
Instead of 9/19/2022, 10/18/2022, 11/18/2022, 2/21/2023, the first four nodes should be placed on something like 5/2/2022, 6/2/2022, 7/2/2022, & 9/2/2022.
Can someone point me to the right process for using DepositRateHelpers in bootstrapping a zero curve with a fixed reference date?
You need to set the global evaluation date:
Settings.instance().setEvaluationDate(yourEvaluationDate);