endOfMonth() private method

private endOfMonth ( ) : bool
return bool
Ejemplo n.º 1
0
 public DepositRateHelper(double rate, IborIndex i)
     : base(rate)
 {
     iborIndex_ = new IborIndex("no-fix", // never take fixing into account
                                i.tenor(), i.fixingDays(), new Currency(),
                                i.fixingCalendar(), i.businessDayConvention(),
                                i.endOfMonth(), i.dayCounter(), termStructureHandle_);
     initializeDates();
 }
Ejemplo n.º 2
0
 public DepositRateHelper(double rate, IborIndex i)
     : base(rate)
 {
     iborIndex_ = new IborIndex("no-fix", // never take fixing into account
                                i.tenor(), i.fixingDays(), new Currency(),
                                i.fixingCalendar(), i.businessDayConvention(),
                                i.endOfMonth(), i.dayCounter(), termStructureHandle_);
     initializeDates();
 }
Ejemplo n.º 3
0
        public FraRateHelper(double rate, int monthsToStart, IborIndex i) : base(rate)
        {
            periodToStart_ = new Period(monthsToStart, TimeUnit.Months);

            iborIndex_ = new IborIndex("no-fix",  // never take fixing into account
                                       i.tenor(), i.fixingDays(), new Currency(),
                                       i.fixingCalendar(), i.businessDayConvention(),
                                       i.endOfMonth(), i.dayCounter(), termStructureHandle_);

            initializeDates();
        }
Ejemplo n.º 4
0
        public FRARateHelper(double rate, int monthsToStart, IborIndex i)
            : base(rate)
        {
            periodToStart_ = new Period(monthsToStart, TimeUnit.Months);

            iborIndex_ = new IborIndex("no-fix",  // never take fixing into account
                                       i.tenor(), i.fixingDays(), new Currency(),
                                       i.fixingCalendar(), i.businessDayConvention(),
                                       i.endOfMonth(), i.dayCounter(), termStructureHandle_);

            initializeDates();
        }
Ejemplo n.º 5
0
        protected override void initializeDates()
        {
            earliestDate_ = calendar_.advance(evaluationDate_, new Period(settlementDays_, TimeUnit.Days),
                                              BusinessDayConvention.Following);

            Date maturity = earliestDate_ + tenor_;

            // dummy BMA index with curve/swap arguments
            BMAIndex clonedIndex = new BMAIndex(termStructureHandle_);

            Schedule bmaSchedule = new MakeSchedule().from(earliestDate_).to(maturity)
                                   .withTenor(bmaPeriod_)
                                   .withCalendar(bmaIndex_.fixingCalendar())
                                   .withConvention(bmaConvention_)
                                   .backwards()
                                   .value();

            Schedule liborSchedule = new MakeSchedule().from(earliestDate_).to(maturity)
                                     .withTenor(iborIndex_.tenor())
                                     .withCalendar(iborIndex_.fixingCalendar())
                                     .withConvention(iborIndex_.businessDayConvention())
                                     .endOfMonth(iborIndex_.endOfMonth())
                                     .backwards()
                                     .value();

            swap_ = new BMASwap(BMASwap.Type.Payer, 100.0, liborSchedule, 0.75,             // arbitrary
                                0.0, iborIndex_, iborIndex_.dayCounter(), bmaSchedule, clonedIndex, bmaDayCount_);
            swap_.setPricingEngine(new DiscountingSwapEngine(iborIndex_.forwardingTermStructure()));

            Date d             = calendar_.adjust(swap_.maturityDate(), BusinessDayConvention.Following);
            int  w             = d.weekday();
            Date nextWednesday = (w >= 4) ? d + new Period((11 - w), TimeUnit.Days) :
                                 d + new Period((4 - w), TimeUnit.Days);

            latestDate_ = clonedIndex.valueDate(clonedIndex.fixingCalendar().adjust(nextWednesday));
        }
Ejemplo n.º 6
0
        public CapHelper(Period length,
            Handle<Quote> volatility,
            IborIndex index,
            // data for ATM swap-rate calculation
            Frequency fixedLegFrequency,
            DayCounter fixedLegDayCounter,
            bool includeFirstSwaplet,
            Handle<YieldTermStructure> termStructure,
            bool calibrateVolatility /*= false*/)
            : base(volatility, termStructure, calibrateVolatility)
        {
            Period indexTenor = index.tenor();
            double fixedRate = 0.04; // dummy value
            Date startDate, maturity;
            if (includeFirstSwaplet) {
                startDate = termStructure.link.referenceDate();
                maturity = termStructure.link.referenceDate() + length;
            } else {
                startDate = termStructure.link.referenceDate() + indexTenor;
                maturity = termStructure.link.referenceDate() + length;
            }
            IborIndex dummyIndex=new
                IborIndex("dummy",
                          indexTenor,
                          index.fixingDays(),
                          index.currency(),
                          index.fixingCalendar(),
                          index.businessDayConvention(),
                          index.endOfMonth(),
                          termStructure.link.dayCounter(),
                          termStructure);

            List<double> nominals = new InitializedList<double>(1,1.0);

            Schedule floatSchedule=new Schedule(startDate, maturity,
                                   index.tenor(), index.fixingCalendar(),
                                   index.businessDayConvention(),
                                   index.businessDayConvention(),
                                   DateGeneration.Rule.Forward, false);
            List<CashFlow> floatingLeg;
            IborLeg iborLeg = (IborLeg) new IborLeg(floatSchedule, index)
                                            .withFixingDays(0)
                                            .withNotionals(nominals)
                                            .withPaymentAdjustment(index.businessDayConvention());
            floatingLeg = iborLeg.value();
            Schedule fixedSchedule=new Schedule(startDate, maturity, new Period(fixedLegFrequency),
                                   index.fixingCalendar(),
                                   BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                                   DateGeneration.Rule.Forward, false);
            List<CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule)
                .withCouponRates(fixedRate, fixedLegDayCounter)
                .withNotionals(nominals)
                .withPaymentAdjustment(index.businessDayConvention());

            Swap swap = new Swap(floatingLeg, fixedLeg);
            swap.setPricingEngine(new DiscountingSwapEngine(termStructure));
            double bp = 1.0e-4;
            double fairRate = fixedRate - (double)(swap.NPV()/(swap.legBPS(1) / bp));
            List<double> exerciceRate = new InitializedList<double>(1,fairRate);
            cap_ = new Cap(floatingLeg, exerciceRate);
            marketValue_ = blackPrice(volatility_.link.value());
        }
Ejemplo n.º 7
0
        public CapHelper(Period length,
                         Handle <Quote> volatility,
                         IborIndex index,
                         // data for ATM swap-rate calculation
                         Frequency fixedLegFrequency,
                         DayCounter fixedLegDayCounter,
                         bool includeFirstSwaplet,
                         Handle <YieldTermStructure> termStructure,
                         bool calibrateVolatility /*= false*/)
            : base(volatility, termStructure, calibrateVolatility)
        {
            Period indexTenor = index.tenor();
            double fixedRate = 0.04; // dummy value
            Date   startDate, maturity;

            if (includeFirstSwaplet)
            {
                startDate = termStructure.link.referenceDate();
                maturity  = termStructure.link.referenceDate() + length;
            }
            else
            {
                startDate = termStructure.link.referenceDate() + indexTenor;
                maturity  = termStructure.link.referenceDate() + length;
            }
            IborIndex dummyIndex = new
                                   IborIndex("dummy",
                                             indexTenor,
                                             index.fixingDays(),
                                             index.currency(),
                                             index.fixingCalendar(),
                                             index.businessDayConvention(),
                                             index.endOfMonth(),
                                             termStructure.link.dayCounter(),
                                             termStructure);

            List <double> nominals = new InitializedList <double>(1, 1.0);

            Schedule floatSchedule = new Schedule(startDate, maturity,
                                                  index.tenor(), index.fixingCalendar(),
                                                  index.businessDayConvention(),
                                                  index.businessDayConvention(),
                                                  DateGeneration.Rule.Forward, false);
            List <CashFlow> floatingLeg;
            IborLeg         iborLeg = (IborLeg) new IborLeg(floatSchedule, index)
                                      .withFixingDays(0)
                                      .withNotionals(nominals)
                                      .withPaymentAdjustment(index.businessDayConvention());

            floatingLeg = iborLeg.value();
            Schedule fixedSchedule = new Schedule(startDate, maturity, new Period(fixedLegFrequency),
                                                  index.fixingCalendar(),
                                                  BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted,
                                                  DateGeneration.Rule.Forward, false);
            List <CashFlow> fixedLeg = new FixedRateLeg(fixedSchedule)
                                       .withCouponRates(fixedRate, fixedLegDayCounter)
                                       .withNotionals(nominals)
                                       .withPaymentAdjustment(index.businessDayConvention());

            Swap swap = new Swap(floatingLeg, fixedLeg);

            swap.setPricingEngine(new DiscountingSwapEngine(termStructure));
            double        bp           = 1.0e-4;
            double        fairRate     = fixedRate - (double)(swap.NPV() / (swap.legBPS(1) / bp));
            List <double> exerciceRate = new InitializedList <double>(1, fairRate);

            cap_         = new Cap(floatingLeg, exerciceRate);
            marketValue_ = blackPrice(volatility_.link.value());
        }
Ejemplo n.º 8
0
        protected override void initializeDates()
        {
            // why not using index_->fixingDays instead of settlementDays_
            Date settlement = iborIndex_.fixingCalendar().advance(evaluationDate_, iborIndex_.fixingDays(), TimeUnit.Days);

            earliestDate_ = iborIndex_.fixingCalendar().advance(settlement, periodToStart_,
                                                                iborIndex_.businessDayConvention(), iborIndex_.endOfMonth());
            latestDate_ = iborIndex_.maturityDate(earliestDate_);
            fixingDate_ = iborIndex_.fixingDate(earliestDate_);
        }