Пример #1
0
        public ImpliedVolHelper_(Swaption swaption,
                                 Handle <YieldTermStructure> discountCurve,
                                 double targetValue,
                                 double?displacement = 0.0,
                                 VolatilityType type = VolatilityType.ShiftedLognormal)
        {
            discountCurve_ = discountCurve;
            targetValue_   = targetValue;
            // set an implausible value, so that calculation is forced
            // at first ImpliedVolHelper::operator()(Volatility x) call
            vol_ = new SimpleQuote(-1.0);
            Handle <Quote> h = new Handle <Quote>(vol_);

            switch (type)
            {
            case VolatilityType.ShiftedLognormal:
                engine_ = new BlackSwaptionEngine(discountCurve_, h, new Actual365Fixed(), displacement);
                break;

            case VolatilityType.Normal:
                engine_ = new BachelierSwaptionEngine(discountCurve_, h, new Actual365Fixed());
                break;

            default:
                Utils.QL_FAIL("unknown VolatilityType (" + type.ToString() + ")");
                break;
            }
            swaption.setupArguments(engine_.getArguments());
            results_ = engine_.getResults() as Instrument.Results;
        }
Пример #2
0
            public SwaptionImpliedVolatilityHelper(Swaption swaption, Handle <YieldTermStructure> discountCurve, double targetValue)
            {
                discountCurve_ = discountCurve;
                targetValue_   = targetValue;

                // set an implausible value, so that calculation is forced
                // at first ImpliedVolHelper::operator()(Volatility x) call
                vol_ = new SimpleQuote(-1.0);
                Handle <Quote> h = new Handle <Quote>(vol_);

                engine_ = new BlackSwaptionEngine(discountCurve_, h);
                swaption.setupArguments(engine_.getArguments());
                results_ = engine_.getResults() as Results;
            }
Пример #3
0
        public override void addTimesTo(List <double> times)
        {
            Swaption.Arguments args = new Swaption.Arguments();
            swaption_.setupArguments(args);

            List <double> swaptionTimes =
                new DiscretizedSwaption(args,
                                        termStructure_.link.referenceDate(),
                                        termStructure_.link.dayCounter()).mandatoryTimes();

            /*times.insert(times.end(),
             *         swaptionTimes.begin(), swaptionTimes.end());*/
            for (int i = 0; i < swaptionTimes.Count; i++)
            {
                times.Insert(times.Count, swaptionTimes[i]);
            }
        }