Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
 public EventClient(EventDispatcher dispatcher)
 {
     this.dispatcher = dispatcher;
     Id = counter++;
     dispatcher.Add(this);
 }