Exemplo n.º 1
0
 public Tick(Tick tick)
     : base(tick)
 {
     this.providerId = tick.providerId;
     this.instrumentId = tick.instrumentId;
     this.price = tick.price;
     this.size = tick.size;
 }
Exemplo n.º 2
0
 public Tick(Tick tick)
     : base(tick)
 {
     this.ProviderId = tick.ProviderId;
     this.InstrumentId = tick.InstrumentId;
     this.Price = tick.Price;
     this.Size = tick.Size;
 }
Exemplo n.º 3
0
 private void Process(Order order, OrderBook curOrderBook)
 {
     if (!order.isQueueCalculated)
     {
         this.SetQueueSizeByOrderBook(order);
     }
     if (order.type == OrderType.Limit)
     {
         if (curOrderBook.bids.Count == 0 || curOrderBook.asks.Count == 0)
         {
             return;
         }
         if (order.isOutPrice)
         {
             double queueSize = order.queueSize;
             this.SetQueueSizeByOrderBook(order);
             if (order.isOutPrice)
             {
                 order.queueSize = queueSize;
             }
         }
         if (order.side == OrderSide.Buy)
         {
             if (curOrderBook.bids[0].price < order.price)
             {
                 order.queueSize = 0.0;
                 this.Fill(order, curOrderBook.bids[0].price, (int)order.leavesQty);
                 return;
             }
             Tick tick = null;
             for (int i = 0; i < curOrderBook.bids.Count; i++)
             {
                 tick = curOrderBook.bids[i];
                 if (tick.Price == order.price)
                 {
                     break;
                 }
             }
             if (tick != null && order.queueSize > (double)tick.size + order.qty)
             {
                 order.queueSize = (double)tick.size + order.qty;
                 return;
             }
         }
         else
         {
             if (order.side == OrderSide.Sell)
             {
                 if (curOrderBook.asks[0].price > order.price)
                 {
                     order.queueSize = 0.0;
                     this.Fill(order, curOrderBook.asks[0].price, (int)order.leavesQty);
                     return;
                 }
                 Tick tick2 = null;
                 for (int j = 0; j < curOrderBook.asks.Count; j++)
                 {
                     tick2 = curOrderBook.asks[j];
                     if (tick2.price == order.price)
                     {
                         break;
                     }
                 }
                 if (tick2 != null && order.queueSize > (double)tick2.size + order.qty)
                 {
                     order.queueSize = (double)tick2.size + order.qty;
                     return;
                 }
             }
         }
     }
     else
     {
         if (order.side == OrderSide.Buy && curOrderBook.asks.Count > 0)
         {
             Tick tick3 = null;
             for (int k = 0; k < curOrderBook.asks.Count; k++)
             {
                 tick3 = curOrderBook.asks[k];
                 if ((double)tick3.size >= order.leavesQty)
                 {
                     this.Fill(order, tick3.price, (int)order.leavesQty);
                     break;
                 }
                 this.Fill(order, tick3.price, tick3.size);
             }
             if (tick3 != null && order.leavesQty > 0.0)
             {
                 double num  = tick3.price + order.instrument.tickSize;
                 double num2 = Math.Ceiling(order.leavesQty / (double)tick3.size);
                 if (num2 >= 1.0)
                 {
                     int num3 = 0;
                     while ((double)num3 < num2)
                     {
                         if (order.leavesQty >= (double)tick3.size)
                         {
                             this.Fill(order, num + (double)num3 * order.instrument.tickSize, tick3.size);
                         }
                         else
                         {
                             if (order.leavesQty < (double)tick3.size)
                             {
                                 this.Fill(order, num + (double)num3 * order.instrument.tickSize, (int)order.leavesQty);
                                 return;
                             }
                         }
                         num3++;
                     }
                     return;
                 }
                 this.Fill(order, num, (int)order.leavesQty);
                 return;
             }
         }
         else
         {
             if (order.side == OrderSide.Sell && curOrderBook.bids.Count > 0)
             {
                 Tick tick4 = null;
                 for (int l = 0; l < curOrderBook.bids.Count; l++)
                 {
                     tick4 = curOrderBook.bids[l];
                     if ((double)tick4.Size >= order.leavesQty)
                     {
                         this.Fill(order, tick4.price, (int)order.leavesQty);
                         break;
                     }
                     this.Fill(order, tick4.price, tick4.size);
                 }
                 if (tick4 != null && order.leavesQty > 0.0)
                 {
                     double num4 = tick4.price - order.instrument.tickSize;
                     double num5 = Math.Ceiling(order.leavesQty / (double)tick4.size);
                     if (num5 >= 1.0)
                     {
                         int num6 = 0;
                         while ((double)num6 < num5)
                         {
                             if (order.leavesQty >= (double)tick4.size)
                             {
                                 this.Fill(order, num4 - (double)num6 * order.instrument.tickSize, tick4.size);
                             }
                             else
                             {
                                 if (order.leavesQty < (double)tick4.size)
                                 {
                                     this.Fill(order, num4 - (double)num6 * order.instrument.tickSize, (int)order.leavesQty);
                                     return;
                                 }
                             }
                             num6++;
                         }
                         return;
                     }
                     this.Fill(order, num4, (int)order.leavesQty);
                 }
             }
         }
     }
 }