|
From: laaouini a. <laa...@ya...> - 2017-12-01 14:35:21
|
Yes, I do it in the following way:
Date today(14, February, 2000);
boost::shared_ptr<IborIndex> makeIndex(std::vector<Date> dates, std::vector<DiscountFactor> discountfactors) { DayCounter dayCounter = Actual360();//Actual360(); RelinkableHandle<YieldTermStructure> termStructure; boost::shared_ptr<IborIndex> index(new Euribor6M(termStructure)); Date todaysDate = index->fixingCalendar().adjust(today); cout << "todaysDate " << todaysDate << endl; Settings::instance().evaluationDate() = todaysDate; for(int i=0;i<dates.size();i++) dates[i] = index->fixingCalendar().advance(dates[i],index->fixingDays(), Days); cout << "dates[0] " << dates[0] << endl; try {
//new ZeroCurve(dates, rates, dayCounter);
Calendar calendar = Calendar(); std::vector<Handle<Quote> > jumps = std::vector<Handle<Quote> >(); std::vector<Date> jumpDates = std::vector<Date>(); Linear interpolator = Linear(); Compounding compounding = Continuous; Frequency frequency = Daily;
termStructure.linkTo(boost::shared_ptr<YieldTermStructure>(
new InterpolatedDiscountCurve < LogLinear >( dates, discountfactors, dayCounter, calendar )
)); } catch(Error e) { std::cout << "Error " << e.what() << std::endl; } return index;}
boost::shared_ptr<IborIndex> makeIndex() {
std::vector<Date> dates; dates.push_back(Date(14, February, 2000)); dates.push_back(Date(15, February, 2000)); dates.push_back(Date(15, August, 2000)); dates.push_back(Date(15, February, 2001)); dates.push_back(Date(15, August, 2001)); dates.push_back(Date(15, February, 2002)); dates.push_back(Date(15, August, 2002)); dates.push_back(Date(15, February, 2003)); dates.push_back(Date(15, August, 2003)); dates.push_back(Date(15, February, 2004)); dates.push_back(Date(15, August, 2004)); dates.push_back(Date(15, February, 2005)); dates.push_back(Date(15, August, 2005)); dates.push_back(Date(15, February, 2006)); dates.push_back(Date(15, August, 2006)); dates.push_back(Date(15, February, 2007)); dates.push_back(Date(15, August, 2007)); dates.push_back(Date(15, February, 2008)); dates.push_back(Date(15, August, 2008)); dates.push_back(Date(15, February, 2009)); dates.push_back(Date(15, August, 2009)); dates.push_back(Date(15, February, 2010)); dates.push_back(Date(15, August, 2010)); dates.push_back(Date(14, February, 2011)); dates.push_back(Date(14, February, 2012)); dates.push_back(Date(14, February, 2013)); dates.push_back(Date(14, February, 2014)); dates.push_back(Date(14, February, 2015));
vector<DiscountFactor> discountFactors; discountFactors.push_back(1); discountFactors.push_back(0.999866337); discountFactors.push_back(0.97583485); discountFactors.push_back(0.952126374); discountFactors.push_back(0.929366524); discountFactors.push_back(0.906787023); discountFactors.push_back(0.885110975); discountFactors.push_back(0.863606688); discountFactors.push_back(0.842962833); discountFactors.push_back(0.82248256); discountFactors.push_back(0.802714439); discountFactors.push_back(0.783212024); discountFactors.push_back(0.764489942); discountFactors.push_back(0.745916213); discountFactors.push_back(0.728085659); discountFactors.push_back(0.710396393); discountFactors.push_back(0.693414913); discountFactors.push_back(0.676567994); discountFactors.push_back(0.660306885); discountFactors.push_back(0.644264345); discountFactors.push_back(0.6288637); discountFactors.push_back(0.61358509); discountFactors.push_back(0.59891781); discountFactors.push_back(0.584398104); discountFactors.push_back(0.556480797); discountFactors.push_back(0.52982607); discountFactors.push_back(0.504515727); discountFactors.push_back(0.480414485);
return makeIndex(dates, discountFactors);
}
Le vendredi 1 décembre 2017 à 15:30:50 UTC+1, <fab...@gm...> a écrit :
#yiv3461759544 #yiv3461759544 -- _filtered #yiv3461759544 {font-family:Helvetica;panose-1:2 11 6 4 2 2 2 2 2 4;} _filtered #yiv3461759544 {panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered #yiv3461759544 {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;}#yiv3461759544 #yiv3461759544 p.yiv3461759544MsoNormal, #yiv3461759544 li.yiv3461759544MsoNormal, #yiv3461759544 div.yiv3461759544MsoNormal {margin:0in;margin-bottom:.0001pt;font-size:11.0pt;}#yiv3461759544 a:link, #yiv3461759544 span.yiv3461759544MsoHyperlink {color:#0563C1;text-decoration:underline;}#yiv3461759544 a:visited, #yiv3461759544 span.yiv3461759544MsoHyperlinkFollowed {color:#954F72;text-decoration:underline;}#yiv3461759544 p.yiv3461759544msonormal0, #yiv3461759544 li.yiv3461759544msonormal0, #yiv3461759544 div.yiv3461759544msonormal0 {margin-right:0in;margin-left:0in;font-size:11.0pt;}#yiv3461759544 span.yiv3461759544EmailStyle18 {color:windowtext;}#yiv3461759544 .yiv3461759544MsoChpDefault {font-size:10.0pt;} _filtered #yiv3461759544 {margin:70.85pt 70.85pt 70.85pt 70.85pt;}#yiv3461759544 div.yiv3461759544WordSection1 {}#yiv3461759544
Hi,
I believe you can create such a curve using one of the 3 public constructors of the InterpolatedDiscountCurve class (ql\termstructures\yield\discountcurve.hpp), which is documented here: http://quantlib.org/reference/class_quant_lib_1_1_interpolated_discount_curve.html#details
Regards,
Fabrice Lecuyer
From: laaouini anas [mailto:laa...@ya...]
Sent: Thursday, November 30, 2017 4:35 PM
To: lui...@gm...; qua...@li...; qua...@li...
Subject: [Quantlib-users] How to construct a YieldTermStructure QuantLibObject from a list of Discount factors?
Hello everybody,
I have a question for you:
How to construct a YieldTermStructure C++ QuantLib Object from a list of Discount factors?
The Quantlib classes and methods are not sufficiently documented. For example, if someone wants
to know how a given method of a class works, he must look at its implementation.
|