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);
        }
示例#2
0
        public MonthlyReturn[] GetReturnsInRange(
            MonthYearRange monthRange,
            FeeType feeType)
        {
            var netReturnSeries = GetReturnSeries(feeType);

            if (netReturnSeries == null)
            {
                return(new MonthlyReturn[0]);
            }

            return(netReturnSeries.GetReturnsInRange(monthRange));
        }
示例#3
0
        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());;
 }
示例#5
0
 public MonthlyReturn[] GetGrossReturnsInRange(
     MonthYearRange monthRange)
 {
     return(GetReturnsInRange(monthRange, FeeType.GrossOfFees));
 }
 public OmniDataFileLineModelFactory(
     MonthYear endEndMonth)
 {
     _endMonth            = endEndMonth;
     _januaryToGivenMonth = CreateRangeFromJanuaryToGivenMonth(endEndMonth);
 }
示例#7
0
 public static IEnumerable <MonthlyReturn> GetMonthsInRange(
     this IEnumerable <MonthlyReturn> allReturns,
     MonthYearRange monthYearRange)
 {
     return(allReturns.Where(r => monthYearRange.IsMonthInRange(r.MonthYear)));
 }