I'd like to use QuantLib as a C++ library to price interest rate derivatives, in particular Cap&Floors. To semplify things a little, let's say I have a vector of EURLibor1Y rates for different maturities, which I called r, and a constant caplet volatility which I called vol. When ever I try to set up a Cap/Floor object using the following code

    Volatility vol = 0.180253;
    boost::shared_ptr<OptionletVolatilityStructure> vol_ptr = boost::make_shared<ConstantOptionletVolatility>(settlement,cal,ModifiedFollowing,vol,Actual360());
    RelinkableHandle<OptionletVolatilityStructure> vol_handle(vol_ptr);
    boost::shared_ptr<YieldTermStructure> curve = boost::make_shared<InterpolatedForwardCurve<LogLinear>>(dates,r,Actual360());
    RelinkableHandle<YieldTermStructure> ts_handle(curve);
    boost::shared_ptr<IborIndex> index = boost::make_shared<EURLibor1Y>(ts_handle);
    IborLeg floatingLeg(schd,index);
    Cap cap(floatingLeg,r);

I get a runtime error saying "terminate called after throwing an instance of 'QuantLib::Error' what(): no notional given", any idea how to fix this?

EDIT: In initializing the Cap I use the vector r because I want it to be ATM.


1 Answer 1


Never mind, just found out the issue. The IborLeg class has a method called "withNotionals(Real)" used to set the notional value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.