Exemplo n.º 1
0
        public Task OrderHistory(Order order, OrderUpdateType orderUpdateType, string activitiesMetadata = null)
        {
            var relatedOrders = new List <Order>();

            foreach (var relatedOrderInfo in order.RelatedOrders)
            {
                if (_orderReader.TryGetOrderById(relatedOrderInfo.Id, out var relatedOrder))
                {
                    relatedOrders.Add(relatedOrder);
                }
            }

            var historyEvent = new OrderHistoryEvent
            {
                OrderSnapshot      = order.ConvertToContract(relatedOrders),
                Timestamp          = _dateService.Now(),
                Type               = orderUpdateType.ToType <OrderHistoryTypeContract>(),
                ActivitiesMetadata = activitiesMetadata
            };

            return(TryProduceMessageAsync(_settings.RabbitMqQueues.OrderHistory.ExchangeName, historyEvent));
        }
 public async Task OrderHistory(Order order, OrderUpdateType orderUpdateType, string activitiesMetadata = null)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 3
0
 public Task OrderHistory(IOrder order, OrderUpdateType orderUpdateType)
 {
     return(TryProduceMessageAsync(_settings.RabbitMqQueues.OrderHistory.ExchangeName, order.ToFullContract(orderUpdateType)));
 }
Exemplo n.º 4
0
        public static OrderFullContract ToFullContract(this IOrder src, OrderUpdateType orderUpdateType)
        {
            var orderContract = new OrderFullContract
            {
                Id                      = src.Id,
                Code                    = src.Code,
                ClientId                = src.ClientId,
                AccountId               = src.AccountId,
                TradingConditionId      = src.TradingConditionId,
                AccountAssetId          = src.AccountAssetId,
                Instrument              = src.Instrument,
                Type                    = src.GetOrderType().ToType <OrderDirectionContract>(),
                CreateDate              = src.CreateDate,
                OpenDate                = src.OpenDate,
                CloseDate               = src.CloseDate,
                ExpectedOpenPrice       = src.ExpectedOpenPrice,
                OpenPrice               = src.OpenPrice,
                ClosePrice              = src.ClosePrice,
                QuoteRate               = src.GetFplRate(),
                MarginRate              = src.GetMarginRate(),
                AssetAccuracy           = src.AssetAccuracy,
                Volume                  = src.Volume,
                TakeProfit              = src.TakeProfit,
                StopLoss                = src.StopLoss,
                CommissionLot           = src.CommissionLot,
                OpenCommission          = src.GetOpenCommission(),
                CloseCommission         = src.GetCloseCommission(),
                SwapCommission          = src.SwapCommission,
                EquivalentAsset         = src.EquivalentAsset,
                OpenPriceEquivalent     = src.OpenPriceEquivalent,
                ClosePriceEquivalent    = src.ClosePriceEquivalent,
                OpenExternalOrderId     = src.OpenExternalOrderId,
                OpenExternalProviderId  = src.OpenExternalProviderId,
                CloseExternalOrderId    = src.CloseExternalOrderId,
                CloseExternalProviderId = src.CloseExternalProviderId,
                StartClosingDate        = src.StartClosingDate,
                Status                  = src.Status.ToType <OrderStatusContract>(),
                CloseReason             = src.CloseReason.ToType <OrderCloseReasonContract>(),
                FillType                = src.FillType.ToType <OrderFillTypeContract>(),
                RejectReason            = src.RejectReason.ToType <OrderRejectReasonContract>(),
                RejectReasonText        = src.RejectReasonText,
                Comment                 = src.Comment,
                MatchedVolume           = src.GetMatchedVolume(),
                MatchedCloseVolume      = src.GetMatchedCloseVolume(),
                PnL                     = src.GetTotalFpl(),
                Fpl                     = src.GetFpl(),
                InterestRateSwap        = src.GetSwaps(),
                MarginInit              = src.GetMarginInit(),
                MarginMaintenance       = src.GetMarginMaintenance(),
                OrderUpdateType         = orderUpdateType.ToType <OrderUpdateTypeContract>(),
                MatchingEngineMode      = src.MatchingEngineMode.ToType <MatchingEngineModeContract>(),
                LegalEntity             = src.LegalEntity,
            };

            foreach (var order in src.MatchedOrders)
            {
                orderContract.MatchedOrders.Add(order.ToBackendContract());
            }

            foreach (var order in src.MatchedCloseOrders)
            {
                orderContract.MatchedCloseOrders.Add(order.ToBackendContract());
            }

            return(orderContract);
        }