コード例 #1
0
        /// <summary>
        /// Sends a new Market Order Request to 'Order Execution Server'
        /// </summary>
        /// <param name="orderDetails">Contains market order information</param>
        public void MarketOrderRequests(OrderDetails orderDetails)
        {
            // Get new Order ID
            orderDetails.ID = _orderExecutionService.GetOrderId();

            // Create Market Order object to be sent to 'Order Execution Service'
            MarketOrder marketOrder = OrderMessage.GenerateMarketOrder(orderDetails.ID, orderDetails.Security, orderDetails.Side,
                                                                       orderDetails.Quantity, orderDetails.Provider);

            // Send Request to Server
            _orderExecutionService.SendOrder(marketOrder);
        }
コード例 #2
0
        public void MarketOrderTestCase()
        {
            bool logonArrived     = false;
            bool logoutArrived    = false;
            bool newArrived       = false;
            bool executionArrived = false;

            ManualResetEvent manualLogonEvent     = new ManualResetEvent(false);
            ManualResetEvent manualLogoutEvent    = new ManualResetEvent(false);
            ManualResetEvent manualConnectedEvent = new ManualResetEvent(false);
            ManualResetEvent manualNewOrderEvent  = new ManualResetEvent(false);
            ManualResetEvent manualExecutionEvent = 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 MarketOrder(TradeHubConstants.OrderExecutionProvider.Simulated)
                {
                    Security = new Security {
                        Symbol = "AAPL"
                    },
                    OrderSide = TradeHubConstants.OrderSide.BUY,
                    OrderSize = 100,
                    OrderID   = "01"
                });
                manualLogonEvent.Set();
            };

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

            _service.ExecutionArrived +=
                delegate(Execution obj)
            {
                executionArrived = true;
                _service.Logout(new Logout {
                    OrderExecutionProvider = TradeHubConstants.OrderExecutionProvider.Simulated
                });
                manualExecutionEvent.Set();
            };

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

            _service.StartService();

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

            Assert.AreEqual(true, logonArrived, "Logon Arrived");
            Assert.AreEqual(true, newArrived, "New Arrived");
            Assert.AreEqual(true, executionArrived, "Execution Arrived");
            Assert.AreEqual(true, logoutArrived, "Logout Arrived");
        }