http://quantlib.414.s1.nabble.com/Facing-app-crash-with-zeroRate-function-tp14853p14854.html
> 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.
>
> ------------------------------------------------------------------------------
> CenturyLink Cloud: The Leader in Enterprise Cloud Services.
> Learn Why More Businesses Are Choosing CenturyLink Cloud For
> Critical Workloads, Development Environments & Everything In Between.
> Get a Quote or Start a Free Trial Today.
>
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk> _______________________________________________
> QuantLib-dev mailing list
>
[hidden email]
>
https://lists.sourceforge.net/lists/listinfo/quantlib-devCenturyLink Cloud: The Leader in Enterprise Cloud Services.
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today.