Пример #1
0
      protected  override void preAdjustValuesImpl()
      {
         for (int i=0; i<startTimes_.Count; i++) {
            if (isOnTime(startTimes_[i])) {
                double end = endTimes_[i];
                double tenor = arguments_.accrualTimes[i];
                DiscretizedDiscountBond bond=new DiscretizedDiscountBond();
                bond.initialize(method(), end);
                bond.rollback(time_);

                CapFloorType type = arguments_.type;
                double gearing = arguments_.gearings[i];
                double nominal = arguments_.nominals[i];

                if ( (type == CapFloorType.Cap) ||
                     (type == CapFloorType.Collar)) {
                    double accrual =(double)( 1.0 + arguments_.capRates[i]*tenor);
                    double strike = 1.0/accrual;
                    for (int j=0; j<values_.size(); j++)
                        values_[j] += nominal*accrual*gearing*
                            Math.Max(strike - bond.values()[j], 0.0);
                }

                if ( (type == CapFloorType.Floor) ||
                     (type == CapFloorType.Collar)) {
                    double accrual =(double)( 1.0 + arguments_.floorRates[i]*tenor);
                    double strike = 1.0/accrual;
                    double mult = (type == CapFloorType.Floor)?1.0:-1.0;
                    for (int j=0; j<values_.size(); j++)
                        values_[j] += nominal*accrual*mult*gearing*
                            Math.Max(bond.values()[j] - strike, 0.0);
                }
            }
         }
      }
Пример #2
0
        protected override void preAdjustValuesImpl()
        {
            // floating payments
            for (int i = 0; i < floatingResetTimes_.Count; i++)
            {
                double t = floatingResetTimes_[i];
                if (t >= 0.0 && isOnTime(t))
                {
                    DiscretizedDiscountBond bond = new DiscretizedDiscountBond();
                    bond.initialize(method(), floatingPayTimes_[i]);
                    bond.rollback(time_);

                    double nominal       = arguments_.nominal;
                    double T             = arguments_.floatingAccrualTimes[i];
                    double spread        = arguments_.floatingSpreads[i];
                    double accruedSpread = nominal * T * spread;
                    for (int j = 0; j < values_.size(); j++)
                    {
                        double coupon = nominal * (1.0 - bond.values()[j])
                                        + accruedSpread * bond.values()[j];
                        if (arguments_.type == VanillaSwap.Type.Payer)
                        {
                            values_[j] += coupon;
                        }
                        else
                        {
                            values_[j] -= coupon;
                        }
                    }
                }
            }
            // fixed payments
            for (int i = 0; i < fixedResetTimes_.Count; i++)
            {
                double t = fixedResetTimes_[i];
                if (t >= 0.0 && isOnTime(t))
                {
                    DiscretizedDiscountBond bond = new DiscretizedDiscountBond();
                    bond.initialize(method(), fixedPayTimes_[i]);
                    bond.rollback(time_);

                    double fixedCoupon = arguments_.fixedCoupons[i];
                    for (int j = 0; j < values_.size(); j++)
                    {
                        double coupon = fixedCoupon * bond.values()[j];
                        if (arguments_.type == VanillaSwap.Type.Payer)
                        {
                            values_[j] -= coupon;
                        }
                        else
                        {
                            values_[j] += coupon;
                        }
                    }
                }
            }
        }
Пример #3
0
        protected override void preAdjustValuesImpl()
        {
            for (int i = 0; i < startTimes_.Count; i++)
            {
                if (isOnTime(startTimes_[i]))
                {
                    double end   = endTimes_[i];
                    double tenor = arguments_.accrualTimes[i];
                    DiscretizedDiscountBond bond = new DiscretizedDiscountBond();
                    bond.initialize(method(), end);
                    bond.rollback(time_);

                    CapFloorType type    = arguments_.type;
                    double       gearing = arguments_.gearings[i];
                    double       nominal = arguments_.nominals[i];

                    if ((type == CapFloorType.Cap) ||
                        (type == CapFloorType.Collar))
                    {
                        double accrual = (double)(1.0 + arguments_.capRates[i] * tenor);
                        double strike  = 1.0 / accrual;
                        for (int j = 0; j < values_.size(); j++)
                        {
                            values_[j] += nominal * accrual * gearing *
                                          Math.Max(strike - bond.values()[j], 0.0);
                        }
                    }

                    if ((type == CapFloorType.Floor) ||
                        (type == CapFloorType.Collar))
                    {
                        double accrual = (double)(1.0 + arguments_.floorRates[i] * tenor);
                        double strike  = 1.0 / accrual;
                        double mult    = (type == CapFloorType.Floor) ? 1.0 : -1.0;
                        for (int j = 0; j < values_.size(); j++)
                        {
                            values_[j] += nominal * accrual * mult * gearing *
                                          Math.Max(bond.values()[j] - strike, 0.0);
                        }
                    }
                }
            }
        }
Пример #4
0
        protected override void preAdjustValuesImpl()
        {
            // floating payments
            for (int i = 0; i < floatingResetTimes_.Count; i++){
                double t = floatingResetTimes_[i];
                if (t >= 0.0 && isOnTime(t)){
                    DiscretizedDiscountBond bond = new DiscretizedDiscountBond();
                    bond.initialize(method(), floatingPayTimes_[i]);
                    bond.rollback(time_);

                    double nominal = arguments_.nominal;
                    double T = arguments_.floatingAccrualTimes[i];
                    double spread = arguments_.floatingSpreads[i];
                    double accruedSpread = nominal * T * spread;
                    for (int j = 0; j < values_.size(); j++){
                        double coupon = nominal * (1.0 - bond.values()[j])
                                    + accruedSpread * bond.values()[j];
                        if (arguments_.type == VanillaSwap.Type.Payer)
                            values_[j] += coupon;
                        else
                            values_[j] -= coupon;
                    }
                }
            }
            // fixed payments
            for (int i = 0; i < fixedResetTimes_.Count; i++){
                double t = fixedResetTimes_[i];
                if (t >= 0.0 && isOnTime(t)){
                    DiscretizedDiscountBond bond = new DiscretizedDiscountBond();
                    bond.initialize(method(), fixedPayTimes_[i]);
                    bond.rollback(time_);

                    double fixedCoupon = arguments_.fixedCoupons[i];
                    for (int j = 0; j < values_.size(); j++){
                        double coupon = fixedCoupon * bond.values()[j];
                        if (arguments_.type == VanillaSwap.Type.Payer)
                            values_[j] -= coupon;
                        else
                            values_[j] += coupon;
                    }
                }
            }
        }