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)));
 }
Ejemplo n.º 2
0
 public void GetTransactions(Action <string> action, long startTime)
 {
     StompWebSocketService.SendMessage("", TransactionsDestination, new TransactionsStartTime()
     {
         StartTime = startTime
     }, action);
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public void OrdersUnsubscribe(Action <string> action)
 {
     StompWebSocketService.Unsubscribe(OrdersSubscribe, action);
 }
Ejemplo n.º 5
0
 public void OrdersReceiver(Action <string> action)
 {
     StompWebSocketService.Subscribe(OrdersSubscribe, action);
 }
Ejemplo n.º 6
0
 public void OrderBookUnsubscribe(string topic, Action <string> action)
 {
     StompWebSocketService.Unsubscribe(topic, action);
 }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
 public void CheckBalance(Action <string> action)
 {
     StompWebSocketService.SendMessage("", BalanceDestination, "", action);
 }
Ejemplo n.º 9
0
 public void SendOrder(OrderCrypto order, Action <string> action)
 {
     StompWebSocketService.SendMessage("", CreateOrder, order, action);
 }
Ejemplo n.º 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)));
 }
Ejemplo n.º 11
0
 public SubscriptionFactory(string url, string token)
 {
     _url   = url;
     _token = token;
     StompWebSocketService = new StompWebSocketService(_url, _token);
 }