public void testCashedValues() { Date startDate = new Date(01, 03, 2007); Period period = new Period(360, TimeUnit.Months); Calendar calendar = new TARGET(); Date endDate = calendar.advance(startDate, period, BusinessDayConvention.Unadjusted); Schedule schedule = new Schedule(startDate, endDate, new Period(1, TimeUnit.Months), calendar, BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false); // PSA 100% PSACurve psa100 = new PSACurve(startDate); double[] listCPR = { 0.2000, 0.4000, 0.6000, 0.8000, 1.0000, 1.2000, 1.4000, 1.6000, 1.8000, 2.0000, 2.2000, 2.4000, 2.6000, 2.8000, 3.0000, 3.2000, 3.4000, 3.6000, 3.8000, 4.0000, 4.2000, 4.4000, 4.6000, 4.8000, 5.0000, 5.2000, 5.4000, 5.6000, 5.8000, 6.0000 }; for (int i = 0; i < schedule.Count; i++) { if (i <= 29) { QAssert.AreEqual(listCPR[i], psa100.getCPR(schedule[i]) * 100, 0.001); } else { QAssert.AreEqual(6.0000, psa100.getCPR(schedule[i]) * 100); } } }
public static MBSFixedRateBond makeMBSFixedBond(Date startDate, Period bondLength, Period originalLength, DayCounter dCounter, Frequency payFrequency, double amount, double WACRate, double PassThroughRate, PSACurve psaCurve) { return(makeMBSFixedBond(startDate, bondLength, originalLength, dCounter, payFrequency, amount, WACRate, PassThroughRate, psaCurve, new TARGET())); }
public static MBSFixedRateBond makeMBSFixedBond(Date startDate, Period bondLength, Period originalLength, DayCounter dCounter, Frequency payFrequency, double amount, double WACrate, double PassThroughRate, PSACurve psaCurve, Calendar calendar) { MBSFixedRateBond bond; Date endDate = calendar.advance(startDate, bondLength); Schedule schedule = new Schedule(startDate, endDate, bondLength, calendar, BusinessDayConvention.Unadjusted, BusinessDayConvention.Unadjusted, DateGeneration.Rule.Backward, false); bond = new MBSFixedRateBond(0, calendar, amount, startDate, bondLength, originalLength, payFrequency, WACrate, PassThroughRate, dCounter, psaCurve); return(bond); }