public string GetSendMessage <T>(string correlationId, string topic, T body)
 {
     return(String.Format("SEND\r\ncorrelation-id:{0}\r\nX-Deltix-Nonce:{2}\r\ndestination:{1}\r\n\r\n{3}\r\n\r\n\0",
                          correlationId, topic,
                          StompWebSocketService.ConvertToUnixTimestamp(DateTime.Now),
                          JsonConvert.SerializeObject(body)));
 }
 public void GetTransactions(Action <string> action, long startTime)
 {
     StompWebSocketService.SendMessage("", TransactionsDestination, new TransactionsStartTime()
     {
         StartTime = startTime
     }, action);
 }
Exemple #3
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);
        }
 public void OrdersUnsubscribe(Action <string> action)
 {
     StompWebSocketService.Unsubscribe(OrdersSubscribe, action);
 }
 public void OrdersReceiver(Action <string> action)
 {
     StompWebSocketService.Subscribe(OrdersSubscribe, action);
 }
 public void OrderBookUnsubscribe(string topic, Action <string> action)
 {
     StompWebSocketService.Unsubscribe(topic, action);
 }
        public void CancelOrder(string orderId, Action <string> action)
        {
            string idHeader = String.Format("X-Deltix-Order-ID:{0}\r\n", orderId);

            StompWebSocketService.SendMessage(idHeader, DeleteOrder, "", action);
        }
 public void CheckBalance(Action <string> action)
 {
     StompWebSocketService.SendMessage("", BalanceDestination, "", action);
 }
 public void SendOrder(OrderCrypto order, Action <string> action)
 {
     StompWebSocketService.SendMessage("", CreateOrder, order, action);
 }
Exemple #10
0
 public static string GetSendOrderRequest(OrderCrypto order)
 {
     return(String.Format("correlation-id:ioeswd7t9m\r\nX-Deltix-Nonce:{0}\r\ndestination:/app/v1/orders/create\r\n\r\n{1}",
                          StompWebSocketService.ConvertToUnixTimestamp(DateTime.Now),
                          JsonConvert.SerializeObject(order)));
 }
Exemple #11
0
 public SubscriptionFactory(string url, string token)
 {
     _url   = url;
     _token = token;
     StompWebSocketService = new StompWebSocketService(_url, _token);
 }