Inheritance: DataObject
Ejemplo n.º 1
0
 public Trade(Tick tick) : base(tick)
 {
 }
Ejemplo n.º 2
0
        // TODO: rewrite it using goto statement!!!
        internal void OnData(DataObject obj)
        {
            /*
                        var tick = (Tick)obj;
                        var items = ItemLists[tick.InstrumentId];
                        if (items == null)
                            return;

                        int i = 0;
                        while (i < items.Count)
                        {
                            var item = items[i];
                            switch (item.barInput)
                            {
                                case BarInput.Trade:
                                    if (tick.TypeId == DataObjectType.Trade)
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                    break;
                                case BarInput.Bid:
                                    if (tick.TypeId == DataObjectType.Bid)
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                    break;
                                case BarInput.Ask:
                                    if (tick.TypeId == DataObjectType.Ask)
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                    break;
                                case BarInput.Middle:
                                    switch (tick.TypeId)
                                    {
                                        case DataObjectType.Bid:
                                            {
                                                var ask = this.framework.DataManager.GetAsk(tick.InstrumentId);
                                                if (ask == null)
                                                {
                                                    i++;
                                                    continue;
                                                }
                                                tick = new Tick(obj.DateTime, tick.ProviderId, tick.InstrumentId, (ask.Price + tick.Price) / 2.0, (ask.Size + tick.Size) / 2);
                                                break;
                                            }
                                        case DataObjectType.Ask:
                                            {
                                                Bid bid = this.framework.DataManager.GetBid(tick.InstrumentId);
                                                if (bid == null)
                                                {
                                                    i++;
                                                    continue;
                                                }
                                                tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId, (bid.Price + tick.Price) / 2.0, (bid.Size + tick.Size) / 2);
                                                break;
                                            }
                                        case DataObjectType.Trade:
                                            i++;
                                            continue;
                                    }
                                    if (obj.TypeId != DataObjectType.Ask)
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                    break;
                                case BarInput.Tick:
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                case BarInput.BidAsk:
                                    if (tick.TypeId != DataObjectType.Trade)
                                    {
                                        item.Process(tick);
                                        i++;
                                        continue;
                                    }
                                    break;
                                default:
                                    Console.WriteLine($"BarFactory::OnData BarInput is not supported : {item.barInput}");
                                    break;
                            }
                            i++;
                        }
            */
            var tick = (Tick) obj;
            var items = ItemLists[tick.InstrumentId];
            if (items != null)
            {
                int i = 0;
                while (i < items.Count)
                {
                    var item = items[i];
                    switch (item.barInput)
                    {
                        case BarInput.Trade:
                            if (tick.TypeId == DataObjectType.Trade)
                            {
                                goto IL_19C;
                            }
                            break;
                        case BarInput.Bid:
                            if (tick.TypeId == DataObjectType.Bid)
                            {
                                goto IL_19C;
                            }
                            break;
                        case BarInput.Ask:
                            if (tick.TypeId == DataObjectType.Ask)
                            {
                                goto IL_19C;
                            }
                            break;
                        case BarInput.Middle:
                            switch (tick.TypeId)
                            {
                                case DataObjectType.Bid:
                                {
                                    var ask = this.framework.DataManager.GetAsk(tick.InstrumentId);
                                    if (ask == null)
                                    {
                                        goto IL_1A3;
                                    }
                                    tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId,
                                        (ask.Price + tick.Price)/2.0, (ask.Size + tick.Size)/2);
                                    break;
                                }
                                case DataObjectType.Ask:
                                {
                                    var bid = this.framework.DataManager.GetBid(tick.InstrumentId);
                                    if (bid == null)
                                    {
                                        goto IL_1A3;
                                    }
                                    tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId,
                                        (bid.Price + tick.Price)/2.0, (bid.Size + tick.Size)/2);
                                    break;
                                }
                                case DataObjectType.Trade:
                                    goto IL_1A3;
                            }
                            if (obj.TypeId != DataObjectType.Ask)
                            {
                                goto IL_19C;
                            }
                            break;
                        case BarInput.Tick:
                            goto IL_19C;
                        case BarInput.BidAsk:
                            if (tick.TypeId != DataObjectType.Trade)
                            {
                                goto IL_19C;
                            }
                            break;
                        default:
                            Console.WriteLine($"BarFactory::OnData BarInput is not supported : {item.barInput}");
                            break;
                    }
                    IL_1A3:
                    i++;
                    continue;
                    IL_19C:
                    item.Process(tick);
                    goto IL_1A3;
                }
            }

        }
Ejemplo n.º 3
0
 public void Save(Tick tick, SaveMode option = SaveMode.Add) => Save(tick.InstrumentId, tick, option);
Ejemplo n.º 4
0
 public Bid(Tick tick) : base(tick)
 {
 }
Ejemplo n.º 5
0
 public void Save(Tick tick, SaveMode option = SaveMode.Add) => Save(tick.InstrumentId, tick, option);
Ejemplo n.º 6
0
 protected internal void EmitTickWithProviderId(Tick tick, byte providerId)
 {
     // create a new instance?
     tick.ProviderId = providerId;
     this.framework.EventManager.OnEvent(tick);
 }
Ejemplo n.º 7
0
 public Ask(Tick tick) : base(tick)
 {
 }
Ejemplo n.º 8
0
 public Tick(Tick tick)
     : this(tick.DateTime, tick.ExchangeDateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size)
 {
 }
Ejemplo n.º 9
0
 private void SyncExchangeClockWithTick(Tick tick, string funcName)
 {
     if (tick.ExchangeDateTime > this.framework.ExchangeClock.DateTime)
     {
         this.framework.ExchangeClock.DateTime = tick.ExchangeDateTime;
     }
     else if (tick.ExchangeDateTime > this.framework.ExchangeClock.DateTime)
     {
         Console.WriteLine($"{nameof(EventManager)}::{funcName} Exchange datetime is out of synch : {tick.GetType().Name.ToLower()} datetime = {tick.ExchangeDateTime} clock datetime = {this.framework.ExchangeClock.DateTime}");
     }
 }
Ejemplo n.º 10
0
 public Tick(Tick tick)
     : this(tick.DateTime, tick.ExchangeDateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size)
 {
 }
Ejemplo n.º 11
0
 private void method_3()
 {
     SortedList<double, Tick> sortedList = new SortedList<double, Tick>(new PriceComparer(PriceSortOrder.Descending));
     SortedList<double, Tick> sortedList2 = new SortedList<double, Tick>(new PriceComparer(PriceSortOrder.Ascending));
     this.dateTime_0 = default(DateTime);
     foreach (Tuple<DateTime, List<Tick>, List<Tick>> current in this.GonEpGhAb.Values)
     {
         if (current.Item1 > this.dateTime_0)
         {
             this.dateTime_0 = current.Item1;
         }
     }
     List<Tuple<DateTime, List<Tick>, List<Tick>>> list = new List<Tuple<DateTime, List<Tick>, List<Tick>>>();
     foreach (Tuple<DateTime, List<Tick>, List<Tick>> current2 in this.GonEpGhAb.Values)
     {
         if (current2.Item1 + this.Timeout >= this.dateTime_0)
         {
             list.Add(current2);
         }
     }
     foreach (Tuple<DateTime, List<Tick>, List<Tick>> current3 in list)
     {
         foreach (Tick current4 in current3.Item2)
         {
             if (!sortedList.ContainsKey(current4.Price))
             {
                 Tick tick = new Tick(current4);
                 if (Mode == AggregationMode.TotalValue)
                 {
                     tick.ProviderId = 0;
                 }
                 sortedList.Add(current4.Price, tick);
             }
             else if (Mode == AggregationMode.TotalValue)
             {
                 sortedList[current4.Price].Size += current4.Size;
             }
             else if (Mode == AggregationMode.MaxValue && current4.Size > sortedList[current4.Price].Size)
             {
                 sortedList[current4.Price] = new Tick(current4);
             }
         }
         foreach (Tick current5 in current3.Item3)
         {
             if (!sortedList2.ContainsKey(current5.Price))
             {
                 Tick tick2 = new Tick(current5);
                 if (this.Mode == AggregationMode.TotalValue)
                 {
                     tick2.ProviderId = 0;
                 }
                 sortedList2.Add(current5.Price, tick2);
             }
             else if (this.Mode == AggregationMode.TotalValue)
             {
                 sortedList2[current5.Price].Size += current5.Size;
             }
             else if (this.Mode == AggregationMode.MaxValue && current5.Size > sortedList2[current5.Price].Size)
             {
                 sortedList2[current5.Price] = new Tick(current5);
             }
         }
     }
     this.bids = new List<Tick>(sortedList.Values);
     this.asks = new List<Tick>(sortedList2.Values);
     this.bool_0 = true;
 }
Ejemplo n.º 12
0
 public Ask(Tick tick) : base(tick)
 {
 }
Ejemplo n.º 13
0
 public Trade(Tick tick) : base(tick)
 {
 }
Ejemplo n.º 14
0
        // TODO: rewrite it using goto statement!!!
        internal void OnData(DataObject obj)
        {
            /*
             *          var tick = (Tick)obj;
             *          var items = ItemLists[tick.InstrumentId];
             *          if (items == null)
             *              return;
             *
             *          int i = 0;
             *          while (i < items.Count)
             *          {
             *              var item = items[i];
             *              switch (item.barInput)
             *              {
             *                  case BarInput.Trade:
             *                      if (tick.TypeId == DataObjectType.Trade)
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                      break;
             *                  case BarInput.Bid:
             *                      if (tick.TypeId == DataObjectType.Bid)
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                      break;
             *                  case BarInput.Ask:
             *                      if (tick.TypeId == DataObjectType.Ask)
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                      break;
             *                  case BarInput.Middle:
             *                      switch (tick.TypeId)
             *                      {
             *                          case DataObjectType.Bid:
             *                              {
             *                                  var ask = this.framework.DataManager.GetAsk(tick.InstrumentId);
             *                                  if (ask == null)
             *                                  {
             *                                      i++;
             *                                      continue;
             *                                  }
             *                                  tick = new Tick(obj.DateTime, tick.ProviderId, tick.InstrumentId, (ask.Price + tick.Price) / 2.0, (ask.Size + tick.Size) / 2);
             *                                  break;
             *                              }
             *                          case DataObjectType.Ask:
             *                              {
             *                                  Bid bid = this.framework.DataManager.GetBid(tick.InstrumentId);
             *                                  if (bid == null)
             *                                  {
             *                                      i++;
             *                                      continue;
             *                                  }
             *                                  tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId, (bid.Price + tick.Price) / 2.0, (bid.Size + tick.Size) / 2);
             *                                  break;
             *                              }
             *                          case DataObjectType.Trade:
             *                              i++;
             *                              continue;
             *                      }
             *                      if (obj.TypeId != DataObjectType.Ask)
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                      break;
             *                  case BarInput.Tick:
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                  case BarInput.BidAsk:
             *                      if (tick.TypeId != DataObjectType.Trade)
             *                      {
             *                          item.Process(tick);
             *                          i++;
             *                          continue;
             *                      }
             *                      break;
             *                  default:
             *                      Console.WriteLine($"BarFactory::OnData BarInput is not supported : {item.barInput}");
             *                      break;
             *              }
             *              i++;
             *          }
             */
            var tick  = (Tick)obj;
            var items = ItemLists[tick.InstrumentId];

            if (items != null)
            {
                int i = 0;
                while (i < items.Count)
                {
                    var item = items[i];
                    switch (item.barInput)
                    {
                    case BarInput.Trade:
                        if (tick.TypeId == DataObjectType.Trade)
                        {
                            goto IL_19C;
                        }
                        break;

                    case BarInput.Bid:
                        if (tick.TypeId == DataObjectType.Bid)
                        {
                            goto IL_19C;
                        }
                        break;

                    case BarInput.Ask:
                        if (tick.TypeId == DataObjectType.Ask)
                        {
                            goto IL_19C;
                        }
                        break;

                    case BarInput.Middle:
                        switch (tick.TypeId)
                        {
                        case DataObjectType.Bid:
                        {
                            var ask = this.framework.DataManager.GetAsk(tick.InstrumentId);
                            if (ask == null)
                            {
                                goto IL_1A3;
                            }
                            tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId,
                                            (ask.Price + tick.Price) / 2.0, (ask.Size + tick.Size) / 2);
                            break;
                        }

                        case DataObjectType.Ask:
                        {
                            var bid = this.framework.DataManager.GetBid(tick.InstrumentId);
                            if (bid == null)
                            {
                                goto IL_1A3;
                            }
                            tick = new Tick(obj.dateTime, tick.ProviderId, tick.InstrumentId,
                                            (bid.Price + tick.Price) / 2.0, (bid.Size + tick.Size) / 2);
                            break;
                        }

                        case DataObjectType.Trade:
                            goto IL_1A3;
                        }
                        if (obj.TypeId != DataObjectType.Ask)
                        {
                            goto IL_19C;
                        }
                        break;

                    case BarInput.Tick:
                        goto IL_19C;

                    case BarInput.BidAsk:
                        if (tick.TypeId != DataObjectType.Trade)
                        {
                            goto IL_19C;
                        }
                        break;

                    default:
                        Console.WriteLine($"BarFactory::OnData BarInput is not supported : {item.barInput}");
                        break;
                    }
IL_1A3:
                    i++;
                    continue;
IL_19C:
                    item.Process(tick);
                    goto IL_1A3;
                }
            }
        }
Ejemplo n.º 15
0
 public Bid(Tick tick) : base(tick)
 {
 }