Ejemplo n.º 1
0
        /// <summary>
        /// Находит и обновляет заявку. Известно, что заявка существует
        /// </summary>
        /// <param name="ev"></param>
        private void UpdateOrder(UpdateOrderEvent ev)
        {
            int index = FindBuyOrderIndex(ev.OrderId, ev.Cookie);

            if (index != -1)
            {
                if (ev.Filled <= 0 || ev.Amount <= 0)
                {
                    BuyOrders.RemoveAt(index);
                }
                else
                {
                    BuyOrders[index].Cookie       = ev.Cookie;
                    BuyOrders[index].FilledVolume = (int)ev.Filled;
                    BuyOrders[index].OrderId      = ev.OrderId;
                    BuyOrders[index].Price        = ev.Price;
                    BuyOrders[index].StopPrice    = ev.Stop;
                    BuyOrders[index].Type         = Server.OrderTypeCast(ev.Type);
                    BuyOrders[index].Volume       = (int)ev.Amount;
                    BuyOrders[index].Action       = Server.ActionCast(ev.Action);
                }
            }
            else
            {
                index = FindSellOrderIndex(ev.OrderId, ev.Cookie);
                if (index != -1)
                {
                    if (ev.Filled <= 0 || ev.Amount <= 0)
                    {
                        SellOrders.RemoveAt(index);
                    }
                    else
                    {
                        SellOrders[index].Cookie       = ev.Cookie;
                        SellOrders[index].FilledVolume = (int)ev.Filled;
                        SellOrders[index].OrderId      = ev.OrderId;
                        SellOrders[index].Price        = ev.Price;
                        SellOrders[index].StopPrice    = ev.Stop;
                        SellOrders[index].Type         = Server.OrderTypeCast(ev.Type);
                        SellOrders[index].Volume       = (int)ev.Amount;
                        SellOrders[index].Action       = Server.ActionCast(ev.Action);
                    }
                }
            }
        }