コード例 #1
0
ファイル: g2.cs プロジェクト: sandboxorg/QLNet
        public double swaption(Swaption.Arguments arguments,
                               double fixedRate,
                               double range,
                               int intervals)
        {
            Date       settlement = termStructure().link.referenceDate();
            DayCounter dayCounter = termStructure().link.dayCounter();
            double     start      = dayCounter.yearFraction(settlement,
                                                            arguments.floatingResetDates[0]);
            double w = (arguments.type == VanillaSwap.Type.Payer ? 1 : -1);

            List <double> fixedPayTimes = new  InitializedList <double>(arguments.fixedPayDates.Count);

            for (int i = 0; i < fixedPayTimes.Count; ++i)
            {
                fixedPayTimes[i] =
                    dayCounter.yearFraction(settlement,
                                            arguments.fixedPayDates[i]);
            }

            SwaptionPricingFunction function = new SwaptionPricingFunction(a(),
                                                                           sigma(), b(), eta(), rho(),
                                                                           w, start,
                                                                           fixedPayTimes,
                                                                           fixedRate, this);

            double          upper      = function.mux() + range * function.sigmax();
            double          lower      = function.mux() - range * function.sigmax();
            SegmentIntegral integrator = new SegmentIntegral(intervals);

            return(arguments.nominal * w * termStructure().link.discount(start) *
                   integrator.value(function.value, lower, upper));
        }
コード例 #2
0
ファイル: g2.cs プロジェクト: StreetConnect/QLNet
        public double swaption(Swaption.Arguments arguments,
            double fixedRate,
            double range,
            int intervals)
        {
            Date settlement = termStructure().link.referenceDate();
            DayCounter dayCounter = termStructure().link.dayCounter();
            double start = dayCounter.yearFraction(settlement,
                                             arguments.floatingResetDates[0]);
            double w = (arguments.type==VanillaSwap.Type.Payer ? 1 : -1 );

            List<double> fixedPayTimes = new  InitializedList<double>(arguments.fixedPayDates.Count);
            for (int i=0; i<fixedPayTimes.Count; ++i)
            fixedPayTimes[i] =
                dayCounter.yearFraction(settlement,
                                        arguments.fixedPayDates[i]);

            SwaptionPricingFunction function = new SwaptionPricingFunction(a(),
                                                sigma(), b(), eta(), rho(),
                                                w, start,
                                                fixedPayTimes,
                                                fixedRate,this);

            double upper = function.mux() + range*function.sigmax();
            double lower = function.mux() - range*function.sigmax();
            SegmentIntegral integrator = new SegmentIntegral(intervals);
            return arguments.nominal*w*termStructure().link.discount(start)*
            integrator.value(function.value, lower, upper);
        }