Assembla home | Assembla project page
 

Changeset 177

Show
Ignore:
Timestamp:
05/22/08 15:21:33 (4 months ago)
Author:
Vice
Message:

Found a bug in YieldTermStructure?. Created the test that exploit the bug ,
then fixed the bug.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QLNet/QLNet/Termstructures/YieldTermStructure.cs

    r108 r177  
    127127                double t2 = t1 + 0.0001; 
    128128                double compound = discount(t1, extrapolate) / discount(t2, extrapolate); 
    129                 return InterestRate.impliedRate(compound, t2 - t1, dayCounter(), comp, freq); 
     129                return InterestRate.impliedRate(compound, t2 - t1, resultDayCounter, comp, freq); 
    130130            } 
    131131            else 
     
    133133                if (!(d1 < d2)) throw new ArgumentException(d1 + " later than " + d2); 
    134134                double compound = discount(d1, extrapolate) / discount(d2, extrapolate); 
    135                 return InterestRate.impliedRate(compound, d1, d2, dayCounter(), comp, freq); 
     135                return InterestRate.impliedRate(compound, d1, d2, resultDayCounter, comp, freq); 
    136136            } 
    137137        } 
  • trunk/QLNet/Test2008/T_Piecewiseyieldcurve.cs

    r163 r177  
    2525namespace TestSuite { 
    2626    [TestClass()] 
    27     public class InterpolatedYieldCurveTest { 
    28         public class CommonVars { 
     27   public class T_Piecewiseyieldcurve 
     28   { 
     29        public class CommonVars  
     30        { 
    2931            #region Values 
    3032            public struct Datum { 
     
    125127 
    126128            // setup 
    127             public CommonVars() { 
     129            public CommonVars()  
     130            { 
    128131 
    129132                //cleaner = new IndexHistoryCleaner(); 
     
    319322        } 
    320323 
     324        [TestMethod()] 
     325        public void testForwardRateDayCounter() 
     326        { 
     327 
     328           CommonVars vars = new CommonVars(); 
     329           DayCounter d = new ActualActual(); 
     330           DayCounter d1 = new Actual360(); 
     331 
     332           vars.termStructure = new PiecewiseYieldCurve<Discount, LogLinear>(vars.settlementDays, 
     333                                                          vars.calendar, vars.instruments, d); 
     334 
     335           InterestRate ir = vars.termStructure.forwardRate(vars.settlement,vars.settlement+30, d1, Compounding.Simple); 
     336 
     337           if (ir.dayCounter().name() != d1.name()) 
     338              Assert.Fail("PiecewiseYieldCurve forwardRate dayCounter error" + 
     339                          " Actual daycounter : " + vars.termStructure.dayCounter().name() + 
     340                          " Expetced DayCounter : " + d1.name()); 
     341    
     342 
     343        } 
    321344 
    322345        public void testCurveConsistency<T, I>(CommonVars vars)