public void CoupdaysNc_ShouldReturnNumberOfDays_ActualActual() { var settlement = new DateTime(2016, 02, 01); var maturity = new DateTime(2019, 5, 31); var func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.Actual_Actual), FinancialDayFactory.Create(maturity, DayCountBasis.Actual_Actual), 4, DayCountBasis.Actual_Actual ); var result = func.Coupdaysnc(); Assert.AreEqual(28d, result.Result); settlement = new DateTime(2016, 05, 30); maturity = new DateTime(2019, 5, 31); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.Actual_Actual), FinancialDayFactory.Create(maturity, DayCountBasis.Actual_Actual), 4, DayCountBasis.Actual_Actual ); result = func.Coupdaysnc(); Assert.AreEqual(1d, result.Result); }
public void CoupdaysNc_ShouldReturnNumberOfDays_Us_30_360() { var settlement = new DateTime(2016, 02, 01); var maturity = new DateTime(2019, 5, 31); var func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.US_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.US_30_360), 4, DayCountBasis.US_30_360 ); var result = func.Coupdaysnc(); Assert.AreEqual(29d, result.Result); settlement = new DateTime(2016, 05, 30); maturity = new DateTime(2019, 5, 31); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.US_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.US_30_360), 4, DayCountBasis.US_30_360 ); result = func.Coupdaysnc(); Assert.AreEqual(0d, result.Result); settlement = new DateTime(2018, 08, 01); maturity = new DateTime(2019, 03, 15); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.US_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.US_30_360), 4, DayCountBasis.US_30_360 ); result = func.Coupdaysnc(); Assert.AreEqual(44d, result.Result); // NB! Excel returns 29 on this one. Google sheets returns 28. As far as we can see it should be // 28, so that's how we have implemented it in EPPlus settlement = new DateTime(2018, 08, 01); maturity = new DateTime(2020, 02, 29); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.US_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.US_30_360), 4, DayCountBasis.US_30_360 ); result = func.Coupdaysnc(); Assert.AreEqual(28d, result.Result); }
public void CoupdaysNc_ShouldReturnNumberOfDays_European_30_360() { var settlement = new DateTime(2016, 02, 01); var maturity = new DateTime(2019, 5, 31); var func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.European_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.European_30_360), 4, DayCountBasis.European_30_360 ); var result = func.Coupdaysnc(); Assert.AreEqual(28d, result.Result); settlement = new DateTime(2016, 05, 30); maturity = new DateTime(2019, 5, 31); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.European_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.European_30_360), 4, DayCountBasis.European_30_360 ); result = func.Coupdaysnc(); Assert.AreEqual(0d, result.Result); settlement = new DateTime(2018, 08, 01); maturity = new DateTime(2019, 03, 15); func = new CoupdaysncImpl( FinancialDayFactory.Create(settlement, DayCountBasis.European_30_360), FinancialDayFactory.Create(maturity, DayCountBasis.European_30_360), 4, DayCountBasis.European_30_360 ); result = func.Coupdaysnc(); Assert.AreEqual(44d, result.Result); }
protected override FinanceCalcResult <double> ExecuteFunction(FinancialDay settlementDate, FinancialDay maturityDate, int frequency, DayCountBasis basis = DayCountBasis.US_30_360) { var impl = new CoupdaysncImpl(settlementDate, maturityDate, frequency, basis); return(impl.Coupdaysnc()); }