public void CancelOrderTestCase()
        {
            bool logonArrived        = false;
            bool logoutArrived       = false;
            bool newArrived          = false;
            bool cancellationArrived = false;

            ManualResetEvent manualLogonEvent        = new ManualResetEvent(false);
            ManualResetEvent manualLogoutEvent       = new ManualResetEvent(false);
            ManualResetEvent manualConnectedEvent    = new ManualResetEvent(false);
            ManualResetEvent manualNewOrderEvent     = new ManualResetEvent(false);
            ManualResetEvent manualCancellationEvent = new ManualResetEvent(false);

            _service.Connected += delegate()
            {
                _service.Login(new Login()
                {
                    OrderExecutionProvider = TradeHubConstants.OrderExecutionProvider.Simulated
                });
                manualConnectedEvent.Set();
            };

            _service.LogonArrived +=
                delegate(string obj)
            {
                logonArrived = true;
                _service.SendOrder(new LimitOrder(TradeHubConstants.OrderExecutionProvider.Simulated)
                {
                    Security = new Security {
                        Symbol = "AAPL"
                    },
                    OrderSide  = TradeHubConstants.OrderSide.BUY,
                    OrderSize  = 100,
                    LimitPrice = 1.23m,
                    OrderID    = "01"
                });
                manualLogonEvent.Set();
            };

            _service.NewArrived +=
                delegate(Order obj)
            {
                newArrived = true;
                _service.CancelOrder("01");
                manualNewOrderEvent.Set();
            };

            _service.CancellationArrived +=
                delegate(Order obj)
            {
                cancellationArrived = true;
                _service.Logout(new Logout {
                    OrderExecutionProvider = TradeHubConstants.OrderExecutionProvider.Simulated
                });
                manualCancellationEvent.Set();
            };

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

            _service.StartService();

            manualConnectedEvent.WaitOne(30000, false);
            manualLogonEvent.WaitOne(30000, false);
            manualNewOrderEvent.WaitOne(30000, false);
            manualCancellationEvent.WaitOne(30000, false);
            manualLogoutEvent.WaitOne(30000, false);

            Assert.AreEqual(true, logonArrived, "Logon Arrived");
            Assert.AreEqual(true, newArrived, "New Arrived");
            Assert.AreEqual(true, cancellationArrived, "Cancellation Arrived");
            Assert.AreEqual(true, logoutArrived, "Logout Arrived");
        }
Пример #2
0
 /// <summary>
 /// Sends order cancellation request to 'Order Execution Server'
 /// </summary>
 /// <param name="orderId">ID for the order to be cancelled</param>
 public void CancelOrderRequest(string orderId)
 {
     _orderExecutionService.CancelOrder(orderId);
 }