Exemplo n.º 1
0
        public void MultiMarketDataTickTest()
        {
            string providerOne = MarketDataProvider.Fxcm;
            string providerTwo = MarketDataProvider.Blackwood;

            _multiBrokerHubStrategy = new MultiBrokerTestStrategy("EUR/USD", "ERX", providerOne, providerTwo, providerOne, providerTwo);

            var logonEvent = new ManualResetEvent(false);
            var tickEvent  = new ManualResetEvent(false);

            int loginCount = 0;

            bool providerOneTickArrived = false;
            bool providerTwoTickArrived = false;

            _multiBrokerHubStrategy.MarketDataLogonArrived += delegate(string marketDataProvider)
            {
                loginCount++;
                if (loginCount == 2)
                {
                    logonEvent.Set();
                }
            };

            _multiBrokerHubStrategy.TickArrived += delegate(Tick tick)
            {
                if (tick.MarketDataProvider.Equals(providerOne))
                {
                    providerOneTickArrived = true;
                }
                else
                {
                    providerTwoTickArrived = true;
                }

                Console.WriteLine(tick);

                if (providerOneTickArrived && providerTwoTickArrived)
                {
                    tickEvent.Set();
                }
            };

            logonEvent.WaitOne(14000, false);
            tickEvent.WaitOne(14000, false);

            Assert.AreEqual(2, loginCount, "Login Count");
            Assert.IsTrue(providerOneTickArrived, "Provider One Tick Arrived");
            Assert.IsTrue(providerTwoTickArrived, "Provider Two Tick Arrived");
        }
Exemplo n.º 2
0
        public void MultiOrderExecutionOrderTest()
        {
            string providerOne = MarketDataProvider.Fxcm;
            string providerTwo = MarketDataProvider.Blackwood;

            _multiBrokerHubStrategy = new MultiBrokerTestStrategy("EUR/USD", "ERX", providerOne, providerTwo, providerOne, providerTwo);

            var logonEvent = new ManualResetEvent(false);
            var orderEvent = new ManualResetEvent(false);

            int loginCount = 0;

            bool providerOneOrderExecuted = false;
            bool providerTwoOrderExecuted = false;

            _multiBrokerHubStrategy.MarketDataLogonArrived += delegate(string marketDataProvider)
            {
                loginCount++;
                if (loginCount == 2)
                {
                    logonEvent.Set();
                }
            };

            _multiBrokerHubStrategy.OnNewExecutionReceived += delegate(Execution execution)
            {
                if (execution.OrderExecutionProvider.Equals(providerOne))
                {
                    providerOneOrderExecuted = true;
                }
                else
                {
                    providerTwoOrderExecuted = true;
                }

                Console.WriteLine(execution);

                if (providerOneOrderExecuted && providerTwoOrderExecuted)
                {
                    orderEvent.Set();
                }
            };

            logonEvent.WaitOne(14000, false);
            orderEvent.WaitOne(14000, false);

            Assert.AreEqual(2, loginCount, "Login Count");
            Assert.IsTrue(providerOneOrderExecuted, "Provider One Order Executed");
            Assert.IsTrue(providerTwoOrderExecuted, "Provider Two Order Executed");
        }
Exemplo n.º 3
0
        public void MultiMarketDataLoginTest()
        {
            string providerOne = MarketDataProvider.Fxcm;
            string providerTwo = MarketDataProvider.Simulated;

            _multiBrokerHubStrategy = new MultiBrokerTestStrategy("EUR/USD", "ERX", providerOne, providerTwo, providerOne, providerTwo);

            var logonEvent = new ManualResetEvent(false);

            int loginCount = 0;

            _multiBrokerHubStrategy.MarketDataLogonArrived += delegate(string marketDataProvider)
            {
                loginCount++;
                if (loginCount == 2)
                {
                    logonEvent.Set();
                }
            };

            logonEvent.WaitOne(14000, false);

            Assert.AreEqual(2, loginCount, "Login Count");
        }