private bool ProcessOrderStatusMessage(OrderStatusMessage message)
        {
            if (message.HasOrderId())
            {
                return(base.OnSendInMessage(message));
            }

            return(ProcessInSubscriptionMessage(message));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process <see cref="OrderStatusMessage"/>.
        /// </summary>
        /// <param name="message">A message requesting current registered orders and trades.</param>
        /// <returns>A message requesting current registered orders and trades.</returns>
        private OrderStatusMessage ProcessOrderStatus(OrderStatusMessage message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (!message.IsSubscribe)
            {
                return(message);
            }

            var transId = message.TransactionId;

            _orderStatusIds.Add(transId);

            if (!message.HasOrderId() && message.OriginalTransactionId == 0 && Settings.DaysLoad > TimeSpan.Zero)
            {
                var from = message.From ?? DateTime.UtcNow.Date - Settings.DaysLoad;
                var to   = message.To;

                if (Settings.IsMode(StorageModes.Snapshot))
                {
                    var storage = (ISnapshotStorage <string, ExecutionMessage>)GetSnapshotStorage(DataType.Transactions);

                    foreach (var snapshot in storage.GetAll(from, to))
                    {
                        snapshot.OriginalTransactionId = transId;
                        snapshot.SetSubscriptionIds(subscriptionId: transId);
                        RaiseNewOutMessage(snapshot);

                        from = snapshot.ServerTime;
                    }

                    if (from >= to)
                    {
                        return(null);
                    }

                    message.From = from;
                }
                else if (Settings.IsMode(StorageModes.Incremental))
                {
                    if (!message.SecurityId.IsDefault())
                    {
                        // TODO restore last actual state from incremental messages

                        //GetStorage<ExecutionMessage>(msg.SecurityId, ExecutionTypes.Transaction)
                        //	.Load(from, to)
                        //	.ForEach(RaiseStorageMessage);
                    }
                }
            }

            return(message);
        }
        private void ProcessOrderStatusMessage(OrderStatusMessage message)
        {
            if (message.HasOrderId())
            {
                base.OnSendInMessage(message);
                return;
            }

            ProcessInSubscriptionMessage(message, DataType.Transactions);
        }