Exemplo n.º 1
0
        internal static TransactionData ToTransactionData(Token token, XmlNode tran)
        {
            string tranCode = string.Empty;

            Protocal.TransactionData tranData = TransactionParser.ParseTransaction(tran);
            tranData.PlaceByRiskMonitor = token.AppType == AppType.RiskMonitor ? true : false;
            tranData.Id     = Guid.Parse(tran.Attributes["ID"].Value);
            tranData.Orders = new List <OrderData>();

            InstrumentCategory instrumentCategory = InstrumentCategory.Forex;

            if (tran.Attributes["InstrumentCategory"] != null)
            {
                instrumentCategory = (InstrumentCategory)Enum.Parse(typeof(InstrumentCategory), tran.Attributes["InstrumentCategory"].Value);
            }

            foreach (XmlNode orderNode in tran.ChildNodes)
            {
                if (orderNode.Name == "Order")
                {
                    OrderData orderData = null;
                    if (tranData.OrderType == OrderType.BinaryOption)
                    {
                        orderData = OrderDataHelper.InitializeBOData(orderNode);
                    }
                    else if (instrumentCategory == InstrumentCategory.Forex)
                    {
                        orderData = OrderDataHelper.Initialize(orderNode);
                    }
                    else
                    {
                        orderData = OrderDataHelper.InitializePhysicalData(orderNode);
                    }
                    tranData.Orders.Add(orderData);
                }
            }

            return(tranData);
        }