public ImpliedVolHelper(CapFloor cap, Handle <YieldTermStructure> discountCurve, double targetValue, double displacement, VolatilityType type) { discountCurve_ = discountCurve; targetValue_ = targetValue; vol_ = new SimpleQuote(-1.0); Handle <Quote> h = new Handle <Quote>(vol_); switch (type) { case VolatilityType.ShiftedLognormal: engine_ = (IPricingEngine) new BlackCapFloorEngine(discountCurve_, h, new Actual365Fixed(), displacement); break; case VolatilityType.Normal: engine_ = (IPricingEngine) new BachelierCapFloorEngine(discountCurve_, h, new Actual365Fixed()); break; default: Utils.QL_FAIL("unknown VolatilityType (" + type.ToString() + ")"); break; } cap.setupArguments(engine_.getArguments()); results_ = engine_.getResults() as Instrument.Results; }
public ImpliedVolHelper(CapFloor cap, Handle <YieldTermStructure> discountCurve, double targetValue) { discountCurve_ = discountCurve; targetValue_ = targetValue; vol_ = new SimpleQuote(-1.0); Handle <Quote> h = new Handle <Quote>(vol_); engine_ = (IPricingEngine) new BlackCapFloorEngine(discountCurve_, h); cap.setupArguments(engine_.getArguments()); results_ = engine_.getResults() as Instrument.Results; }