Exemplo n.º 1
0
        private void Client_MyOrderEvent(int numUser, string portfolio, PrivateOrderRawEvent orderInfo)
        {
            lock (_orderLocker)
            {
                var needOrder = _myOrders.Find(o => o.NumberUser == numUser);

                if (needOrder == null)
                {
                    return;
                }

                var order = new OsEngine.Entity.Order();
                order.NumberUser       = numUser;
                order.PortfolioNumber  = portfolio;
                order.SecurityNameCode = needOrder.SecurityNameCode;

                if (orderInfo.Id == -1)
                {
                    order.State        = OrderStateType.Fail;
                    order.Price        = needOrder.Price;
                    order.Volume       = needOrder.Volume;
                    order.Side         = needOrder.Side;
                    order.NumberMarket = needOrder.NumberMarket;

                    MyOrderEvent?.Invoke(order);

                    return;
                }

                order.NumberMarket = orderInfo.Id.ToString();
                order.Price        = ParseDecimal(orderInfo.Price);
                order.TimeCallBack = new DateTime(1970, 1, 1).AddMilliseconds(Convert.ToDouble(orderInfo.Timestamp));
                order.Volume       = needOrder.Volume;
                order.Side         = orderInfo.order_type == PrivateOrderRawEvent.OrderType.Bid ? Side.Buy : Side.Sell;

                decimal quantity     = ParseDecimal(orderInfo.Quantity);
                decimal cancelVolume = ParseDecimal(orderInfo.QuantityLeftBeforeCancellation);

                if (quantity == 0 && cancelVolume == needOrder.Volume)
                {
                    order.State = OrderStateType.Cancel;
                    DelOrder(needOrder);
                }
                else if (quantity == 0 && cancelVolume == 0)
                {
                    order.State = OrderStateType.Done;
                    DelOrder(needOrder);
                }
                else if (quantity == order.Volume)
                {
                    order.State = OrderStateType.Activ;
                }
                else if (needOrder.Volume != quantity && quantity != 0)
                {
                    order.State = OrderStateType.Patrial;
                }

                MyOrderEvent?.Invoke(order);
            }
        }
Exemplo n.º 2
0
        public void SendOrder(OsEngine.Entity.Order order)
        {
            lock (_locker)
            {
                _myOrders.Add(order);
            }

            _client.SendOrder(order);
        }
Exemplo n.º 3
0
 public void CanselOrder(OsEngine.Entity.Order order)
 {
     _client.CancelLimitOrder(order);
 }