コード例 #1
0
ファイル: DigitalCoupon.cs プロジェクト: tzhdingli/qlnet
        //@}
        private double callPayoff()
        {
            // to use only if index has fixed
            double payoff = 0.0;

            if (hasCallStrike_)
            {
                double underlyingRate = underlying_.rate();
                if ((underlyingRate - callStrike_) > 1.0e-16)
                {
                    payoff = isCallCashOrNothing_ ? callDigitalPayoff_ : underlyingRate;
                }
                else
                {
                    if (isCallATMIncluded_)
                    {
                        if (Math.Abs(callStrike_ - underlyingRate) <= 1.0e-16)
                        {
                            payoff = isCallCashOrNothing_ ? callDigitalPayoff_ : underlyingRate;
                        }
                    }
                }
            }
            return(payoff);
        }
コード例 #2
0
ファイル: CappedFlooredCoupon.cs プロジェクト: zhangz/QLNet
        // Coupon interface
        public override double rate()
        {
            Utils.QL_REQUIRE(underlying_.pricer() != null, () => "pricer not set");

            double swapletRate  = underlying_.rate();
            double floorletRate = 0.0;

            if (isFloored_)
            {
                floorletRate = underlying_.pricer().floorletRate(effectiveFloor().Value);
            }
            double capletRate = 0.0;

            if (isCapped_)
            {
                capletRate = underlying_.pricer().capletRate(effectiveCap().Value);
            }
            return(swapletRate + floorletRate - capletRate);
        }
コード例 #3
0
        //! \name Coupon interface
        //@{
        public override double rate()
        {
            if (underlying_.pricer() == null)
            {
                throw new ApplicationException("pricer not set");
            }

            double swapletRate  = underlying_.rate();
            double floorletRate = 0.0;

            if (isFloored_)
            {
                floorletRate = underlying_.pricer().floorletRate(effectiveFloor().Value);
            }
            double capletRate = 0.0;

            if (isCapped_)
            {
                capletRate = underlying_.pricer().capletRate(effectiveCap().Value);
            }
            return(swapletRate + floorletRate - capletRate);
        }