예제 #1
0
 private void RemoveOrder(BookDone removeOrder)
 {
     if (removeOrder.Side == SideType.Buy)
     {
         var offer = Buys.FirstOrDefault(a => a.OrderId == removeOrder.OrderId);
         if (offer != null)
         {
             Buys.Remove(offer);
         }
         else if (!RemoveReceiveOrder(removeOrder.OrderId))
         {
             Api.Log.Warning($"Order not found for {removeOrder.Reason} buy offer : {removeOrder.OrderId}");
         }
     }
     else
     {
         var offer = Sells.FirstOrDefault(b => b.OrderId == removeOrder.OrderId);
         if (offer != null)
         {
             Sells.Remove(offer);
         }
         else if (!RemoveReceiveOrder(removeOrder.OrderId))
         {
             Api.Log.Warning($"Order not found for {removeOrder.Reason} sell offer : {removeOrder.OrderId}");
         }
     }
 }
예제 #2
0
        private void UpdateOrder(BookChange changeOrder)
        {
            var offer = changeOrder.Side == SideType.Buy
                ? Buys.FirstOrDefault(a => a.OrderId == changeOrder.OrderId)
                : Sells.FirstOrDefault(b => b.OrderId == changeOrder.OrderId);

            if (offer != null)
            {
                offer.Price = changeOrder.Price;
                offer.Size  = changeOrder.NewSize;
            }
            else
            {
                Api.Log.Warning("Change receive for unknown order id");
                OpenOrder(new BookOpen {
                    OrderId = changeOrder.OrderId, Side = changeOrder.Side, Price = changeOrder.Price, RemainingSize = changeOrder.NewSize
                });
            }
        }