public async Task Handle(PartialTransactionEvent @event)
        {
            var state = await GetState(@event.Id);

            await messageBus.SendAsync(new OrderReportingMessage
            {
                Event = ClientAdapter.Messages.Orders.Events.PartialDeal,
                State = state
            });
        }
        public async Task Handle(PartialTransactionEvent @event)
        {
            var transaction = new UpdateOrderTransaction();

            transaction.Status   = (int)OrderStatus.PartialTransaction;
            transaction.Volume   = @event.Amount;
            transaction.Id       = @event.Id.ToString();
            transaction.DateTime = @event.DateTime.DateTime;

            await bus.SendAsync(transaction);
        }
예제 #3
0
        public void Deal(TransactionInfo info)
        {
            if (Status == OrderStatus.FullCanceled ||
                Status == OrderStatus.PartialCanceled ||
                Status == OrderStatus.Canceling)
            {
                throw new OrderIsCanceledException("订单已被取消");
            }
            if (Status == OrderStatus.FullTransaction)
            {
                throw new OrderHasBeenDealException("订单已完全成交");
            }
            if (info.Amount <= 0)
            {
                throw new InvalidValueException("数量:Amount不大于0");
            }
            if (info.Price <= 0)
            {
                throw new InvalidValueException("价格:Price不大于0");
            }

            var   volume = Volume + info.Amount;
            Event @event = null;

            if (volume > TotalAmount)
            {
                throw new InvalidValueException("成交量大于委托总量");
            }

            else if (volume == TotalAmount)
            {
                @event = new FullTransactionEvent
                {
                    Id       = Id,
                    Amount   = volume,
                    Price    = info.Price,
                    DateTime = DateTimeOffset.UtcNow
                };
            }
            else
            {
                @event = new PartialTransactionEvent
                {
                    Id       = Id,
                    Amount   = volume,
                    Price    = info.Price,
                    DateTime = DateTimeOffset.UtcNow
                };
            }

            ApplyEvent(@event);
        }
예제 #4
0
 public void Handle(PartialTransactionEvent @event)
 {
     Price  = @event.Price;
     Volume = @event.Amount;
     Status = OrderStatus.PartialTransaction;
 }