Ejemplo n.º 1
0
        internal static TransactionBookData ToTransactionBookData(XmlNode tranNode)
        {
            string tranCode = string.Empty;
            Guid?  orderBatchInstructionId;
            TransactionBookData tranData = TransactionParser.ParseTransactionBookData(tranNode, out orderBatchInstructionId);

            tranData.Id     = Guid.Parse(tranNode.Attributes["ID"].Value);
            tranData.Orders = new List <OrderBookData>();

            var instrument = InstrumentManager.Default.Get(tranData.InstrumentId);
            InstrumentCategory instrumentCategory = instrument.Category;

            foreach (XmlNode orderNode in tranNode.ChildNodes)
            {
                if (orderNode.Name == "Order")
                {
                    OrderBookData orderData = null;
                    if (instrumentCategory == InstrumentCategory.Forex)
                    {
                        orderData = OrderDataHelper.InitializeBookData(orderNode);
                    }
                    else
                    {
                        orderData = OrderDataHelper.InitalizePhysicalBookData(orderNode);
                    }
                    orderData.OrderBatchInstructionID = orderBatchInstructionId;
                    tranData.Orders.Add(orderData);
                }
            }
            tranData.PlaceByRiskMonitor = true;
            return(tranData);
        }
Ejemplo n.º 2
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);
        }