/// <summary>
        /// Cancellation order result callback.
        /// </summary>
        /// <param name="cancelTransId">Cancellation transaction id.</param>
        /// <param name="orderId">Order ID.</param>
        /// <param name="data">Cancellation result.</param>
        /// <param name="ex">Error cancellation.</param>
        private void ClientOnOrderCancelResult(long cancelTransId, long orderId, CancelOrderResponse2 data, Exception ex)
        {
            if (ex != null)
            {
                this.AddWarningLog("CancelOrder: {0}", ex);

                SendOutMessage(new ExecutionMessage
                {
                    OriginalTransactionId = cancelTransId,
                    ExecutionType         = ExecutionTypes.Transaction,
                    OrderState            = OrderStates.Failed,
                    Error = new InvalidOperationException(LocalizedStrings.Str3373Params.Put(orderId, ex)),
                });

                return;
            }

            var msg = new ExecutionMessage
            {
                OriginalTransactionId = cancelTransId,
                OrderId       = orderId,
                PortfolioName = data.accountId.To <string>(),
                ExecutionType = ExecutionTypes.Transaction,
                OrderStatus   = OrderStatus.SentToCanceled,
                ServerTime    = ETradeUtil.ETradeTimestampToUTC(data.cancelTime)
            };

            this.AddDebugLog("ord #{0}: {1}", orderId, data.resultMessage);

            SendOutMessage(msg);
        }
        /// <summary>
        /// Callback of the order (re)registration.
        /// </summary>
        /// <param name="transId">Transaction ID.</param>
        /// <param name="data">(Re)registration result.</param>
        /// <param name="ex">(Re)registration error.</param>
        private void ClientOnOrderRegisterResult(long transId, PlaceEquityOrderResponse2 data, Exception ex)
        {
            if (ex != null)
            {
                this.AddWarningLog("RegisterOrder: {0}", ex);
                SendOutMessage(new ExecutionMessage
                {
                    OriginalTransactionId = transId,
                    OrderState            = OrderStates.Failed,
                    Error         = new InvalidOperationException(LocalizedStrings.Str2258Params.Put(transId, ex)),
                    OrderStatus   = OrderStatus.RejectedBySystem,
                    ExecutionType = ExecutionTypes.Transaction,
                    HasOrderInfo  = true,
                });
                return;
            }

            var msg = new ExecutionMessage
            {
                SecurityId = new SecurityId {
                    SecurityCode = data.symbol, BoardCode = AssociatedBoardCode
                },
                PortfolioName         = data.accountId.To <string>(),
                Side                  = data.orderAction.ETradeActionToSide(),
                OriginalTransactionId = transId,
                OrderState            = OrderStates.Active,
                OrderId               = data.orderNum,
                ExecutionType         = ExecutionTypes.Transaction,
                ServerTime            = ETradeUtil.ETradeTimestampToUTC(data.orderTime),
                HasOrderInfo          = true,
            };

            SaveOrder(transId, msg.OrderId ?? 0);

            if (data.messageList != null)
            {
                foreach (var m in data.messageList)
                {
                    this.AddDebugLog("ord #{0}: ({1}) {2}", data.orderNum, m.msgCode, m.msgDesc);
                }
            }

            SendOutMessage(msg);
        }
        /// <summary>Коллбэк результата запроса списка заявок.</summary>
        /// <param name="portName">Имя портфеля.</param>
        /// <param name="data">Результат запроса списка заявок.</param>
        /// <param name="ex">Ошибка запроса списка заявок.</param>
        private void ClientOnOrdersData(string portName, IEnumerable <Order> data, Exception ex)
        {
            if (ex != null)
            {
                SendOutError(ex);
                return;
            }

            foreach (var nativeOrder in data)
            {
                if (!IsOrderSupported(nativeOrder))
                {
                    continue;
                }

                var leg = nativeOrder.legDetails[0];

                var secId = new SecurityId
                {
                    SecurityCode = leg.symbolInfo.symbol,
                    BoardCode    = AssociatedBoardCode
                };

                var transId = _ordersByTransactionId.TryGetKey(nativeOrder.orderId);
                if (transId == 0)
                {
                    transId = TransactionIdGenerator.GetNextId();
                    SaveOrder(transId, nativeOrder.orderId);
                }

                var tuple = _orderStateMap[nativeOrder.orderStatus];

                var msg = new ExecutionMessage
                {
                    SecurityId            = secId,
                    PortfolioName         = portName,
                    Side                  = leg.orderAction.ETradeActionToSide(),
                    OrderPrice            = nativeOrder.limitPrice.To <decimal>(),
                    OrderVolume           = leg.orderedQuantity.To <decimal>(),
                    Balance               = (leg.orderedQuantity - leg.filledQuantity).To <decimal>(),
                    OriginalTransactionId = transId,
                    OrderId               = nativeOrder.orderId,
                    ExecutionType         = ExecutionTypes.Transaction,
                    OrderType             = nativeOrder.priceType.ETradePriceTypeToOrderType(),
                    ServerTime            = ETradeUtil.ETradeTimestampToUTC(nativeOrder.orderExecutedTime > 0 ? nativeOrder.orderExecutedTime : nativeOrder.orderPlacedTime),
                    OrderState            = tuple.Item1,
                    OrderStatus           = tuple.Item2,
                };

                switch (msg.OrderType)
                {
                case OrderTypes.Limit:
                {
                    msg.OrderPrice = (decimal)nativeOrder.limitPrice;
                    break;
                }

                case OrderTypes.Conditional:
                {
                    if (nativeOrder.priceType == "STOP")
                    {
                        msg.Condition = new ETradeOrderCondition
                        {
                            StopType  = ETradeStopTypes.StopMarket,
                            StopPrice = (decimal)nativeOrder.stopPrice
                        };
                    }
                    else if (nativeOrder.priceType == "STOP_LIMIT")
                    {
                        msg.Condition = new ETradeOrderCondition
                        {
                            StopType  = ETradeStopTypes.StopLimit,
                            StopPrice = (decimal)nativeOrder.stopPrice
                        };
                        msg.OrderPrice = nativeOrder.limitPrice.To <decimal>();
                    }
                    else
                    {
                        this.AddErrorLog(LocalizedStrings.Str3374Params, nativeOrder.priceType);
                    }

                    break;
                }
                }

                SendOutMessage(msg);
            }
        }