Ejemplo n.º 1
0
        IborIndex makeIndex(List <Date> dates,
                            List <double> rates)
        {
            DayCounter dayCounter = new Actual360();

            RelinkableHandle <YieldTermStructure> termStructure = new RelinkableHandle <YieldTermStructure>();
            IborIndex index = new Euribor6M(termStructure);

            Date todaysDate =
                index.fixingCalendar().adjust(new Date(4, 9, 2005));

            Settings.setEvaluationDate(todaysDate);

            dates[0] = index.fixingCalendar().advance(todaysDate,
                                                      index.fixingDays(), TimeUnit.Days);
            Linear Interpolator = new Linear();

            termStructure.linkTo(new InterpolatedZeroCurve <Linear>(dates, rates, dayCounter, Interpolator));

            return(index);
        }
Ejemplo n.º 2
0
        public void testInitialisation()
        {
            //"Testing caplet LMM process initialisation..."

            //SavedSettings backup;

            DayCounter dayCounter = new Actual360();
            RelinkableHandle <YieldTermStructure> termStructure = new RelinkableHandle <YieldTermStructure>();;

            termStructure.linkTo(Utilities.flatRate(Date.Today, 0.04, dayCounter));

            IborIndex index = new Euribor6M(termStructure);
            OptionletVolatilityStructure capletVol = new ConstantOptionletVolatility(
                termStructure.currentLink().referenceDate(),
                termStructure.currentLink().calendar(),
                BusinessDayConvention.Following,
                0.2,
                termStructure.currentLink().dayCounter());

            Calendar calendar = index.fixingCalendar();

            for (int daysOffset = 0; daysOffset < 1825 /* 5 year*/; daysOffset += 8)
            {
                Date todaysDate = calendar.adjust(Date.Today + daysOffset);
                Settings.setEvaluationDate(todaysDate);
                Date settlementDate =
                    calendar.advance(todaysDate, index.fixingDays(), TimeUnit.Days);

                termStructure.linkTo(Utilities.flatRate(settlementDate, 0.04, dayCounter));

                LiborForwardModelProcess process = new LiborForwardModelProcess(60, index);

                List <double> fixings = process.fixingTimes();
                for (int i = 1; i < fixings.Count - 1; ++i)
                {
                    int ileft  = process.nextIndexReset(fixings[i] - 0.000001);
                    int iright = process.nextIndexReset(fixings[i] + 0.000001);
                    int ii     = process.nextIndexReset(fixings[i]);

                    if ((ileft != i) || (iright != i + 1) || (ii != i + 1))
                    {
                        Assert.Fail("Failed to next index resets");
                    }
                }
            }
        }