public void CanCalculateLinkedReturnsWithCumReturnsMonthToEnd() { var janSP500returns = sp500 .Where(r => r.EffectiveDate.Month == 1) .Select(r => r.TotalReturn) .ToList(); var cumReturns = FinCalcs.ReturnsToMonthEnd(janSP500returns); var longCalc = FinCalcs.LinkedReturns( periodReturns: janSP500returns, startPeriod: 0, endPeriod: janSP500returns.Count() - 1); var quickCalc = FinCalcs.LinkedReturns( returnToMonthEnd: cumReturns, startingPeriodReturn: janSP500returns.ElementAt(0), startPeriod: 0, endPeriod: janSP500returns.Count() - 1 ); Assert.AreEqual( Math.Round(longCalc, 6), Math.Round(quickCalc, 6)); }
public void CanCalculateReturnToMonthEnd() { var cumReturns = FinCalcs.ReturnsToMonthEnd( sp500 .Where(r => r.EffectiveDate.Month == 1) .Select(r => r.TotalReturn) .ToList() ); Assert.AreEqual(0.990074m, Math.Round(cumReturns.First(), 6)); Assert.AreEqual(1m, Math.Round(cumReturns.Last())); }