Exemple #1
0
        void _marketDataEngineClient_InquiryResponseArrived(Common.Core.ValueObjects.Inquiry.MarketDataProviderInfo obj)
        {
            Subscribe subscribe = new Subscribe();

            subscribe.MarketDataProvider = Common.Core.Constants.MarketDataProvider.Simulated;
            subscribe.Security           = new Security()
            {
                Symbol = "IBM"
            };
            _marketDataEngineClient.SendTickSubscriptionRequest(subscribe);
        }
Exemple #2
0
        public void MarketDataProviderTickTestCase()
        {
            bool      logonArrived           = false;
            bool      logoutArrived          = false;
            bool      inquiryResponseArrived = false;
            int       count     = 1;
            Stopwatch stopwatch = new Stopwatch();

            ManualResetEvent manualLogonEvent           = new ManualResetEvent(false);
            ManualResetEvent manualLogoutEvent          = new ManualResetEvent(false);
            ManualResetEvent manualConnectedEvent       = new ManualResetEvent(false);
            ManualResetEvent manualInquiryResponseEvent = new ManualResetEvent(false);
            ManualResetEvent manualTickArrivedEvent     = new ManualResetEvent(false);

            _marketDataEngineClient.ServerConnected += delegate()
            {
                _marketDataEngineClient.SendLoginRequest(new Login()
                {
                    MarketDataProvider = TradeHubConstants.MarketDataProvider.Simulated
                });
                manualConnectedEvent.Set();
            };

            _marketDataEngineClient.LogonArrived +=
                delegate(string obj)
            {
                logonArrived = true;

                _marketDataEngineClient.SendInquiryRequest(TradeHubConstants.MarketDataProvider.Simulated);
                manualLogonEvent.Set();
            };

            _marketDataEngineClient.InquiryResponseArrived +=
                delegate(MarketDataProviderInfo obj)
            {
                inquiryResponseArrived = true;
                Console.WriteLine(obj);
                // _marketDataEngineClient.SendLogoutRequest(new Logout { MarketDataProvider = TradeHubConstants.MarketDataProvider.Simulated });
                Subscribe subscribe = new Subscribe();
                subscribe.MarketDataProvider = TradeHubConstants.MarketDataProvider.Simulated;
                subscribe.Security           = new Security()
                {
                    Symbol = "IBM"
                };
                _marketDataEngineClient.SendTickSubscriptionRequest(subscribe);
                manualInquiryResponseEvent.Set();
            };
            _marketDataEngineClient.TickArrived += delegate(Tick tick)
            {
                if (count == 1)
                {
                    stopwatch.Start();
                }
                if (count == 1000000)
                {
                    stopwatch.Stop();
                    Console.WriteLine("1000000 Ticks recevied in " + stopwatch.ElapsedMilliseconds + " ms");
                    _marketDataEngineClient.SendLogoutRequest(new Logout {
                        MarketDataProvider = TradeHubConstants.MarketDataProvider.Simulated
                    });
                    manualTickArrivedEvent.Set();
                    //  Logger.Info("Recevied Tick=" + tick, "", "MarketDataProviderBarTestCase");
                }
                count++;
            };

            _marketDataEngineClient.LogoutArrived +=
                delegate(string obj)
            {
                logoutArrived = true;
                manualLogoutEvent.Set();
            };

            _marketDataEngineClient.Start();

            manualConnectedEvent.WaitOne(30000, false);
            manualLogonEvent.WaitOne(30000, false);
            manualInquiryResponseEvent.WaitOne(30000, false);
            manualLogoutEvent.WaitOne(30000, false);
            manualTickArrivedEvent.WaitOne(500000);

            Assert.AreEqual(true, logonArrived, "Logon Arrived");
            Assert.AreEqual(true, inquiryResponseArrived, "Inquiry Response Arrived");
            Assert.AreEqual(1000001, count, "Tick arrived");
            Assert.AreEqual(true, logoutArrived, "Logout Arrived");
            Console.WriteLine("1000000 Ticks recevied in " + stopwatch.ElapsedMilliseconds + " ms");
            Console.WriteLine(1000000 / stopwatch.ElapsedMilliseconds * 1000 + "msg/sec");
        }