Example #1
0
        public CapletBootstrapEngineHelperTests()
        {
            const string CalculationDateString = @"2007-11-29";
            const string StartDateString       = @"2007-11-30";
            const bool   ValidateArguments     = true;

            _calculationDate            = DateTime.Parse(CalculationDateString);
            _capFrequency               = CapFrequency.Quarterly;
            _capStartLag                = 1;
            _currency                   = "AUD";
            _handle                     = "Caplet Bootstrap Engine Helper tests";
            _numYears                   = 10.0d;
            _parVolatilityInterpolation =
                ParVolatilityInterpolationType.CubicHermiteSpline;
            _rollConvention = BusinessDayConventionEnum.MODFOLLOWING;
            _startDate      = DateTime.Parse(StartDateString);
            _tolerance      = 1.0E-5d;
            _settingsObj    = new CapletBootstrapSettings
                                  (_calculationDate,
                                  _capFrequency,
                                  _capStartLag,
                                  _currency,
                                  _handle,
                                  _parVolatilityInterpolation,
                                  _rollConvention,
                                  ValidateArguments);

            // Initialise the offsets.
            _offsets = new List <double>();

            foreach (DateTime date in _dates)
            {
                TimeSpan dateDiff = date - _calculationDate;
                _offsets.Add(dateDiff.Days);
            }
        }
Example #2
0
        public void TestGenerateUSDCapRollSchedule()
        {
            // Construct the settings object: only change the parameters that
            // are particular to this test case.
            const string CalculationDateString = @"2008-05-14";
            const bool   ValidateArguments     = true;

            _calculationDate = DateTime.Parse(CalculationDateString);
            _capStartLag     = 2;
            _currency        = "USD";
            _numYears        = 20.0d;

            _settingsObj = new CapletBootstrapSettings
                               (_calculationDate,
                               _capFrequency,
                               _capStartLag,
                               _currency,
                               _handle,
                               _parVolatilityInterpolation,
                               _rollConvention,
                               ValidateArguments);
            Assert.IsNotNull(_settingsObj);

            // Generate the roll schedule.
            CapletBootstrapEngineHelper.GenerateRollSchedule
                (_settingsObj, _numYears, out _rollSchedule);

            // Check the first and last dates in the roll schedule.
            const string FirstDateInSchedule = "2008-08-18";
            const string LastDateInSchedule  = "2028-05-16";

            Assert.AreEqual
                (DateTime.Parse(FirstDateInSchedule), _rollSchedule[0]);
            Assert.AreEqual(DateTime.Parse(LastDateInSchedule),
                            _rollSchedule[_rollSchedule.Count - 1]);
        }