Beispiel #1
0
		public void OnEvent(Event e)
		{
			if (this.queue != null)
			{
				this.queue.Enqueue(e);
				return;
			}
			this.OnEvent_(e);
		}
Beispiel #2
0
		public GroupEvent(Event obj, Group group)
		{
			this.Obj = obj;
			this.Group = group;
			if (group != null)
			{
				this.GroupId = group.Id;
				return;
			}
			this.GroupId = -1;
		}
Beispiel #3
0
		public override void OnEvent(Event e)
		{
			if (e != null && e.TypeId != 2 && e.TypeId != 3 && e.TypeId != 4 && e.TypeId != 6)
			{
				Console.WriteLine(string.Concat(new object[]
				{
					"Event ",
					e.TypeId,
					" ",
					e.GetType()
				}));
			}
		}
		public override void OnEvent(Event e)
		{
			if (this.filter[(int)e.TypeId])
			{
				if (e.dateTime < this.dateTime)
				{
					Console.WriteLine(string.Concat(new object[]
					{
						"!",
						e,
						" = ",
						e.dateTime,
						" <> ",
						this.dateTime
					}));
					return;
				}
				this.dateTime = e.dateTime;
				this.series.Add((DataObject)e);
			}
		}
Beispiel #5
0
		private void OnGroupEvent(Event e)
		{
			this.framework.groupManager.OnGroupEvent((GroupEvent)e);
		}
Beispiel #6
0
		private void OnPositionChanged(Event e)
		{
			OnPositionChanged onPositionChanged = (OnPositionChanged)e;
			this.framework.strategyManager.OnPositionChanged(onPositionChanged.portfolio, onPositionChanged.position);
		}
Beispiel #7
0
		private void OnOrderDone(Event e)
		{
			this.framework.strategyManager.OnOrderDone(((OnOrderDone)e).order);
		}
Beispiel #8
0
		private void OnOrderPartiallyFilled(Event e)
		{
			this.framework.strategyManager.OnOrderPartiallyFilled(((OnOrderPartiallyFilled)e).order);
		}
Beispiel #9
0
		private void OnAccountData(Event e)
		{
			AccountData data = (AccountData)e;
			this.framework.accountDataManager.OnAccountData(data);
		}
Beispiel #10
0
		private void OnNews(Event e)
		{
			this.data_count += 1L;
			News news = (News)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = news.dateTime;
			}
			else
			{
				news.dateTime = this.framework.clock.DateTime;
			}
			this.framework.dataManager.OnNews(news);
			this.framework.strategyManager.OnNews(news);
		}
Beispiel #11
0
		private void OnSimulatorStart(Event e)
		{
			OnSimulatorStart arg_06_0 = (OnSimulatorStart)e;
			if (this.bus != null)
			{
				this.bus.ResetCounts();
			}
			this.count = 0L;
			this.data_count = 0L;
			this.watch.Reset();
			this.watch.Start();
		}
Beispiel #12
0
		public void OnEvent(Event e)
		{
			if (this.status == EventManagerStatus.Paused && this.step_enabled && (this.step_typeId == 0 || this.step_typeId == e.TypeId))
			{
				Console.WriteLine(DateTime.Now + " Event : " + e);
				this.step_enabled = false;
			}
			this.count += 1L;
			if (this.filter != null && this.filter.Filter(e) == null)
			{
				return;
			}
			if (this.handler[(int)e.TypeId] != null)
			{
				this.handler[(int)e.TypeId](e);
			}
			if (this.dispatcher != null)
			{
				this.dispatcher.OnEvent(e);
			}
			if (this.logger != null)
			{
				this.logger.OnEvent(e);
			}
		}
Beispiel #13
0
		private void OnEvent_(Event e)
		{
			byte typeId = e.TypeId;
			if (typeId <= 21)
			{
				switch (typeId)
				{
				case 2:
					if (this.Bid != null)
					{
						this.Bid(this, (Bid)e);
						return;
					}
					break;
				case 3:
					if (this.Ask != null)
					{
						this.Ask(this, (Ask)e);
						return;
					}
					break;
				case 4:
					if (this.Trade != null)
					{
						this.Trade(this, (Trade)e);
						return;
					}
					break;
				case 5:
					break;
				case 6:
					if (this.Bar != null)
					{
						this.Bar(this, (Bar)e);
						return;
					}
					break;
				default:
					switch (typeId)
					{
					case 13:
						if (this.ExecutionReport != null)
						{
							this.ExecutionReport(this, (ExecutionReport)e);
							return;
						}
						break;
					case 14:
						if (this.ExecutionCommand != null)
						{
							this.ExecutionCommand(this, (ExecutionCommand)e);
							return;
						}
						break;
					default:
						if (typeId != 21)
						{
							return;
						}
						if (this.ProviderError != null)
						{
							this.ProviderError(this, new ProviderErrorEventArgs((ProviderError)e));
							return;
						}
						break;
					}
					break;
				}
			}
			else
			{
				switch (typeId)
				{
				case 50:
					if (this.NewGroup != null)
					{
						this.NewGroup(this, new GroupEventAgrs((Group)e));
						return;
					}
					break;
				case 51:
					if (this.NewGroupUpdate != null)
					{
						this.NewGroupUpdate(this, new GroupUpdateEventAgrs((GroupUpdate)e));
						return;
					}
					break;
				case 52:
					if (this.NewGroupEvent != null)
					{
						this.NewGroupEvent(this, new GroupEventEventAgrs((GroupEvent)e));
						return;
					}
					break;
				default:
					switch (typeId)
					{
					case 99:
						if (this.FrameworkCleared != null)
						{
							this.FrameworkCleared(this, new FrameworkEventArgs(((OnFrameworkCleared)e).framework));
							return;
						}
						break;
					case 100:
						if (this.InstrumentAdded != null)
						{
							this.InstrumentAdded(this, new InstrumentEventArgs(((OnInstrumentAdded)e).instrument));
							return;
						}
						break;
					case 101:
						if (this.InstrumentDeleted != null)
						{
							this.InstrumentDeleted(this, new InstrumentEventArgs(((OnInstrumentDeleted)e).instrument));
							return;
						}
						break;
					case 102:
						if (this.ProviderAdded != null)
						{
							this.ProviderAdded(this, new ProviderEventArgs(((OnProviderAdded)e).provider));
							return;
						}
						break;
					case 103:
						if (this.ProviderRemoved != null)
						{
							this.ProviderRemoved(this, new ProviderEventArgs(((OnProviderRemoved)e).provider));
							return;
						}
						break;
					case 104:
						if (this.ProviderConnected != null)
						{
							this.ProviderConnected(this, new ProviderEventArgs(((OnProviderConnected)e).provider));
							return;
						}
						break;
					case 105:
						if (this.ProviderDisconnected != null)
						{
							this.ProviderDisconnected(this, new ProviderEventArgs(((OnProviderDisconnected)e).provider));
							return;
						}
						break;
					case 106:
						if (this.ProviderStatusChanged != null)
						{
							this.ProviderStatusChanged(this, new ProviderEventArgs(((OnProviderStatusChanged)e).provider));
							return;
						}
						break;
					case 107:
					case 114:
					case 115:
					case 116:
					case 117:
					case 118:
					case 119:
					case 120:
					case 121:
					case 125:
					case 126:
					case 132:
					case 133:
					case 134:
					case 135:
					case 136:
					case 137:
					case 138:
					case 139:
						break;
					case 108:
						if (this.SimulatorStop != null)
						{
							this.SimulatorStop(this, EventArgs.Empty);
							return;
						}
						break;
					case 109:
						if (this.SimulatorProgress != null)
						{
							this.SimulatorProgress(this, new SimulatorProgressEventArgs(((OnSimulatorProgress)e).count, ((OnSimulatorProgress)e).percent));
							return;
						}
						break;
					case 110:
						if (this.PositionOpened != null)
						{
							this.PositionOpened(this, new PositionEventArgs(((OnPositionOpened)e).portfolio, ((OnPositionOpened)e).position));
							return;
						}
						break;
					case 111:
						if (this.PositionClosed != null)
						{
							this.PositionClosed(this, new PositionEventArgs(((OnPositionClosed)e).portfolio, ((OnPositionClosed)e).position));
							return;
						}
						break;
					case 112:
						if (this.PositionChanged != null)
						{
							this.PositionChanged(this, new PositionEventArgs(((OnPositionChanged)e).portfolio, ((OnPositionChanged)e).position));
							return;
						}
						break;
					case 113:
						if (this.Fill != null)
						{
							this.Fill(this, (OnFill)e);
							return;
						}
						break;
					case 122:
						if (this.OrderManagerCleared != null)
						{
							this.OrderManagerCleared(this, (OnOrderManagerCleared)e);
							return;
						}
						break;
					case 123:
						if (this.InstrumentDefinition != null)
						{
							this.InstrumentDefinition(this, new InstrumentDefinitionEventArgs(((OnInstrumentDefinition)e).definition));
							return;
						}
						break;
					case 124:
						if (this.InstrumentDefinitionEnd != null)
						{
							this.InstrumentDefinitionEnd(this, new InstrumentDefinitionEndEventArgs(((OnInstrumentDefinitionEnd)e).end));
							return;
						}
						break;
					case 127:
						if (this.PortfolioAdded != null)
						{
							this.PortfolioAdded(this, new PortfolioEventArgs(((OnPortfolioAdded)e).portfolio));
							return;
						}
						break;
					case 128:
						if (this.PortfolioDeleted != null)
						{
							this.PortfolioDeleted(this, new PortfolioEventArgs(((OnPortfolioDeleted)e).portfolio));
							return;
						}
						break;
					case 129:
						if (this.PortfolioParentChanged != null)
						{
							this.PortfolioParentChanged(this, new PortfolioEventArgs(((OnPortfolioParentChanged)e).portfolio));
							return;
						}
						break;
					case 130:
						if (this.HistoricalData != null)
						{
							this.HistoricalData(this, new HistoricalDataEventArgs((HistoricalData)e));
							return;
						}
						break;
					case 131:
						if (this.HistoricalDataEnd != null)
						{
							this.HistoricalDataEnd(this, new HistoricalDataEndEventArgs((HistoricalDataEnd)e));
							return;
						}
						break;
					case 140:
						if (this.AccountData != null)
						{
							this.AccountData(this, new AccountDataEventArgs((AccountData)e));
							return;
						}
						break;
					default:
						switch (typeId)
						{
						case 207:
							if (this.EventManagerStarted != null)
							{
								this.EventManagerStarted(this, EventArgs.Empty);
								return;
							}
							break;
						case 208:
							if (this.EventManagerStopped != null)
							{
								this.EventManagerStopped(this, EventArgs.Empty);
								return;
							}
							break;
						case 209:
							if (this.EventManagerPaused != null)
							{
								this.EventManagerPaused(this, EventArgs.Empty);
								return;
							}
							break;
						case 210:
							if (this.EventManagerResumed != null)
							{
								this.EventManagerResumed(this, EventArgs.Empty);
								return;
							}
							break;
						case 211:
							if (this.EventManagerStep != null)
							{
								this.EventManagerStep(this, EventArgs.Empty);
							}
							break;
						default:
							return;
						}
						break;
					}
					break;
				}
			}
		}
Beispiel #14
0
		internal GroupEvent(Event obj, int groupId)
		{
			this.Obj = obj;
			this.GroupId = groupId;
		}
Beispiel #15
0
		public void OnEvent(Event e)
		{
			this.framework.eventManager.OnEvent(e);
		}
Beispiel #16
0
		private void OnLevel2Update(Event e)
		{
			this.data_count += 1L;
			Level2Update level2Update = (Level2Update)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = level2Update.dateTime;
			}
			else
			{
				level2Update.dateTime = this.framework.Clock.DateTime;
			}
			this.framework.dataManager.OnLevel2Update(level2Update);
			this.framework.providerManager.executionSimulator.OnLevel2(level2Update);
			this.framework.StrategyManager.OnLevel2(level2Update);
		}
Beispiel #17
0
		private void OnFundamental(Event e)
		{
			this.data_count += 1L;
			Fundamental fundamental = (Fundamental)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = fundamental.dateTime;
			}
			else
			{
				fundamental.dateTime = this.framework.clock.DateTime;
			}
			this.framework.dataManager.OnFundamental(fundamental);
			this.framework.strategyManager.OnFundamental(fundamental);
		}
Beispiel #18
0
		private void OnSimulatorStop(Event e)
		{
			OnSimulatorStop arg_06_0 = (OnSimulatorStop)e;
			this.framework.strategyManager.Stop();
			this.watch.Stop();
			long elapsedMilliseconds = this.watch.ElapsedMilliseconds;
			if (elapsedMilliseconds != 0L)
			{
				Console.WriteLine(string.Concat(new object[]
				{
					DateTime.Now,
					" Data run done, count = ",
					this.data_count,
					" ms = ",
					this.watch.ElapsedMilliseconds,
					" event/sec = ",
					this.data_count / elapsedMilliseconds * 1000L
				}));
			}
			else
			{
				Console.WriteLine(string.Concat(new object[]
				{
					DateTime.Now,
					" Data run done, count = ",
					this.data_count,
					" ms = 0"
				}));
			}
			this.framework.Mode = FrameworkMode.Realtime;
		}
Beispiel #19
0
		private void OnExecutionReport(Event e)
		{
			ExecutionReport executionReport = (ExecutionReport)e;
			if (this.framework.Clock.Mode == ClockMode.Realtime)
			{
				executionReport.dateTime = this.framework.Clock.DateTime;
			}
			this.framework.orderManager.OnExecutionReport(executionReport);
			this.framework.portfolioManager.OnExecutionReport(executionReport);
			this.framework.strategyManager.OnExecutionReport(executionReport);
		}
Beispiel #20
0
		private void OnSimulatorProgress(Event e)
		{
			OnSimulatorProgress arg_06_0 = (OnSimulatorProgress)e;
		}
Beispiel #21
0
		private void OnOrderStatusChanged(Event e)
		{
			this.framework.strategyManager.OnOrderStatusChanged(((OnOrderStatusChanged)e).order);
		}
Beispiel #22
0
		private void OnBid(Event e)
		{
			this.data_count += 1L;
			Bid bid = (Bid)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = bid.dateTime;
			}
			else
			{
				bid.dateTime = this.framework.clock.DateTime;
			}
			this.factory.OnData(bid);
			this.framework.dataManager.OnBid(bid);
			this.framework.instrumentManager.GetById(bid.instrumentId).bid = bid;
			this.framework.providerManager.executionSimulator.OnBid(bid);
			this.framework.strategyManager.OnBid(bid);
		}
Beispiel #23
0
		private void OnOrderCancelled(Event e)
		{
			this.framework.strategyManager.OnOrderCancelled(((OnOrderCancelled)e).order);
		}
Beispiel #24
0
		private void OnAsk(Event e)
		{
			this.data_count += 1L;
			Ask ask = (Ask)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = ask.DateTime;
			}
			else
			{
				ask.dateTime = this.framework.clock.DateTime;
			}
			this.factory.OnData(ask);
			this.framework.dataManager.OnAsk(ask);
			this.framework.instrumentManager.GetById(ask.instrumentId).ask = ask;
			this.framework.providerManager.executionSimulator.OnAsk(ask);
			this.framework.strategyManager.OnAsk(ask);
		}
Beispiel #25
0
		private void OnFill(Event e)
		{
			this.framework.strategyManager.OnFill((OnFill)e);
		}
Beispiel #26
0
		private void OnTrade(Event e)
		{
			this.data_count += 1L;
			Trade trade = (Trade)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = trade.dateTime;
			}
			else
			{
				trade.dateTime = this.framework.clock.DateTime;
			}
			this.factory.OnData(trade);
			this.framework.dataManager.OnTrade(trade);
			this.framework.instrumentManager.GetById(trade.instrumentId).trade = trade;
			this.framework.providerManager.executionSimulator.OnTrade(trade);
			this.framework.strategyManager.OnTrade(trade);
		}
Beispiel #27
0
		private void OnReminder(Event e)
		{
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = e.dateTime;
			}
			((Reminder)e).Execute();
		}
Beispiel #28
0
		private void OnBar(Event e)
		{
			this.data_count += 1L;
			Bar bar = (Bar)e;
			this.framework.dataManager.OnBar(bar);
			this.framework.providerManager.executionSimulator.OnBar(bar);
			this.framework.strategyManager.OnBar(bar);
		}
Beispiel #29
0
		private void OnHistoricalDataEnd(Event e)
		{
			this.framework.dataManager.OnHistoricalDataEnd((HistoricalDataEnd)e);
		}
Beispiel #30
0
		private void OnLevel2Snapshot(Event e)
		{
			this.data_count += 1L;
			Level2Snapshot level2Snapshot = (Level2Snapshot)e;
			if (this.framework.Clock.Mode == ClockMode.Simulation)
			{
				this.framework.Clock.DateTime = level2Snapshot.dateTime;
			}
			else
			{
				level2Snapshot.dateTime = this.framework.Clock.DateTime;
			}
			this.framework.dataManager.OnLevel2Snapshot(level2Snapshot);
			this.framework.providerManager.executionSimulator.OnLevel2(level2Snapshot);
			this.framework.strategyManager.OnLevel2(level2Snapshot);
		}