|
From: v17 <var...@ya...> - 2014-01-16 05:48:33
|
Hi,
Request members help on the below issue -
I have following code in my project -
boost::shared_ptr<YieldTermStructure>
CYieldCurveUtils::MakeTermStructure(const vector<Rate> &liborRates, const
vector<Period> &liborTenors, YieldCurveDef &_ycDef, bool zeroRates ){
ycDef = _ycDef;
ycDef.evalDate = ycDef.cal.advance(ycDef.evalDate, -2, Days);
const int size = liborRates.size();
std::vector<shared_ptr<RateHelper>> instruments;
Period oneYear(1, Years);
shared_ptr<Euribor> swapIndex(new Euribor(6 * Months));
vector<Date> liborDates(liborTenors.size());
Date curDate;
if (!zeroRates){
for (int idx = 0; idx < size; idx++){
if (liborTenors[idx] < oneYear){
shared_ptr<RateHelper> rateHelper(new
DepositRateHelper(liborRates[idx],liborTenors[idx],ycDef.fixingDays,ycDef.cal,
ycDef.bdc, ycDef.endOfMonth, ycDef.dc));
instruments.push_back(rateHelper);
}
else {
shared_ptr<RateHelper> rateHelper(new
SwapRateHelper(liborRates[idx],liborTenors[idx], ycDef.cal, ycDef.freq,
ycDef.bdc, ycDef.dc, swapIndex));
instruments.push_back(rateHelper);
}
}
yieldCurve = shared_ptr<YieldTermStructure>(new
PiecewiseYieldCurve<Discount, LogLinear, IterativeBootstrap>(ycDef.evalDate,
instruments, ycDef.dc));
yieldCurve->enableExtrapolation();
}
else{
for (int i = 0; i < size; i++){
curDate = ycDef.cal.advance(ycDef.evalDate, liborTenors[i]);
liborDates[i] = curDate;
}
yieldCurve = shared_ptr<YieldTermStructure>(new
InterpolatedZeroCurve<LogLinear>(liborDates, liborRates, ycDef.dc,
ycDef.cal));
yieldCurve->enableExtrapolation();
}
return yieldCurve;
}
void GetZeroRates(const vector<Real> &liborRates, const vector<Period>
&liborTenors, vector <Real> &zeroRates, YieldCurveDef &_ycDef){
boost::shared_ptr<YieldTermStructure> ptrYiedCurve =
MakeTermStructure(liborRates, liborTenors, _ycDef, true);
int size = liborTenors.size();
zeroRates.clear();
zeroRates.resize(size);
for (int i = 0; i < size; i++){
zeroRates[i] = ptrYiedCurve->zeroRate(_ycDef.evalDate + liborTenors[i],
_ycDef.dc, Compounded, Annual);
//std::cout << "Rate = " << yieldCurve->forwardRate(_ycDef.evalDate +
Period(1*Years), _ycDef.evalDate + Period(1*Years) + periods[i] , _ycDef.dc,
Compounded, Annual) << std::endl;
}
}
Program crashes when it hits zeroRate(...) function. Is it looking for
discountImpl function implementation? I am using InterpolatedZeroCurve which
provides the implementation for discountImpl and zeroYieldImpl functions.
--
View this message in context: http://quantlib.10058.n7.nabble.com/Facing-app-crash-with-zeroRate-function-tp14853.html
Sent from the quantlib-dev mailing list archive at Nabble.com.
|