public ReturnResult CalculateReturn( CalculateReturnRequest request) { var monthRange = MonthYearRange.CreateForEndMonthAndMonthsBack(request.EndMonth, request.NumberOfMonths); var returnsInRange = _monthlyReturns.GetMonthsInRange(monthRange).ToArray(); var result = new ReturnResult(); if (returnsInRange.Any()) { if (returnsInRange.WeDoNotHaveExactlyOneReturnPerMonth(monthRange)) { result.SetError("Could not find a complete / unique set of months."); return(result); } result = PerformReturnCalculation(request, returnsInRange, result); } else { result.SetError("Could not find return(s) for month(s)."); } return(result); }
public MonthlyReturn[] GetReturnsInRange( MonthYearRange monthRange, FeeType feeType) { var netReturnSeries = GetReturnSeries(feeType); if (netReturnSeries == null) { return(new MonthlyReturn[0]); } return(netReturnSeries.GetReturnsInRange(monthRange)); }
public static bool WeDoNotHaveExactlyOneReturnPerMonth( this IEnumerable <MonthlyReturn> allReturns, MonthYearRange monthYearRange) { var exactlyOneMonth = true; monthYearRange.ForEachMonthInRange( m => { if (allReturns.Count(r => r.MonthYear == m) != 1) { exactlyOneMonth = false; } }); return(!exactlyOneMonth); }
public MonthlyReturn[] GetReturnsInRange( MonthYearRange monthRange) { return(_monthlyReturns .GetMonthsInRange(monthRange).ToArray());; }
public MonthlyReturn[] GetGrossReturnsInRange( MonthYearRange monthRange) { return(GetReturnsInRange(monthRange, FeeType.GrossOfFees)); }
public OmniDataFileLineModelFactory( MonthYear endEndMonth) { _endMonth = endEndMonth; _januaryToGivenMonth = CreateRangeFromJanuaryToGivenMonth(endEndMonth); }
public static IEnumerable <MonthlyReturn> GetMonthsInRange( this IEnumerable <MonthlyReturn> allReturns, MonthYearRange monthYearRange) { return(allReturns.Where(r => monthYearRange.IsMonthInRange(r.MonthYear))); }