fixing() публичный Метод

public fixing ( Date fixingDate, bool forecastTodaysFixing ) : double
fixingDate Date
forecastTodaysFixing bool
Результат double
Пример #1
0
        public override double swapletRate()
        {
            List <Date>       fixingDates = coupon_.fixingDates();
            InterestRateIndex index       = coupon_.index();

            int  cutoffDays = 0; // to be verified
            Date startDate  = coupon_.accrualStartDate() - cutoffDays,
                 endDate    = coupon_.accrualEndDate() - cutoffDays,
                 d1         = startDate,
                 d2         = startDate;

            if (!(fixingDates.Count > 0))
            {
                throw new ApplicationException("fixing date list empty");
            }
            if (!(index.valueDate(fixingDates.First()) <= startDate))
            {
                throw new ApplicationException("first fixing date valid after period start");
            }
            if (!(index.valueDate(fixingDates.Last()) >= endDate))
            {
                throw new ApplicationException("last fixing date valid before period end");
            }

            double avgBMA = 0.0;
            int    days   = 0;

            for (int i = 0; i < fixingDates.Count - 1; ++i)
            {
                Date valueDate     = index.valueDate(fixingDates[i]);
                Date nextValueDate = index.valueDate(fixingDates[i + 1]);

                if (fixingDates[i] >= endDate || valueDate >= endDate)
                {
                    break;
                }
                if (fixingDates[i + 1] < startDate || nextValueDate <= startDate)
                {
                    continue;
                }

                d2 = Date.Min(nextValueDate, endDate);

                avgBMA += index.fixing(fixingDates[i]) * (d2 - d1);

                days += d2 - d1;
                d1    = d2;
            }
            avgBMA /= (endDate - startDate);

            if (!(days == endDate - startDate))
            {
                throw new ApplicationException("averaging days " + days + " differ from " +
                                               "interest days " + (endDate - startDate));
            }

            return(coupon_.gearing() * avgBMA + coupon_.spread());
        }
Пример #2
0
        }                                                              //! spread paid over the fixing of the underlying index

        //! fixing of the underlying index
        public virtual double indexFixing()
        {
            return(index_.fixing(fixingDate()));
        }