예제 #1
0
        public void GetEntitiesWithReturnSeriesShouldMapSingleEntityAndSingleReturn()
        {
            var testHelper = new EntityReturnsRepositoryTestHelper();

            testHelper
            .SetupGetAllEntities(c => c.AddPortfolio(100, "Port100"));

            testHelper.SetupGetReturnSeries(
                new[] { 100 },
                c => c.AddNetOfFeesReturnSeries(1000, 100));

            testHelper
            .SetupGetMonthlyReturns(new [] { 1000 },
                                    c => c.Add(new MonthlyReturnDto()
            {
                ReturnSeriesId = 1000, Year = 2000, Month = 1, ReturnValue = 0.1m
            }));

            var repository = testHelper.CreateEntityReturnsRepository();

            var results = repository.GetAllInvestmentVehicles();

            var expectedEntity = new InvestmentVehicle()
            {
                Number = 100,
                Name   = "Port100",
                InvestmentVehicleType = InvestmentVehicleType.Portfolio
            };

            var returnSeries = new MonthlyReturnSeries()
            {
                ReturnSeriesId = 1000, FeeType = FeeType.NetOfFees
            };

            expectedEntity.AddReturnSeries(returnSeries);

            returnSeries.AddReturn(new MonthYear(2000, 1), 0.1m);

            Assert.Equal(results[0], expectedEntity);
        }
        private InvestmentVehicle CreateTestBenchmark(
            int benchmarkNumber,
            MonthYear excludeMonth = null)
        {
            var benchmark000 = new InvestmentVehicle();

            benchmark000.Number = benchmarkNumber;
            benchmark000.Name   = "Benchmark" + benchmarkNumber;
            benchmark000.InvestmentVehicleType = InvestmentVehicleType.Benchmark;

            var bench000Series = new MonthlyReturnSeries();

            bench000Series.FeeType = FeeType.None;
            bench000Series.AddReturn(new MonthYear(1999, 5), 0.002m);
            bench000Series.AddReturn(new MonthYear(1999, 6), 0.003m);
            bench000Series.AddReturn(new MonthYear(1999, 7), 0.005m);
            bench000Series.AddReturn(new MonthYear(1999, 8), 0.006m);
            bench000Series.AddReturn(new MonthYear(1999, 9), 0.007m);
            bench000Series.AddReturn(new MonthYear(1999, 10), 0.008m);
            bench000Series.AddReturn(new MonthYear(1999, 11), 0.009m);
            bench000Series.AddReturn(new MonthYear(1999, 12), 0.010m);
            bench000Series.AddReturn(new MonthYear(2000, 1), 0.011m);
            bench000Series.AddReturn(new MonthYear(2000, 2), 0.012m);
            bench000Series.AddReturn(new MonthYear(2000, 3), 0.013m);
            bench000Series.AddReturn(new MonthYear(2000, 4), 0.014m);

            if (excludeMonth != null)
            {
                bench000Series.RemoveReturn(excludeMonth);
            }

            benchmark000.AddReturnSeries(bench000Series);

            return(benchmark000);
        }
        private InvestmentVehicle CreateTestPortfolio(
            int portfolioNumber,
            MonthYear excludeMonth = null)
        {
            var portfolio000 = new InvestmentVehicle();

            portfolio000.Number = portfolioNumber;
            portfolio000.Name   = "Portfolio" + portfolioNumber.ToString("000");
            portfolio000.InvestmentVehicleType = InvestmentVehicleType.Portfolio;

            var port000NetSeries = new MonthlyReturnSeries();

            port000NetSeries.FeeType = FeeType.NetOfFees;
            port000NetSeries.AddReturn(new MonthYear(1999, 5), -0.08m);
            port000NetSeries.AddReturn(new MonthYear(1999, 6), -0.07m);
            port000NetSeries.AddReturn(new MonthYear(1999, 7), -0.06m);
            port000NetSeries.AddReturn(new MonthYear(1999, 8), -0.05m);
            port000NetSeries.AddReturn(new MonthYear(1999, 9), -0.04m);
            port000NetSeries.AddReturn(new MonthYear(1999, 10), -0.03m);
            port000NetSeries.AddReturn(new MonthYear(1999, 11), -0.02m);
            port000NetSeries.AddReturn(new MonthYear(1999, 12), -0.01m);
            port000NetSeries.AddReturn(new MonthYear(2000, 1), 0.01m);
            port000NetSeries.AddReturn(new MonthYear(2000, 2), 0.02m);
            port000NetSeries.AddReturn(new MonthYear(2000, 3), 0.03m);
            port000NetSeries.AddReturn(new MonthYear(2000, 4), 0.04m);

            if (excludeMonth != null)
            {
                port000NetSeries.RemoveReturn(excludeMonth);
            }

            portfolio000.AddReturnSeries(port000NetSeries);

            var port000GrossSeries = new MonthlyReturnSeries();

            port000GrossSeries.FeeType = FeeType.GrossOfFees;
            port000GrossSeries.AddReturn(new MonthYear(1999, 5), -0.04m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 6), -0.03m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 7), -0.02m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 8), -0.01m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 9), 0.01m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 10), 0.02m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 11), 0.03m);
            port000GrossSeries.AddReturn(new MonthYear(1999, 12), 0.04m);
            port000GrossSeries.AddReturn(new MonthYear(2000, 1), 0.05m);
            port000GrossSeries.AddReturn(new MonthYear(2000, 2), 0.06m);
            port000GrossSeries.AddReturn(new MonthYear(2000, 3), 0.07m);
            port000GrossSeries.AddReturn(new MonthYear(2000, 4), 0.08m);

            if (excludeMonth != null)
            {
                port000GrossSeries.RemoveReturn(excludeMonth);
            }

            portfolio000.AddReturnSeries(port000GrossSeries);

            return(portfolio000);
        }
        public void RemoveReturnShouldRemoveTheReturnWithTheGivenMonth()
        {
            var month = new MonthYear(2013, 1);

            _returnSeries.AddReturn(month, 0.1m);

            _returnSeries.RemoveReturn(month);

            var returnsInRange = _returnSeries.GetReturnsInRange(new MonthYearRange(month, month));

            Assert.Equal(0, returnsInRange.Length);
        }