Fair Rate of Overnight Indexed Swap
Posted by Fabio on
URL: http://quantlib.414.s1.nabble.com/Fair-Rate-of-Overnight-Indexed-Swap-tp15053.html
Hi,
I got stuck into this problem.
My purpose is to compute the fair rate of an Eonia OIS with start date 13 December 2012 and maturity 14 January 2013. I guess the discount curve is properly build and the OIS is correctly defined, nontheless, after calling the method fairRate(), the returned value is -1.#IND.
I'm quite new to QuantLib and not able to work this problem around.
Can anyone help me, please?
Thank you!
#pragma warning(disable:4996)
#include <iostream>
#include <ql/quantlib.hpp>
using namespace std;
using namespace boost;
using namespace QuantLib;
int main(){
Calendar calendar = TARGET();
Date today(11, December, 2012);
Eonia eonia;
DayCounter eonia_dc = eonia.dayCounter();
Natural settlementDays = 2;
Date settlementDate = calendar.advance(today, settlementDays, Days);
Date d2_1m(14, January, 2013);
// DISCOUNTING CURVE CONSTRUCTION
vector<Date> dates(0);
vector<DiscountFactor> discountFactor(0);
dates.push_back(settlementDate);
dates.push_back(d2_1m);
discountFactor.push_back(1.0);
discountFactor.push_back(0.95);
InterpolatedDiscountCurve <LogLinear> eoniaCurve(dates, discountFactor, eonia_dc, calendar);
boost::shared_ptr<YieldTermStructure> OisCurve;
OisCurve = boost::shared_ptr<YieldTermStructure>(new InterpolatedDiscountCurve <LogLinear>(dates, discountFactor, eonia_dc, calendar));
Handle<YieldTermStructure> discountingTermStructure(OisCurve);
boost::shared_ptr<OvernightIndex> eoniaIndex(new Eonia(discountingTermStructure));
// SOME OIS CHARACTERISTICS
Real nominal = 100000.0;
Spread spread = 0.0;
Rate fixedRate = 0.00074;
OvernightIndexedSwap::Type type = OvernightIndexedSwap::Payer;
Frequency legFrequency = Annual;
BusinessDayConvention legConvention = Unadjusted;
Schedule schedule(settlementDate, d2_1m, Period(legFrequency), calendar, legConvention, legConvention,
DateGeneration::Forward, false);
OvernightIndexedSwap ois_swap(type, nominal, schedule, fixedRate, eonia_dc, eoniaIndex, spread);
// FAIR RATE CALCULATION
Rate fairRate = 0.0;
fairRate = ois_swap.fairRate();
cout << "Fair Rate: " << fairRate << endl;
getchar();
return 0;
}