Esempio n. 1
0
 public void EventSortedSet_Add()
 {
     var t1 = DateTime.Parse("2000/01/01 00:00:01");
     var t2 = DateTime.Parse("2000/01/01 00:00:05");
     var t3 = DateTime.Parse("2000/01/01 00:01:01");
     var t4 = DateTime.Parse("2000/01/01 00:01:01");
     var e1 = new Event() { DateTime = t1 };
     var e2 = new Event() { DateTime = t2 };
     var e3 = new Event() { DateTime = t3 };
     var e4 = new Event() { DateTime = t4 };
     var e5 = new Event() { DateTime = t3 };
     var e6 = new Event() { DateTime = t2 };
     var sset = new EventSortedSet();
     sset.Add(e1);
     sset.Add(e2);
     sset.Add(e3);
     sset.Add(e4);
     sset.Add(e5);
     Assert.Equal(5, sset.Count);
     Assert.Same(e1, sset[0]);
     Assert.Same(e2, sset[1]);
     Assert.Same(e3, sset[2]);
     Assert.Same(e4, sset[3]);
     Assert.Same(e5, sset[4]);
     sset.Add(e6);
     Assert.Equal(6, sset.Count);
     Assert.Same(e1, sset[0]);
     Assert.Same(e2, sset[1]);
     Assert.Same(e6, sset[2]);
     Assert.Same(e3, sset[3]);
     Assert.Same(e4, sset[4]);
     Assert.Same(e5, sset[5]);
 }
Esempio n. 2
0
        public void Emit(Event e)
        {
            if (e.TypeId == EventType.Command)
                ((Command)e).SenderId = Id;

            this.dispatcher.Emit(e);
        }
Esempio n. 3
0
 public void Clear()
 {
     this.@event = null;
     CommandPipe.Clear();
     DataPipe.Clear();
     ServicePipe.Clear();
     HistoricalPipe.Clear();
     ExecutionPipe.Clear();
     for (int i = 0; i < this.attachedCount; i++)
         this.attached[i] = null;
     this.attachedCount = 0;
 }
Esempio n. 4
0
        public override void OnEvent(Event e)
        {
            if (this.gates[e.TypeId])
            {

                if (e.DateTime >= this.dateTime)
                {
                    this.dateTime = e.dateTime;
                    this.series.Add((DataObject)e);
                }
                else
                {
                    Console.WriteLine($"!{e} = {e.DateTime} <> {this.dateTime}");
                }
            }
        }
Esempio n. 5
0
 public OnException(string source, Event ev, Exception exception)
 {
     Source = source;
     Event = ev;
     Exception = exception;
 }
Esempio n. 6
0
 private void method_1(Event event_0)
 {
     if (event_0.TypeId == 55 && ((Response)event_0).ReceiverId != -1)
     {
         this.idArray_0[((Response)event_0).ReceiverId].OnEvent(event_0);
     }
     else
     {
         List<IEventClient> list = this.idArray_1[(int)event_0.TypeId];
         if (list != null)
         {
             for (int i = 0; i < list.Count; i++)
             {
                 if (list[i].IsOnEventEnabled)
                 {
                     list[i].OnEvent(event_0);
                 }
             }
         }
     }
     byte typeId = event_0.TypeId;
     if (typeId <= 55)
     {
         if (typeId <= 14)
         {
             switch (typeId)
             {
                 case 2:
                     if (this.bidEventHandler_0 != null)
                     {
                         this.bidEventHandler_0(this, (Bid)event_0);
                         return;
                     }
                     break;
                 case 3:
                     if (this.askEventHandler_0 != null)
                     {
                         this.askEventHandler_0(this, (Ask)event_0);
                         return;
                     }
                     break;
                 case 4:
                     if (this.tradeEventHandler_0 != null)
                     {
                         this.tradeEventHandler_0(this, (Trade)event_0);
                         return;
                     }
                     break;
                 case 5:
                     break;
                 case 6:
                     {
                         Bar bar = (Bar)event_0;
                         BarStatus barStatus_ = bar.Status;
                         if (barStatus_ != BarStatus.Open)
                         {
                             if (barStatus_ != BarStatus.Close)
                             {
                                 return;
                             }
                             if (this.barEventHandler_0 != null)
                             {
                                 this.barEventHandler_0(this, bar);
                                 return;
                             }
                         }
                         else if (this.barEventHandler_1 != null)
                         {
                             this.barEventHandler_1(this, bar);
                             return;
                         }
                         break;
                     }
                 default:
                     switch (typeId)
                     {
                         case 13:
                             this.permanentQueue_0.Enqueue(event_0);
                             if (this.executionReportEventHandler_0 != null)
                             {
                                 this.executionReportEventHandler_0(this, (ExecutionReport)event_0);
                                 return;
                             }
                             break;
                         case 14:
                             this.permanentQueue_0.Enqueue(event_0);
                             if (this.executionCommandEventHandler_0 != null)
                             {
                                 this.executionCommandEventHandler_0(this, (ExecutionCommand)event_0);
                                 return;
                             }
                             break;
                         default:
                             return;
                     }
                     break;
             }
         }
         else if (typeId != 21)
         {
             if (typeId != 27)
             {
                 switch (typeId)
                 {
                     case EventType.Group:
                         this.permanentQueue_0.Enqueue(event_0);
                         if (this.groupEventHandler_0 != null)
                         {
                             this.groupEventHandler_0(this, new GroupEventAgrs((Group)event_0));
                             return;
                         }
                         break;
                     case EventType.GroupUpdate:
                         this.permanentQueue_0.Enqueue(event_0);
                         if (this.groupUpdateEventHandler_0 != null)
                         {
                             this.groupUpdateEventHandler_0(this, new GroupUpdateEventAgrs((GroupUpdate)event_0));
                             return;
                         }
                         break;
                     case EventType.GroupEvent:
                         this.permanentQueue_0.Enqueue(event_0);
                         if (this.groupEventEventHandler_0 != null)
                         {
                             this.groupEventEventHandler_0(this, new GroupEventEventAgrs((GroupEvent)event_0));
                             return;
                         }
                         break;
                     case EventType.Message:
                         break;
                     case EventType.Command:
                         if (this.commandEventHandler_0 != null)
                         {
                             this.commandEventHandler_0(this, (Command)event_0);
                             return;
                         }
                         break;
                     case EventType.Response:
                         if (this.responseEventHandler_0 != null)
                         {
                             this.responseEventHandler_0(this, (Response)event_0);
                             return;
                         }
                         break;
                     default:
                         return;
                 }
             }
             else
             {
                 this.permanentQueue_0.Enqueue(event_0);
                 if (this.outputEventHandler_0 != null)
                 {
                     this.outputEventHandler_0(this, (Output)event_0);
                     return;
                 }
             }
         }
         else
         {
             this.permanentQueue_0.Enqueue(event_0);
             if (this.providerErrorEventHandler_0 != null)
             {
                 this.providerErrorEventHandler_0(this, new ProviderErrorEventArgs((ProviderError)event_0));
                 return;
             }
         }
     }
     else if (typeId <= 114)
     {
         if (typeId != 99)
         {
             switch (typeId)
             {
                 case 110:
                     if (this.ovQrTixtSx != null)
                     {
                         this.ovQrTixtSx(this, new PositionEventArgs(((OnPositionOpened)event_0).Portfolio, ((OnPositionOpened)event_0).Position));
                         return;
                     }
                     break;
                 case 111:
                     if (this.positionEventHandler_1 != null)
                     {
                         this.positionEventHandler_1(this, new PositionEventArgs(((OnPositionClosed)event_0).Portfolio, ((OnPositionClosed)event_0).Position));
                         return;
                     }
                     break;
                 case 112:
                     if (this.positionEventHandler_0 != null)
                     {
                         this.positionEventHandler_0(this, new PositionEventArgs(((OnPositionChanged)event_0).Portfolio, ((OnPositionChanged)event_0).Position));
                         return;
                     }
                     break;
                 case 113:
                     this.permanentQueue_0.Enqueue(event_0);
                     if (this.fillEventHandler_0 != null)
                     {
                         this.fillEventHandler_0(this, (OnFill)event_0);
                         return;
                     }
                     break;
                 case 114:
                     this.permanentQueue_0.Enqueue(event_0);
                     if (this.transactionEventHandler_0 != null)
                     {
                         this.transactionEventHandler_0(this, (OnTransaction)event_0);
                         return;
                     }
                     break;
                 default:
                     return;
             }
         }
         else
         {
             this.permanentQueue_0.Clear();
            // if (FrameworkCleared != null)
           //  {
                 FrameworkCleared?.Invoke(this, new FrameworkEventArgs(((OnFrameworkCleared) event_0).Framework));
          //       return;
         //    }
         }
     }
     else
     {
         switch (typeId)
         {
             case 130:
                 this.permanentQueue_0.Enqueue(event_0);
                 if (this.orderManagerClearedEventHandler_0 != null)
                 {
                     this.orderManagerClearedEventHandler_0(this, (OnOrderManagerCleared)event_0);
                     return;
                 }
                 break;
             case 131:
                 if (this.instrumentDefinitionEventHandler_0 != null)
                 {
                     this.instrumentDefinitionEventHandler_0(this, new InstrumentDefinitionEventArgs(((OnInstrumentDefinition)event_0).InstrumentDefinition));
                     return;
                 }
                 break;
             case 132:
                 if (this.instrumentDefinitionEndEventHandler_0 != null)
                 {
                     this.instrumentDefinitionEndEventHandler_0(this, new InstrumentDefinitionEndEventArgs(((OnInstrumentDefinitionEnd)event_0).InstrumentDefinitionEnd));
                     return;
                 }
                 break;
             case 133:
             case 134:
             case 140:
             case 141:
             case 143:
                 break;
             case 135:
                 if (this.portfolioEventHandler_0 != null)
                 {
                     this.portfolioEventHandler_0(this, new PortfolioEventArgs(((OnPortfolioAdded)event_0).Portfolio));
                     return;
                 }
                 break;
             case 136:
                 if (this.WixrwvmkIM != null)
                 {
                     this.WixrwvmkIM(this, new PortfolioEventArgs(((OnPortfolioRemoved)event_0).Portfolio));
                     return;
                 }
                 break;
             case 137:
                 if (this.portfolioEventHandler_1 != null)
                 {
                     this.portfolioEventHandler_1(this, new PortfolioEventArgs(((OnPortfolioParentChanged)event_0).Portfolio));
                     return;
                 }
                 break;
             case 138:
                 if (this.historicalDataEventHandler_0 != null)
                 {
                     this.historicalDataEventHandler_0(this, new HistoricalDataEventArgs((HistoricalData)event_0));
                     return;
                 }
                 break;
             case 139:
                 if (this.historicalDataEndEventHandler_0 != null)
                 {
                     this.historicalDataEndEventHandler_0(this, new HistoricalDataEndEventArgs((HistoricalDataEnd)event_0));
                     return;
                 }
                 break;
             case 142:
                 if (this.accountDataEventHandler_0 != null)
                 {
                     this.accountDataEventHandler_0(this, new AccountDataEventArgs((AccountData)event_0));
                     return;
                 }
                 break;
             case 144:
                 if (this.strategyEventHandler_0 != null)
                 {
                     this.strategyEventHandler_0(this, new StrategyEventArgs(((OnStrategyAdded)event_0).Strategy));
                     return;
                 }
                 break;
             default:
                 if (typeId != 162)
                 {
                     switch (typeId)
                     {
                         case 207:
                             if (this.eventHandler_1 != null)
                             {
                                 this.eventHandler_1(this, EventArgs.Empty);
                                 return;
                             }
                             break;
                         case 208:
                             if (this.eventHandler_2 != null)
                             {
                                 this.eventHandler_2(this, EventArgs.Empty);
                                 return;
                             }
                             break;
                         case 209:
                             if (this.eventHandler_3 != null)
                             {
                                 this.eventHandler_3(this, EventArgs.Empty);
                                 return;
                             }
                             break;
                         case 210:
                             if (this.eventHandler_4 != null)
                             {
                                 this.eventHandler_4(this, EventArgs.Empty);
                                 return;
                             }
                             break;
                         case 211:
                             if (this.eventHandler_5 != null)
                             {
                                 this.eventHandler_5(this, EventArgs.Empty);
                             }
                             break;
                         case 212:
                         case 213:
                         case 214:
                         case 215:
                         case 216:
                         case 217:
                         case 218:
                         case 219:
                         case 220:
                         case 228:
                             break;
                         case 221:
                             if (this.instrumentEventHandler_0 != null)
                             {
                                 this.instrumentEventHandler_0(this, new InstrumentEventArgs(((OnInstrumentAdded)event_0).Instrument));
                                 return;
                             }
                             break;
                         case 222:
                             if (this.instrumentEventHandler_1 != null)
                             {
                                 this.instrumentEventHandler_1(this, new InstrumentEventArgs(((OnInstrumentDeleted)event_0).Instrument));
                                 return;
                             }
                             break;
                         case 223:
                             if (this.providerEventHandler_0 != null)
                             {
                                 this.providerEventHandler_0(this, new ProviderEventArgs(((OnProviderAdded)event_0).Provider));
                                 return;
                             }
                             break;
                         case 224:
                             if (this.TqQiEpesSY != null)
                             {
                                 this.TqQiEpesSY(this, new ProviderEventArgs(((OnProviderRemoved)event_0).Provider));
                                 return;
                             }
                             break;
                         case 225:
                             if (this.jMmiArAlGk != null)
                             {
                                 this.jMmiArAlGk(this, new ProviderEventArgs(((OnProviderConnected)event_0).Provider));
                                 return;
                             }
                             break;
                         case 226:
                             if (this.providerEventHandler_2 != null)
                             {
                                 this.providerEventHandler_2(this, new ProviderEventArgs(((OnProviderDisconnected)event_0).Provider));
                                 return;
                             }
                             break;
                         case 227:
                             if (this.providerEventHandler_1 != null)
                             {
                                 this.providerEventHandler_1(this, new ProviderEventArgs(((OnProviderStatusChanged)event_0).Provider));
                                 return;
                             }
                             break;
                         case 229:
                             if (this.eventHandler_0 != null)
                             {
                                 this.eventHandler_0(this, EventArgs.Empty);
                                 return;
                             }
                             break;
                         case 230:
                             if (this.simulatorProgressEventHandler_0 != null)
                             {
                                 this.simulatorProgressEventHandler_0(this, new SimulatorProgressEventArgs(((OnSimulatorProgress)event_0).Count, ((OnSimulatorProgress)event_0).Percent));
                                 return;
                             }
                             break;
                         default:
                             return;
                     }
                 }
                 else
                 {
                     this.permanentQueue_0.Enqueue(event_0);
                     if (this.accountReportEventHandler_0 != null)
                     {
                         this.accountReportEventHandler_0(this, (AccountReport)event_0);
                         return;
                     }
                 }
                 break;
         }
     }
 }
Esempio n. 7
0
 public virtual void OnEvent(Event e)
 {
     if (this.eventDispatcher_0 != null)
     {
         this.eventDispatcher_0.OnEvent(e);
     }
 }
Esempio n. 8
0
 private Event Dequeue_origin()
 {
     if (this.Mode == EventBusMode.Simulation)
     {
         while (true)
         {
             if (!DataPipe.IsEmpty() && this.@event == null)
             {
                 Event @event = DataPipe.Read();
                 if (@event.dateTime < this.framework.Clock.DateTime)
                 {
                     if (@event.TypeId != 205 && @event.TypeId != 206 && @event.TypeId != 229)
                     {
                         if (@event.TypeId != 230)
                         {
                             Console.WriteLine(string.Concat(new object[]
                             {
                         "EventBus::Dequeue Skipping: ",
                         @event,
                         " ",
                         @event.dateTime,
                         " <> ",
                         this.framework.Clock.DateTime
                             }));
                             continue;
                         }
                     }
                     @event.dateTime = this.framework.Clock.DateTime;
                     this.@event = @event;
                 }
                 else
                 {
                     this.@event = @event;
                 }
             }
             if (!ExecutionPipe.IsEmpty())
             {
                 goto IL_25D;
             }
             if (!LocalClockEventQueue.IsEmpty() && this.@event != null)
             {
                 if (ReminderOrder == ReminderOrder.Before)
                 {
                     if (LocalClockEventQueue.PeekDateTime() <= [email protected])
                     {
                         break;
                     }
                 }
                 else if (LocalClockEventQueue.PeekDateTime() < [email protected])
                 {
                     goto IL_275;
                 }
             }
             if (!ExchangeClockEventQueue.IsEmpty() && this.@event != null && ([email protected] == 2 || [email protected] == 3 || [email protected] == 4))
             {
                 if (ReminderOrder == ReminderOrder.Before)
                 {
                     if (ExchangeClockEventQueue.PeekDateTime() <= ((Tick)this.@event).ExchangeDateTime)
                     {
                         goto Block_12;
                     }
                 }
                 else if (ExchangeClockEventQueue.PeekDateTime() < ((Tick)this.@event).ExchangeDateTime)
                 {
                     goto IL_28D;
                 }
             }
             if (!CommandPipe.IsEmpty())
             {
                 goto IL_299;
             }
             if (!ServicePipe.IsEmpty())
             {
                 goto IL_2A5;
             }
             if (this.@event != null)
             {
                 goto IL_2B1;
             }
             Thread.Sleep(1);
         }
         return LocalClockEventQueue.Read();
         Block_12:
         return ExchangeClockEventQueue.Read();
         IL_25D:
         return ExecutionPipe.Read();
         IL_275:
         return LocalClockEventQueue.Read();
         IL_28D:
         return ExchangeClockEventQueue.Read();
         IL_299:
         return CommandPipe.Read();
         IL_2A5:
         return ServicePipe.Read();
         IL_2B1:
         Event event2 = this.@event;
         this.@event = null;
         for (int i = 0; i < this.attachedCount; i++)
         {
             if (event2.TypeId != 205 && event2.TypeId != 206)
             {
                 this.attached[i].Enqueue(event2);
             }
         }
         return event2;
     }
     while (true)
     {
         if (!DataPipe.IsEmpty() && this.@event == null)
         {
             this.@event = DataPipe.Read();
         }
         if (!LocalClockEventQueue.IsEmpty())
         {
             if (ReminderOrder == ReminderOrder.Before)
             {
                 if (LocalClockEventQueue.PeekDateTime() <= this.framework.Clock.DateTime)
                 {
                     break;
                 }
             }
             else if (LocalClockEventQueue.PeekDateTime() < this.framework.Clock.DateTime)
             {
                 goto IL_4AF;
             }
         }
         if (!ExchangeClockEventQueue.IsEmpty() && this.@event != null && ([email protected] == 2 || [email protected] == 3 || [email protected] == 4))
         {
             if (ReminderOrder == ReminderOrder.Before)
             {
                 if (ExchangeClockEventQueue.PeekDateTime() <= ((Tick)this.@event).ExchangeDateTime)
                 {
                     goto Block_34;
                 }
             }
             else if (ExchangeClockEventQueue.PeekDateTime() < ((Tick)this.@event).ExchangeDateTime)
             {
                 goto IL_4C7;
             }
         }
         if (!ExecutionPipe.IsEmpty())
         {
             goto IL_4D3;
         }
         if (!CommandPipe.IsEmpty())
         {
             goto IL_4DF;
         }
         if (!ServicePipe.IsEmpty())
         {
             goto IL_4EB;
         }
         if (this.@event != null)
         {
             goto IL_4F7;
         }
         switch (this.IdleMode)
         {
             case EventBusIdleMode.Sleep:
                 Thread.Sleep(1);
                 break;
             case EventBusIdleMode.Wait:
                 this.hasWorkEvent.Reset();
                 this.hasWorkEvent.Wait(1);
                 break;
         }
     }
     return LocalClockEventQueue.Read();
     Block_34:
     return ExchangeClockEventQueue.Read();
     IL_4AF:
     return LocalClockEventQueue.Read();
     IL_4C7:
     return ExchangeClockEventQueue.Read();
     IL_4D3:
     return ExecutionPipe.Read();
     IL_4DF:
     return CommandPipe.Read();
     IL_4EB:
     return ServicePipe.Read();
     IL_4F7:
     Event result = this.@event;
     this.@event = null;
     return result;
 }
Esempio n. 9
0
 public GroupEvent(Event obj, int groupId)
 {
     Obj     = obj;
     GroupId = groupId;
 }
Esempio n. 10
0
 private void OnProviderDisconnected(Event e)
 {
     var p = ((OnProviderDisconnected)e).Provider;
     if (p is IDataProvider)
         this.framework.SubscriptionManager.OnProviderDisconnected((IDataProvider)p);
     this.framework.StrategyManager.OnProviderDisconnected(p);
 }
Esempio n. 11
0
 private void OnPendingNewOrder(Event e)
 {
     this.framework.StrategyManager.OnPendingNewOrder(((OnPendingNewOrder)e).Order);
 }
Esempio n. 12
0
 internal virtual void vmethod_2(string source, Event ev, Exception exception)
 {
     if (this.IsInstance)
     {
         this.OnException(source, ev, exception);
     }
 }
Esempio n. 13
0
 internal virtual void vmethod_41(Event ev)
 {
     if (this.IsInstance)
     {
         this.OnUserEvent(ev);
     }
     for (int i = 0; i < this.Strategies.Count; i++)
     {
         this.Strategies[i].vmethod_41(ev);
     }
 }
Esempio n. 14
0
 public virtual void OnEvent(Event e)
 {
     // noop
 }
Esempio n. 15
0
 public override void OnEvent(Event e)
 {
     if (e == null || e.TypeId == EventType.Bid || e.TypeId == EventType.Ask || e.TypeId == EventType.Trade || e.TypeId == EventType.Bar)
         return;
     Console.WriteLine($"Event {e.TypeId} {e.GetType()}");
 }
Esempio n. 16
0
 private void OnSimulatorProgress(Event e)
 {
     // noop
 }
Esempio n. 17
0
 private void OnSimulatorStop(Event e)
 {
     this.framework.StrategyManager.Stop();
     this.stopwatch.Stop();
     var ms = this.stopwatch.ElapsedMilliseconds;
     Console.WriteLine(ms != 0
         ? $"{DateTime.Now} Data run done, count = {DataEventCount} ms = {this.stopwatch.ElapsedMilliseconds}  event/sec = {DataEventCount/ms*1000}"
         : $"{DateTime.Now} Data run done, count = {DataEventCount} ms = 0");
 }
Esempio n. 18
0
        private void OnSimulatorStart(Event e)
        {
            var start = (OnSimulatorStart)e;
            if (this.framework.Clock.Mode == ClockMode.Simulation)
                this.framework.Clock.DateTime = start.DateTime1;

            this.bus?.ResetCounts();
            EventCount = DataEventCount = 0;
            this.stopwatch.Reset();
            this.stopwatch.Start();
        }
Esempio n. 19
0
 public void Serialize(BinaryWriter writer, Event e)
 {
     var streamer = this.streamsById[e.TypeId];
     writer.Write(streamer.typeId);
     writer.Write(streamer.GetVersion(e));
     streamer.Write(writer, e);
 }
Esempio n. 20
0
 public void Log(Event e, Group group)
 {
     EventServer.OnLog(new GroupEvent(e, group));
 }
Esempio n. 21
0
 internal void OnException(string source, Event e, Exception ex)
 {
     if (Strategy?.Status == StrategyStatus.Running)
         Strategy.EmitException(source, e, ex);
 }
Esempio n. 22
0
 private void OnStrategyEvent(Event e)
 {
     this.framework.StrategyManager.OnStrategyEvent(((OnStrategyEvent)e).Data);
 }
Esempio n. 23
0
 protected virtual void OnException(string source, Event ev, Exception exception)
 {
 }
Esempio n. 24
0
 public virtual void Process(Event e)
 {
     switch (e.TypeId)
     {
         case EventType.OnConnect:
             Connect();
             break;
         case EventType.OnDisconnect:
             Disconnect();
             break;
         case EventType.OnSubscribe:
             Subscribe((e as OnSubscribe).Instrument);
             break;
         case EventType.OnUnsubscribe:
             Unsubscribe((e as OnUnsubscribe).Instrument);
             break;
     }
 }
Esempio n. 25
0
 protected virtual void OnUserEvent(Event ev)
 {
 }
Esempio n. 26
0
 public virtual void OnEvent(Event e)
 {
     if (this.framework.Mode != FrameworkMode.Simulation)
         this.eventQueue_1?.Enqueue(e);
     else
         this.method_1(e);
 }
Esempio n. 27
0
 public void Log(Event e, int groupId)
 {
     EventServer.OnLog(new GroupEvent(e, GroupManager.GroupById[groupId]));
 }
Esempio n. 28
0
 public void Emit(Event e)
 {
     this.framework.EventManager.Dispatcher.Emit(e);
 }
Esempio n. 29
0
        private Event Dequeue_me()
        {
            if (Mode == EventBusMode.Simulation)
            {
                while (true)
                {
                    if (!DataPipe.IsEmpty() && this.@event == null)
                    {
                        var e = DataPipe.Read();
                        if (e.dateTime < this.framework.Clock.DateTime)
                        {
                            if (e.TypeId != EventType.OnQueueOpened && e.TypeId != EventType.OnQueueClosed && e.TypeId != EventType.OnSimulatorStop)
                            {
                                if (e.TypeId != EventType.OnSimulatorProgress)
                                {
                                    if (ShowWarnings)
                                        Console.WriteLine($"EventBus::Dequeue Skipping: {e} {e.dateTime} <> {this.framework.Clock.DateTime}");
                                    continue;
                                }
                            }
                            e.DateTime = this.framework.Clock.DateTime;
                            this.@event = e;
                        }
                        else
                            this.@event = e;
                    }

                    if (!ExecutionPipe.IsEmpty())
                        return this.ExecutionPipe.Read();

                    if (!LocalClockEventQueue.IsEmpty() && this.@event != null)
                    {
                        if (ReminderOrder == ReminderOrder.Before)
                        {
                            if (LocalClockEventQueue.PeekDateTime() <= [email protected])
                                return LocalClockEventQueue.Read();
                        }
                        else if (this.LocalClockEventQueue.PeekDateTime() < [email protected])
                            return LocalClockEventQueue.Read();
                    }

                    if (!LocalClockEventQueue.IsEmpty() && this.@event != null && ([email protected] == EventType.Bid || [email protected] == EventType.Ask || [email protected] == EventType.Trade))
                    {
                        if (ReminderOrder == ReminderOrder.Before)
                        {
                            if (ExchangeClockEventQueue.PeekDateTime() <= ((Tick)this.@event).ExchangeDateTime)
                                return this.ExchangeClockEventQueue.Read();
                        }
                        else if (ExchangeClockEventQueue.PeekDateTime() < ((Tick)this.@event).ExchangeDateTime)
                            return ExchangeClockEventQueue.Read();
                    }

                    if (!CommandPipe.IsEmpty())
                        return CommandPipe.Read();

                    if (!ServicePipe.IsEmpty())
                        return ServicePipe.Read();

                    if (this.@event != null)
                    {
                        // forward the event to externally attached queues
                        var e = this.@event;
                        this.@event = null;
                        for (int i = 0; i < this.attachedCount; i++)
                            if (e.TypeId != EventType.OnQueueOpened && e.TypeId != EventType.OnQueueClosed)
                                this.attached[i].Enqueue(e);
                        return e;
                    }

                    // still not getting any event, try later
                    Thread.Sleep(1);
                }
            }

            // Mode == EventBusMode.Realtime
            while (true)
            {
                if (!DataPipe.IsEmpty() && this.@event == null)
                    this.@event = DataPipe.Read();

                if (!LocalClockEventQueue.IsEmpty())
                {
                    if (ReminderOrder == ReminderOrder.Before)
                    {
                        if (LocalClockEventQueue.PeekDateTime() <= this.framework.Clock.DateTime)
                            return LocalClockEventQueue.Read();
                    }
                    else if (LocalClockEventQueue.PeekDateTime() < this.framework.Clock.DateTime)
                        return LocalClockEventQueue.Read();
                }

                if (!ExchangeClockEventQueue.IsEmpty() && this.@event != null && ([email protected] == EventType.Bid || [email protected] == EventType.Ask || [email protected] == EventType.Trade))
                {
                    if (ReminderOrder == ReminderOrder.Before)
                    {
                        if (ExchangeClockEventQueue.PeekDateTime() <= ((Tick)this.@event).ExchangeDateTime)
                            return this.ExchangeClockEventQueue.Read();
                    }
                    else if (ExchangeClockEventQueue.PeekDateTime() < ((Tick)this.@event).ExchangeDateTime)
                        return ExchangeClockEventQueue.Read();
                }

                if (!ExecutionPipe.IsEmpty())
                    return ExecutionPipe.Read();

                if (!CommandPipe.IsEmpty())
                    return CommandPipe.Read();

                if (!ServicePipe.IsEmpty())
                    return ServicePipe.Read();

                if (this.@event != null)
                {
                    var result = this.@event;
                    this.@event = null;
                    return result;
                }

                // still not getting an event, go idle for a while
                switch (IdleMode)
                {
                    case EventBusIdleMode.Sleep:
                        Thread.Sleep(1);
                        break;
                    case EventBusIdleMode.Wait:
                        this.hasWorkEvent.Reset();
                        this.hasWorkEvent.Wait(1);
                        break;
                }
            }
        }
Esempio n. 30
0
 public void Emit(Event e) { }
Esempio n. 31
0
 public void Emit(Event e)
 {
     this.streamerManager_0.Serialize(this.binaryWriter_0, e);
 }
Esempio n. 32
0
 public GroupEvent(Event obj, Group group)
 {
     Obj     = obj;
     Group   = group;
     GroupId = group != null ? group.Id : -1;
 }