예제 #1
0
        private void AddCompositeAction(Stock stock, RestApi.CorporateActions.CompositeAction corporateAction)
        {
            var builder = stock.CorporateActions.StartCompositeAction(corporateAction.Id, corporateAction.ActionDate, corporateAction.Description);

            foreach (var childAction in corporateAction.ChildActions)
            {
                if (childAction is RestApi.CorporateActions.CapitalReturn capitalReturn)
                {
                    builder.AddCapitalReturn(capitalReturn.Description, capitalReturn.PaymentDate, capitalReturn.Amount);
                }
                else if (childAction is RestApi.CorporateActions.Dividend dividend)
                {
                    builder.AddDividend(dividend.Description, dividend.PaymentDate, dividend.Amount, dividend.PercentFranked, dividend.DrpPrice);
                }
                else if (childAction is RestApi.CorporateActions.SplitConsolidation splitConsolidation)
                {
                    builder.AddSplitConsolidation(splitConsolidation.Description, splitConsolidation.OriginalUnits, splitConsolidation.NewUnits);
                }
                else if (childAction is RestApi.CorporateActions.Transformation transformation)
                {
                    var resultingStocks = transformation.ResultingStocks.Select(x => new Domain.CorporateActions.Transformation.ResultingStock(x.Stock, x.OriginalUnits, x.NewUnits, x.CostBase, x.AquisitionDate));
                    builder.AddTransformation(transformation.Description, transformation.ImplementationDate, transformation.CashComponent, transformation.RolloverRefliefApplies, resultingStocks);
                }
            }
            builder.Finish();
        }
        public static RestApi.CorporateActions.CompositeAction ToResponse(this Domain.CorporateActions.CompositeAction action)
        {
            var response = new RestApi.CorporateActions.CompositeAction();

            PopulateCorporateAction(response, action);

            var childActions = action.ChildActions.Select(x => x.ToResponse());

            response.ChildActions.AddRange(childActions);

            return(response);
        }
        public void AddCompositeAction()
        {
            var action = new RestApi.CorporateActions.CompositeAction()
            {
                Id          = Guid.NewGuid(),
                Stock       = _StockWithoutCorporateActions,
                ActionDate  = new Date(2001, 01, 01),
                Description = "Restructure"
            };

            action.ChildActions.Add(new RestApi.CorporateActions.CapitalReturn()
            {
                Id          = Guid.NewGuid(),
                Stock       = _StockWithoutCorporateActions,
                ActionDate  = new Date(2001, 01, 01),
                Description = "Capital Return",
                PaymentDate = new Date(2001, 01, 15),
                Amount      = 10.00m
            });
            action.ChildActions.Add(new RestApi.CorporateActions.SplitConsolidation()
            {
                Id            = Guid.NewGuid(),
                Stock         = _StockWithoutCorporateActions,
                ActionDate    = new Date(2001, 01, 01),
                Description   = "Split",
                OriginalUnits = 1,
                NewUnits      = 2
            });

            var result = _Service.AddCorporateAction(_StockWithoutCorporateActions, action);

            result.Should().HaveOkStatus();

            var @event = new CompositeActionAddedEvent(_StockWithoutCorporateActions, 1, action.Id, new Date(2001, 01, 01), "Restructure");

            @event.ChildActions.Add(new CapitalReturnAddedEvent(_StockWithoutCorporateActions, 1, action.Id, new Date(2001, 01, 01), "Capital Return", new Date(2001, 01, 15), 10.00m));
            @event.ChildActions.Add(new SplitConsolidationAddedEvent(_StockWithoutCorporateActions, 1, action.Id, new Date(2001, 01, 01), "Split", 1, 2));
            _Events.Should().BeEquivalentTo(new[] { @event }, x => x.Excluding(x => x.ChildActions[0].ActionId).Excluding(x => x.ChildActions[1].ActionId));
        }
예제 #4
0
        public void AddCompositeAction()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stockId  = Guid.NewGuid();
            var actionId = Guid.NewGuid();
            var action   = new RestApi.CorporateActions.CompositeAction()
            {
                Id = actionId
            };

            var service = mockRepository.Create <ICorporateActionService>();

            service.Setup(x => x.AddCorporateAction(stockId, It.IsAny <RestApi.CorporateActions.CompositeAction>())).Returns(ServiceResult.Ok()).Verifiable();

            var controller = new CorporateActionController(service.Object);
            var result     = controller.AddCorporateAction(stockId, action);

            result.Should().BeOkResult();

            mockRepository.VerifyAll();
        }