Exemplo n.º 1
0
 def run(self):
     while True:
         host = self.url
         websocket.enableTrace(False)
         ws = websocket.WebSocketApp(host,
                                     on_message=self.on_message,
                                     on_error=self.on_error,
                                     on_close=self.on_close)
         ws.on_open = self.on_open
         ws.run_forever()
Exemplo n.º 2
0
def on_error(self, evt):
    print('7777777777777777777')
    print(evt)


def on_close(self):
    print('DISCONNECT')


if __name__ == "__main__":
    from config.config import websocket_future_compress_url

    while True:
        url = websocket_future_compress_url  # if okcoin.cn  change url wss://real.okcoin.cn:10440/websocket/okcoinapi
        api_key = '0a5ba5fe-2ce4-4f2a-b308-1f6f17d3e6ec'
        secret_key = '82B69BD2B7DBBABF726D046C37C7969F'
        # 存放上一条数据
        result = {}
        host = url
        websocket.enableTrace(False)
        # if len(sys.argv) < 2:
        #     host = url
        # else:
        #     host = sys.argv[1]
        ws = websocket.WebSocketApp(host,
                                    on_message=on_message,
                                    on_error=on_error,
                                    on_close=on_close)
        ws.on_open = on_open
        ws.run_forever()