public void Attach(EventBus bus) { var q = new EventQueue(EventQueueId.Data, EventQueueType.Master, EventQueuePriority.Normal, 25600, null) { IsSynched = true, Name = $"attached {bus.framework.Name}" }; q.Enqueue(new OnQueueOpened(q)); bus.DataPipe.Add(q); this.attached[this.attachedCount++] = q; }
private Framework(string name, FrameworkMode mode, bool createServers, EventBus externalBus, InstrumentServer instrumentServer, DataServer dataServer, string fileServerPath) { Name = name; this.mode = mode; LoadConfiguration(); // Setup events compoents setup EventBus = new EventBus(this); OutputManager = new OutputManager(this, Configuration.IsOutputLogEnabled ? Configuration.OutputLogFileName : null); Clock = new Clock(this, ClockType.Local, false); EventBus.LocalClockEventQueue = Clock.ReminderQueue; ExchangeClock = new Clock(this, ClockType.Exchange, false); EventBus.ExchangeClockEventQueue = ExchangeClock.ReminderQueue; externalBus?.Attach(EventBus); EventServer = new EventServer(this, EventBus); EventManager = new EventManager(this, EventBus); // Setup streamers StreamerManager = new StreamerManager(); StreamerManager.AddDefaultStreamers(); // Create Servers var iServer = instrumentServer ?? new FileInstrumentServer(this, Configuration.InstrumentFileName); var dServer = dataServer ?? new FileDataServer(this, Configuration.DataFileName); var oServer = new FileOrderServer(this, Configuration.OrderFileName); var pServer = new FilePortfolioServer(this, Configuration.PortfolioFileName); InstrumentManager = new InstrumentManager(this, iServer); InstrumentServer = iServer; InstrumentManager.Load(); DataManager = new DataManager(this, dServer); DataServer = dServer; OrderManager = new OrderManager(this, oServer); OrderServer = oServer; PortfolioManager = new PortfolioManager(this, pServer); PortfolioServer = pServer; UserServer = new XmlUserServer(this); UserManager = new UserManager(this, UserServer); UserManager.Load(); // Create Providers ProviderManager = new ProviderManager(this); // Other stuff EventLoggerManager = new EventLoggerManager(); SubscriptionManager = new SubscriptionManager(this); ScenarioManager = new ScenarioManager(this); StrategyManager = new StrategyManager(this); StatisticsManager = new StatisticsManager(this); GroupManager = new GroupManager(this); AccountDataManager = new AccountDataManager(this); LicenseManager = new LicenseManager(); CurrencyConverter = new CurrencyConverter(this); DataFileManager = new DataFileManager(Installation.DataDir.FullName); instance = instance ?? this; }
public Framework(string name, EventBus externalBus, InstrumentServer instrumentServer, DataServer dataServer = null) : this(name, FrameworkMode.Simulation, createServers: false, externalBus: externalBus, instrumentServer: instrumentServer, dataServer: dataServer, fileServerPath: String.Empty) { }
public void Detach(EventBus bus) { string name = "attached " + bus.framework.Name; var index = Array.FindIndex(this.attached, 0, this.attachedCount, q => q.Name == name); if (index != -1) { var found = this.attached[index]; for (int i = index; i < this.attachedCount - 1; ++i) this.attached[i] = this.attached[i + 1]; this.attachedCount--; bus.DataPipe.Remove(found); } else Console.WriteLine($"EventBus::Detach Can not find attached bus queue : {bus.framework.Name}"); }
public EventManager(Framework framework, EventBus bus) { this.framework = framework; this.bus = bus; BarFactory = new BarFactory(this.framework); BarSliceFactory = new BarSliceFactory(this.framework); Dispatcher = new EventDispatcher(this.framework); // Event Gates this.gates[EventType.Bid] = OnBid; this.gates[EventType.Ask] = OnAsk; this.gates[EventType.Trade] = OnTrade; this.gates[EventType.Quote] = OnQuote; this.gates[EventType.Bar] = OnBar; this.gates[EventType.Level2Snapshot] = OnLevel2Snapshot; this.gates[EventType.Level2Update] = OnLevel2Update; this.gates[EventType.ExecutionReport] = OnExecutionReport; this.gates[EventType.Reminder] = OnReminder; this.gates[EventType.Fundamental] = OnFundamental; this.gates[EventType.News] = OnNews; this.gates[EventType.Group] = OnGroup; this.gates[EventType.GroupEvent] = OnGroupEvent; this.gates[EventType.Command] = OnCommand; this.gates[EventType.OnPositionOpened] = OnPositionOpened; this.gates[EventType.OnPositionClosed] = OnPositionClosed; this.gates[EventType.OnPositionChanged] = OnPositionChanged; this.gates[EventType.OnFill] = OnFill; this.gates[EventType.OnTransaction] = OnTransaction; this.gates[EventType.OnSendOrder] = OnSendOrder; this.gates[EventType.OnPendingNewOrder] = OnPendingNewOrder; this.gates[EventType.OnNewOrder] = OnNewOrder; this.gates[EventType.OnOrderStatusChanged] = OnOrderStatusChanged; this.gates[EventType.OnOrderPartiallyFilled] = OnOrderPartiallyFilled; this.gates[EventType.OnOrderFilled] = OnOrderFilled; this.gates[EventType.OnOrderReplaced] = OnOrderReplaced; this.gates[EventType.OnOrderCancelled] = OnOrderCancelled; this.gates[EventType.OnOrderRejected] = OnOrderRejected; this.gates[EventType.OnOrderExpired] = OnOrderExpired; this.gates[EventType.OnOrderCancelRejected] = OnOrderCancelRejected; this.gates[EventType.OnOrderReplaceRejected] = OnOrderReplaceRejected; this.gates[EventType.OnOrderDone] = OnOrderDone; this.gates[EventType.OnPortfolioAdded] = OnPortfolioAdded; this.gates[EventType.OnPortfolioRemoved] = OnPortfolioRemoved; this.gates[EventType.OnPortfolioParentChanged] = OnPortfolioParentChanged; this.gates[EventType.HistoricalData] = OnHistoricalData; this.gates[EventType.HistoricalDataEnd] = OnHistoricalDataEnd; this.gates[EventType.BarSlice] = OnBarSlice; this.gates[EventType.OnStrategyEvent] = OnStrategyEvent; this.gates[EventType.AccountData] = OnAccountData; this.gates[EventType.OnPropertyChanged] = OnPropertyChanged; this.gates[EventType.OnException] = OnException; this.gates[EventType.AccountReport] = OnAccountReport; this.gates[EventType.ProviderError] = OnProviderError; this.gates[EventType.OnProviderConnected] = OnProviderConnected; this.gates[EventType.OnProviderDisconnected] = OnProviderDisconnected; this.gates[EventType.OnSimulatorStart] = OnSimulatorStart; this.gates[EventType.OnSimulatorStop] = OnSimulatorStop; this.gates[EventType.OnSimulatorProgress] = OnSimulatorProgress; // Enable all events by defaults for (int i = 0; i < byte.MaxValue; i++) Enabled[i] = true; if (bus != null) { this.thread = new Thread(Run) { Name = "Event Manager Thread", IsBackground = true }; this.thread.Start(); } }
public Framework(string name, EventBus externalBus, InstrumentServer instrumentServer, DataServer dataServer = null) : this(name, FrameworkMode.Simulation, createServers : false, externalBus : externalBus, instrumentServer : instrumentServer, dataServer : dataServer, fileServerPath : String.Empty) { }
public EventServer(Framework framework, EventBus bus) { this.framework = framework; this.bus = bus; }
public EventManager(Framework framework, EventBus bus) { this.framework = framework; this.bus = bus; BarFactory = new BarFactory(this.framework); BarSliceFactory = new BarSliceFactory(this.framework); Dispatcher = new EventDispatcher(this.framework); // Event Gates this.gates[EventType.Bid] = OnBid; this.gates[EventType.Ask] = OnAsk; this.gates[EventType.Trade] = OnTrade; this.gates[EventType.Quote] = OnQuote; this.gates[EventType.Bar] = OnBar; this.gates[EventType.Level2Snapshot] = OnLevel2Snapshot; this.gates[EventType.Level2Update] = OnLevel2Update; this.gates[EventType.ExecutionReport] = OnExecutionReport; this.gates[EventType.Reminder] = OnReminder; this.gates[EventType.Fundamental] = OnFundamental; this.gates[EventType.News] = OnNews; this.gates[EventType.Group] = OnGroup; this.gates[EventType.GroupEvent] = OnGroupEvent; this.gates[EventType.Command] = OnCommand; this.gates[EventType.OnPositionOpened] = OnPositionOpened; this.gates[EventType.OnPositionClosed] = OnPositionClosed; this.gates[EventType.OnPositionChanged] = OnPositionChanged; this.gates[EventType.OnFill] = OnFill; this.gates[EventType.OnTransaction] = OnTransaction; this.gates[EventType.OnSendOrder] = OnSendOrder; this.gates[EventType.OnPendingNewOrder] = OnPendingNewOrder; this.gates[EventType.OnNewOrder] = OnNewOrder; this.gates[EventType.OnOrderStatusChanged] = OnOrderStatusChanged; this.gates[EventType.OnOrderPartiallyFilled] = OnOrderPartiallyFilled; this.gates[EventType.OnOrderFilled] = OnOrderFilled; this.gates[EventType.OnOrderReplaced] = OnOrderReplaced; this.gates[EventType.OnOrderCancelled] = OnOrderCancelled; this.gates[EventType.OnOrderRejected] = OnOrderRejected; this.gates[EventType.OnOrderExpired] = OnOrderExpired; this.gates[EventType.OnOrderCancelRejected] = OnOrderCancelRejected; this.gates[EventType.OnOrderReplaceRejected] = OnOrderReplaceRejected; this.gates[EventType.OnOrderDone] = OnOrderDone; this.gates[EventType.OnPortfolioAdded] = OnPortfolioAdded; this.gates[EventType.OnPortfolioRemoved] = OnPortfolioRemoved; this.gates[EventType.OnPortfolioParentChanged] = OnPortfolioParentChanged; this.gates[EventType.HistoricalData] = OnHistoricalData; this.gates[EventType.HistoricalDataEnd] = OnHistoricalDataEnd; this.gates[EventType.BarSlice] = OnBarSlice; this.gates[EventType.OnStrategyEvent] = OnStrategyEvent; this.gates[EventType.AccountData] = OnAccountData; this.gates[EventType.OnPropertyChanged] = OnPropertyChanged; this.gates[EventType.OnException] = OnException; this.gates[EventType.AccountReport] = OnAccountReport; this.gates[EventType.ProviderError] = OnProviderError; this.gates[EventType.OnProviderConnected] = OnProviderConnected; this.gates[EventType.OnProviderDisconnected] = OnProviderDisconnected; this.gates[EventType.OnSimulatorStart] = OnSimulatorStart; this.gates[EventType.OnSimulatorStop] = OnSimulatorStop; this.gates[EventType.OnSimulatorProgress] = OnSimulatorProgress; // Enable all events by defaults for (int i = 0; i < byte.MaxValue; i++) { Enabled[i] = true; } if (bus != null) { this.thread = new Thread(Run) { Name = "Event Manager Thread", IsBackground = true }; this.thread.Start(); } }