Re: Swap valution with eurodollar futures

Posted by Ferdinando M. Ametrano-3 on
URL: http://quantlib.414.s1.nabble.com/Swap-valution-with-eurodollar-futures-tp6459p6466.html

Hi Ramji

without going into further detailed examination, I wonder what is the
reference date you should work with: Settlement date: Saturday,
January 1st, 2005 is wrong for sure.
Do you really want to use TARGET calendar ? Is Fabozzi's example EUR or USD ?

If you're really into this example and need help you might consider
attaching a scan of the relevant Fabozzi pages...

ciao -- Nando

RSS feed: http://www.google.com/reader/shared/ferdinando.ametrano



On Thu, Dec 10, 2009 at 3:54 AM,  <[hidden email]> wrote:

> Faboozi
>  First column is Floating Cash flow at End of Quarter, and last column is PV
> of cash flow.
> Amount: 1012500-----Rate:0.0405----Days: 90 --- 1002351 (PV of Cash Flow)
> Amount: 1049028-----Rate:0.0415----Days: 91 --- 1027732
> Amount: 1162778-----Rate:0.0455----Days: 92 --- 1126079
> Amount: 1206222-----Rate:0.0475----Days: 92 --- 1154229
> Amount: 1225000-----Rate:0.0490----Days: 90 --- 1158012
> Amount: 1271472-----Rate:0.0503----Days: 91 --- 1186852
> Amount: 1316111-----Rate:0.0515----Days: 92 --- 1212562
> Amount: 1341667-----Rate:0.0525----Days: 92 --- 1219742
> Amount: 1350500-----Rate:0.0540----Days: 90 --- 1210970
> Amount: 1390278-----Rate:0.0550----Days: 91 --- 1229999
> Amount: 1443889-----Rate:0.0565----Days: 92 --- 1259248
> Amount: 1472000-----Rate:0.0576----Days: 92 --- 1265140
> Quantlib results:
> Today: Thursday, December 30th, 2004
> Settlement date: Saturday, January 1st, 2005
> Amount: 1.01227e+006-----Rate: 0.0404909-----Days: 90
> Amount: 1.03979e+006-----Rate: 0.0411346-----Days: 91
> Amount: 1.07986e+006-----Rate: 0.0422554-----Days: 92
> Amount: 1.16847e+006-----Rate: 0.0457227-----Days: 92
> Amount: 1.18679e+006-----Rate: 0.0474715-----Days: 90
> Amount: 1.24657e+006-----Rate: 0.0493149-----Days: 91
> Amount: 1.28915e+006-----Rate: 0.0504450-----Days: 92
> Amount: 1.31987e+006-----Rate: 0.0516471-----Days: 92
> Amount: 1.31777e+006-----Rate: 0.0527107-----Days: 90
> Amount: 1.36803e+006-----Rate: 0.0541197-----Days: 91
> Amount: 1.41024e+006-----Rate: 0.0551835-----Days: 92
> Amount: 1.44831e+006-----Rate: 0.0566731-----Days: 92
> int main(int, char* []) {
>     try {
>         boost::timer timer;
>         std::cout << std::endl;
>         /*********************
>          ***  MARKET DATA  ***
>          *********************/
>         Calendar calendar = TARGET();
>         Date settlementDate(1, January, 2005);
>
>         Integer fixingDays = 2;
>         Date todaysDate = calendar.advance(settlementDate, -fixingDays,
> Days);
>         // nothing to do with Date::todaysDate
>         Settings::instance().evaluationDate() = todaysDate;
>         todaysDate = Settings::instance().evaluationDate();
>         std::cout << "Today: " << todaysDate.weekday()
>                   << ", " << todaysDate << std::endl;
>         std::cout << "Settlement date: " << settlementDate.weekday()
>                   << ", " << settlementDate << std::endl;
>         // deposits
>         Rate d3mQuote=0.0405;
>         // futures
>         Real fut1Quote=95.85;
>         Real fut2Quote=95.45;
>         Real fut3Quote=95.28;
>         Real fut4Quote=95.10;
>         Real fut5Quote=94.97;
>         Real fut6Quote=94.85;
>         Real fut7Quote=94.75;
>         Real fut8Quote=94.60;
>  Real fut9Quote=94.50;
>  Real fut10Quote=94.35;
>  Real fut11Quote=94.24;
>         // deposits
>         boost::shared_ptr<Quote> d3mRate(new SimpleQuote(d3mQuote));
>         // futures
>         boost::shared_ptr<Quote> fut1Price(new SimpleQuote(fut1Quote));
>         boost::shared_ptr<Quote> fut2Price(new SimpleQuote(fut2Quote));
>         boost::shared_ptr<Quote> fut3Price(new SimpleQuote(fut3Quote));
>         boost::shared_ptr<Quote> fut4Price(new SimpleQuote(fut4Quote));
>         boost::shared_ptr<Quote> fut5Price(new SimpleQuote(fut5Quote));
>         boost::shared_ptr<Quote> fut6Price(new SimpleQuote(fut6Quote));
>         boost::shared_ptr<Quote> fut7Price(new SimpleQuote(fut7Quote));
>         boost::shared_ptr<Quote> fut8Price(new SimpleQuote(fut8Quote));
>  boost::shared_ptr<Quote> fut9Price(new SimpleQuote(fut9Quote));
>         boost::shared_ptr<Quote> fut10Price(new SimpleQuote(fut10Quote));
>  boost::shared_ptr<Quote> fut11Price(new SimpleQuote(fut11Quote));
>         DayCounter depositDayCounter = Actual360();
>         boost::shared_ptr<RateHelper> d3m(new DepositRateHelper(
>             Handle<Quote>(d3mRate),
>             3*Months, fixingDays,
>             calendar, Unadjusted,
>             true, depositDayCounter));
>         // setup futures
>         Integer futMonths = 3;
>         Date imm = IMM::nextDate(settlementDate);
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut1(new FuturesRateHelper(
>             Handle<Quote>(fut1Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>            true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut2(new FuturesRateHelper(
>             Handle<Quote>(fut2Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut3(new FuturesRateHelper(
>             Handle<Quote>(fut3Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut4(new FuturesRateHelper(
>             Handle<Quote>(fut4Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut5(new FuturesRateHelper(
>             Handle<Quote>(fut5Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut6(new FuturesRateHelper(
>             Handle<Quote>(fut6Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut7(new FuturesRateHelper(
>             Handle<Quote>(fut7Price),
>             imm,
>             futMonths, calendar, Unadjusted,
>             true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut8(new FuturesRateHelper(
>              Handle<Quote>(fut8Price),
>              imm,
>              futMonths, calendar, ModifiedFollowing,
>              true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut9(new FuturesRateHelper(
>              Handle<Quote>(fut9Price),
>              imm,
>              futMonths, calendar, ModifiedFollowing,
>              true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut10(new FuturesRateHelper(
>              Handle<Quote>(fut10Price),
>              imm,
>              futMonths, calendar, ModifiedFollowing,
>              true, depositDayCounter));
>         imm = IMM::nextDate(imm+1);
>         boost::shared_ptr<RateHelper> fut11(new FuturesRateHelper(
>              Handle<Quote>(fut11Price),
>              imm,
>              futMonths, calendar, ModifiedFollowing,
>              true, depositDayCounter));
>         DayCounter termStructureDayCounter = Actual360();
>
>         double tolerance = 1.0e-15;
>         // A depo-futures-swap curve
>         std::vector<boost::shared_ptr<RateHelper> > depoFutSwapInstruments;
>         depoFutSwapInstruments.push_back(d3m);
>         depoFutSwapInstruments.push_back(fut1);
>         depoFutSwapInstruments.push_back(fut2);
>         depoFutSwapInstruments.push_back(fut3);
>         depoFutSwapInstruments.push_back(fut4);
>         depoFutSwapInstruments.push_back(fut5);
>         depoFutSwapInstruments.push_back(fut6);
>         depoFutSwapInstruments.push_back(fut7);
>         depoFutSwapInstruments.push_back(fut8);
>  depoFutSwapInstruments.push_back(fut9);
>  depoFutSwapInstruments.push_back(fut10);
>  depoFutSwapInstruments.push_back(fut11);
>         boost::shared_ptr<YieldTermStructure> depoFutSwapTermStructure(
>             new PiecewiseYieldCurve<Discount, Linear>(
>                              settlementDate, depoFutSwapInstruments,
>                              termStructureDayCounter,
>                              std::vector<Handle<Quote> >(),
>                              std::vector<Date>(),
>                              tolerance));
>         RelinkableHandle<YieldTermStructure> discountingTermStructure;
>         RelinkableHandle<YieldTermStructure> forecastingTermStructure;
>         // constant nominal 100,000,000 Euro
>         Real nominal = 100000000.0;
>         // fixed leg
>         Frequency fixedLegFrequency = Quarterly;
>         BusinessDayConvention fixedLegConvention = Unadjusted;
>         BusinessDayConvention floatingLegConvention = Unadjusted;
>         DayCounter fixedLegDayCounter = Thirty360(Thirty360::European);
>         Rate fixedRate = 0.0498;
>         DayCounter floatingLegDayCounter = Actual360();
>         // floating leg
>         Frequency floatingLegFrequency = Quarterly;
>         boost::shared_ptr<IborIndex> euriborIndex(
>                           new Euribor3M(forecastingTermStructure));
>         Spread spread = 0.0;
>         Integer lenghtInYears = 3;
>         VanillaSwap::Type swapType = VanillaSwap::Payer;
>         Date maturity = settlementDate + lenghtInYears*Years;
>         Schedule fixedSchedule(settlementDate, maturity,
>                                        Period(fixedLegFrequency),
>                                        calendar, fixedLegConvention,
>                                        fixedLegConvention,
>                                        DateGeneration::Forward, false);
>         Schedule floatSchedule(settlementDate, maturity,
>                                        Period(floatingLegFrequency),
>                                        calendar, floatingLegConvention,
>                                        floatingLegConvention,
>                                        DateGeneration::Forward, false);
>         VanillaSwap spot3YearSwap(swapType, nominal,
>                     fixedSchedule, fixedRate, fixedLegDayCounter,
>                     floatSchedule, euriborIndex, spread,
>                     floatingLegDayCounter);
>         boost::shared_ptr<PricingEngine> swapEngine(
>                                  new DiscountingSwapEngine
> (discountingTermStructure));
>         spot3YearSwap.setPricingEngine(swapEngine);
>         // Of course, you're not forced to really use different curves
>         forecastingTermStructure.linkTo(depoFutSwapTermStructure);
>         discountingTermStructure.linkTo(depoFutSwapTermStructure);
>         const Leg& floatingCoupons = spot3YearSwap.floatingLeg();
>         for (Size i = 0; i < floatingCoupons.size(); ++i){
>              boost::shared_ptr<IborCoupon> coupon1 =
> boost::dynamic_pointer_cast<IborCoupon>(floatingCoupons[i]);
>         std::cout << "Amount: " << coupon1->amount();
>         std::cout << "-----" << "Rate: " << coupon1->rate();
>         std::cout << "-----" << "Days: " << coupon1->accrualDays() <<
> std::endl;
>        }
>        return 0;
>      } catch (std::exception& e) {
>          std::cout << e.what() << std::endl;
>          return 1;
>      } catch (...) {
>          std::cout << "unknown error" << std::endl;
>           return 1;
>      }
>   }
>
>
>
> -----Original Message-----
> From: Luigi Ballabio <[hidden email]>
> To: [hidden email]
> Cc: [hidden email]
> Sent: Wed, Dec 9, 2009 9:08 am
> Subject: Re: [Quantlib-users] Swap valution with eurodollar futures
>
> On Mon, 2009-12-07 at 23:48 -0500, [hidden email] wrote:
>> I am trying to replicate an example from Fabozzi's book. This is to
>>  price a 3 year swap with fixed rate 4.98% and
>>          // deposits
>>         Rate d3mQuote=0.0405;
>>
>>         // futures
>>         Real fut1Quote=95.85;
>>         Real fut2Quote=95.45;
>>         Real fut3Quote=95.28;
>>         Real fut4Quote=95.10;
>>         Real fut5Quote=94.97;
>>         Real fut6Quote=94.85;
>>         Real fut7Quote=94.75;
>>         Real fut8Quote=94.60;
>>         Real fut9Quote=94.50;
>>         Real fut10Quote=94.35;
>>         Real fut11Quote=94.24;
>> I followed the swap valuation example provided in Quantlib
>> documentation (dep-future). But the value of the cash flows are
>> different from Fabozzi's book. Coupon rates are also different from
>> second quarter onwards.  For example quantlib computed cupon rate for
>> 3rd quarter was 4.20 instead of 4.55 recorded in the book.
>
> Do you have more details?  For instance, how do you extract coupon rates
> from QuantLib? And what does Fabozzi do?
>
> Luigi
>
>
>
> --
>
> Vin: It's like this fellow I knew in El Paso. One day, he just took
> all his clothes off and jumped in a mess of cactus. I asked him that
> same question, "Why?"
> Calvera: And?
> Vin: He said, "It seemed like a good idea at the time."
> -- The Magnificent Seven
>
>
>
> ------------------------------------------------------------------------------
> Return on Information:
> Google Enterprise Search pays you back
> Get the facts.
> http://p.sf.net/sfu/google-dev2dev
>
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
>

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users