瀏覽代碼

streaming release 2

minor fix
laxaurus 6 年之前
父節點
當前提交
81517641cf
共有 3 個文件被更改,包括 9 次插入7 次删除
  1. 1 1
      src/config/tws_gateway.cfg
  2. 3 2
      src/ormdapi/v2/ws/client/ws_api_client.py
  3. 5 4
      src/ormdapi/v2/ws/client/ws_api_test.py

+ 1 - 1
src/config/tws_gateway.cfg

@@ -57,6 +57,6 @@ webconsole.auto_reload: False
 #
 restapi.list_label: 'api_log'
 #restapi.telegram_tok: '870564010:AAFxQa7-WFe2JjTP3KLoyY77NW90smTrnig'
-restapi.web_socket_host: 'localhost'
+restapi.web_socket_host: '0.0.0.0'
 restapi.web_socket_port: 9005
 

+ 3 - 2
src/ormdapi/v2/ws/client/ws_api_client.py

@@ -64,8 +64,9 @@ class RestStream():
     RS_ACCEPTED = 'rs_accepted'
     EVENTS = [RS_ORDER_STATUS, RS_QUOTE, RS_ACCEPTED]
     
-    def __init__(self, host, port):
-        self.url = 'ws://%s:%d' % (host, port)
+    def __init__(self, host, port=None):
+        connect_str = 'ws://%s' % host if (port == '' or port == None) else 'ws://%s:%d' % (host, port)
+        self.url = connect_str
         self.events = { event : []
                           for event in RestStream.EVENTS }
         

+ 5 - 4
src/ormdapi/v2/ws/client/ws_api_test.py

@@ -50,9 +50,10 @@ if __name__ == "__main__":
     level=logging.INFO
     )
     
-    rest_server = 'localhost:5001' # ormd.vortifytech.com
-    ws_server = 'localhost'
-    rs = RestStream(ws_server, 9005)
+    rest_server = 'ormd.vortifytech.com'
+    ws_server = 'ws-ormd.vortifytech.com/ws'
+
+    rs = RestStream(ws_server) 
     try:
         
         '''
@@ -68,7 +69,7 @@ if __name__ == "__main__":
         test_new_order(rest_server, handle)
 
         # run a few seconds and quit 
-        time.sleep(5)
+        time.sleep(2)
         
     except KeyboardInterrupt:
         logging.warn('Received CTRL-C...terminating')