Re: Building the ZeroRate curve from deposit-futures-irs

Posted by Ferdinando M. Ametrano-3 on
URL: http://quantlib.414.s1.nabble.com/Building-the-ZeroRate-curve-from-deposit-futures-irs-tp5625p5626.html

Hi Luca

as far as I know there in no 3D deposit traded on the market, at least
not in the EUR market.

In the EUR market you can have SN (spot next: fixes today, starts in 2
working days, lasts 1 day), SW (spot week: fixes today, starts in 2
working days, lasts 1 week), 2W (2 weeks: fixes today, starts in 2
working days, lasts 2 weeks), 1M (1 month: fixes today, starts in 2
working days, lasts 1 months), nM (n month: fixes today, starts in 2
working days, lasts n months).

You might also have ON (overnight:  fixes today, starts today, lasts 1
day) and TN (tom-next:  starts tomorrow, lasts 1 day).

The star/end dates must be calculated taking into account holidays and
market convention (end-of-month, modified following, etc)

Details change for different currencies, e-g- for GBP spot=today, etc
but the global picture is not altered.

hope it helps

ciao -- Nando

On Tue, Mar 11, 2008 at 3:12 PM, luca ferraro <[hidden email]> wrote:

> Hello everybody,
>
>  I'm a new user of the QuantLib library and new to finance as well.
>
>  After having read the examples and the documentation, I have tried to
>  test my understanding of the libraryin reproducing a zero-rate curve I
>  previously built my own, starting from deposits, futures and IRSs data.
>
>  I cannot reproduce the zero-rate: rates are not correct from the
>  beginning, so I will focus on deposits. Neither the dates of the curve
>  (using the PieacewiseYieldCurve::dates() method) correspond to what I
>  expected from the instruments I gave, for example there is one more date
>  (28/11/2007) I don't know where it comes from (see the output I report
>  below).
>
>  I am also confused in how to describe the 1D 2D and 3D deposit in the
>  DepositRateHelper constructor. Which are the correct settlement and
>  fixing days? For a 1D deposit I expect settlement to be 0, fixing 1 and
>  tenor 1*Day, for a 2D deposit I expect settlement to be 1, fixing 2 and
>  tenor 1*Day. Why are settlement and fixing days both equal to 2 in 1W
>  deposit?
>
>  Can you help me in understanding what I did wrong? Here is what I
>  have done, based on the swapvaluation example.
>
>  Thank you all in advance,
>
>  luca lferraro
>  (luca _dot_ ferraro _at_ caspur _dot_ it)
>
>  ###############################
>  todaysDate: 22/11/2007
>
>  deposit:
>  1D 3.96
>  2D 4.06
>  3D 4.095
>  1W 4.15
>  ...
>  ...
>  futures:
>  DEC07 95-363
>  MAR08 95-365
>  ...
>  ...
>
>
>
>  After having constructed the Handles to deposit rates, here's what I
>  have done in describing the DepositRateHelpers:
>
>  // deposits
>  DayCounter depositDayCounter = Actual360();
>
>  // 1D deposit:
>  // start today (settlement=0), last 1 day, payment tomorrow
>  boost::shared_ptr<RateHelper> d1d(new DepositRateHelper(
>      Handle<Quote>(d1dRate), 1*Days, 1,
>      calendar, ModifiedFollowing,
>      true, 0, depositDayCounter));
>
>  // 2D deposit:
>  // start tomorrow(settlement=1), last 1 day, payment after tomorrow
>  boost::shared_ptr<RateHelper> d2d(new DepositRateHelper(
>      Handle<Quote>(d2dRate), 1*Days, 2,
>      calendar, ModifiedFollowing,
>      true, 1, depositDayCounter));
>
>  // 3D deposit:
>  // start after tomorrow(settlement=2), last 1 day, payment after 3 day
>  boost::shared_ptr<RateHelper> d3d(new DepositRateHelper(
>      Handle<Quote>(d3dRate), 1*Days, 3,
>      calendar, ModifiedFollowing,
>      true, 2, depositDayCounter));
>
>  fixingDays = 2;
>  // 1W deposit: from the swapvaluation example
>  // why are settlement and fixing days both equal two ??? <-- question
>  boost::shared_ptr<RateHelper> d1w(new DepositRateHelper(
>      Handle<Quote>(d1wRate), 1*Weeks, fixingDays,
>      calendar, ModifiedFollowing,
>      true, fixingDays, depositDayCounter));
>
>  ...
>  ...
>  // Prepare the vector of depo-futures-swap to build the YieldCurve
>  std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstruments;
>  depoFutSwapInstruments.push_back(d1d);
>  depoFutSwapInstruments.push_back(d2d);
>  depoFutSwapInstruments.push_back(d3d);
>  depoFutSwapInstruments.push_back(d1w);
>  ...
>  ...
>
>  Date todaysDate = Date(22, November, 2007);
>  Settings::instance().evaluationDate() = todaysDate;
>
>  Integer fixingDays = 1;
>  Date settlementDate=calendar.advance(todaysDate,fixingDays,Days);
>
>  // creating the YieldCurve
>  boost::shared_ptr<PieacewiseYieldCurve<Discount,LogLinear> >
>      depoFutSwapTermStructure(
>      new PiecewiseYieldCurve<Discount,LogLinear>(
>                settlementDate, depoFutSwapInstruments,
>                termStructureDayCounter, tolerance));
>
>  std::vector<Date> v = depoFutSwapTermStructure->dates();
>  for (unsigned i=0; i < v.size();i++) {
>      std::cout << "Date: " << v[i].weekday() << ", " << v[i]
>      << " rate: " << depoFutSwapTermStructure->
>          zeroRate(v[i],termStructureDayCounter,Continuous)
>      << std::endl;
>  }
>
>  ###################
>  OUTPUT OF THE CODE:
>  Today: Thursday, November 22nd, 2007
>  Settlement date: Friday, November 23rd, 2007
>
>  Date: Friday, November 23rd, 2007 rate: 4.014338 %
>  Date: Monday, November 26th, 2007 rate: 4.014338 % <-- the same rate?
>  Date: Tuesday, November 27th, 2007 rate: 4.039792 %
>  Date: Wednesday, November 28th, 2007 rate: 4.062162 % <-- hum !?!
>  Date: Monday, December 3rd, 2007 rate: 4.148461 %
>
>  ##################
>  What I expected:
>  Date:     Days:  Rate:
>  23/11/2007  1  4.01478
>  26/11/2007  4  4.09046
>  27/11/2007  5  4.10270
>  03/12/2007 11  4.16395
>
>  These values comes out from considering that:
>
>  starting date: 22/11/2007
>
>  November 2007         December 2007
>  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
>            1  2  3  4                  1  2
>   5  6  7  8  9 10 11   3  4  5  6  7  8  9
>  12 13 14 15 16 17 18  10 11 12 13 14 15 16
>  19 20 21 22 23 24 25  17 18 19 20 21 22 23
>  26 27 28 29 30        24 25 26 27 28 29 30
>                        31
>
>  1D 22/11/2007 -> 23/11/2007
>
>  2D 22/11/2007 -> (24,25) -> 26/11/2007
>
>  3D 22/11/2007 -> (24,25) -> -> 27/11/2007
>
>  1W 22/11/2007 -> (24,25) -> -> -> -> -> (1,2)
>                ->  03/12/2007
>
>  and that I have built the zero rates considering that:
>  1D: exp^{Z_{1d}*(1/365)} = {1+R_{1D}*(1/360)}
>  2D: exp^{Z_{4d}*(4/365)} = {1+R_{2D}*(3/360)}*exp^{Z_{1d}*(1/365)}
>  ...
>  and so on
>
>
>
>
>  -------------------------------------------------------------------------
>  This SF.net email is sponsored by: Microsoft
>  Defy all challenges. Microsoft(R) Visual Studio 2008.
>  http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>  _______________________________________________
>  QuantLib-users mailing list
>  [hidden email]
>  https://lists.sourceforge.net/lists/listinfo/quantlib-users
>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users