Beispiel #1
0
        private void WaitSendingLimitOrder()
        {
            int counter = 0;

            Order.Price             = CalcPassiveOrderPrice(Order.Side);
            TestContent.OrderStatus = OrderStatus.PENDING;
            TraderSubscriber.SendOrder(Order, OrderResponce);

            while (!TestContent.IsOrderSent && counter++ < 100)
            {
                Thread.Sleep(100);
            }

            if (TestContent.OrderStatus == OrderStatus.PENDING)
            {
                try
                {
                    TestTrader.ExecuteOrder(Order);
                }
                catch (Exception ex)
                {
                    TestContent.IsSuccess   = false;
                    TestContent.OrderStatus = OrderStatus.INDEFINITE;
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #2
0
        private void GeneralCheck(string testName, bool isPassive)
        {
            long sentOrderTime = StompWebSocketService.ConvertToUnixTimestamp(DateTime.Now.AddSeconds(-1));

            Logger.Debug("Send order time: {0}", TradeSetting.GetStringTime(DateTime.Now));

            if (Order.Type == OrderType.LIMIT && isPassive)
            {
                WaitSendingLimitOrder();
            }
            else
            {
                TraderSubscriber.SendOrder(Order, OrderResponce);
                TestContent.OrderStatus = OrderStatus.PENDING;
            }

            WaitOrderStatus();

            if (TestContent.IsSuccess)
            {
                ManagerSubscriber.GetTransactions(SaveTransactions, sentOrderTime);
                Thread.Sleep(1000);
                try
                {
                    CheckCommissions(isPassive);
                }
                catch (Exception ex)
                {
                    TestContent.IsSuccess = false;
                    Console.WriteLine("While calculating commissions an error occured: {0}", ex.Message);
                    Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                }

                try
                {
                    TraderSubscriber.CheckBalance(CheckNewBalance);
                }
                catch (Exception ex)
                {
                    TestContent.IsSuccess = false;
                    Console.WriteLine("While checking balance an error occured: {0}", ex.Message);
                    Console.WriteLine("Stack trace: {0}", ex.StackTrace);
                }

                Thread.Sleep(2000);
            }

            AddTestResult(TestContent.IsSuccess && TestContent.IsOrderSent, testName);
        }