import sys
import websocket
import json
import time

class OkCoin:
    def freshTicker(self, deJson):
        data = deJson[0]['data']
        _high = data['high']
        _last = data['last']
        _low = data['low']
        _open = data['open']
        _close = data['close']
        sys.stdout.write('\033[1A\033[K')
        print('ETH:high=%-7s low=%-7s last=\033[;;34m%-7s\033[0m open=%-7s close=%-7s'
               % (_high, _low, _last, _open, _close))

    def on_message(self, ws, msg):
        #print(msg)
        deJson = json.loads(msg)
        channel = deJson[0]['channel']
        if channel == 'ok_sub_spotcny_eth_ticker':
            self.freshTicker(deJson)

    def on_error(self, ws, error):
        print(error)

    def on_close(self, ws):
        print("#### closed ###")

    def on_open(self, ws):
        ws.send("{'event':'addChannel','channel':'ok_sub_spotcny_eth_ticker'}")
        print('### opening ###')

    def connect(self):
        websocket.enableTrace(False)
        self.ws = websocket.WebSocketApp("wss://real.okcoin.cn:10440/websocket/okcoinapi",
                                    on_message = self.on_message,
                                    on_error = self.on_error,
                                    on_close = self.on_close)
        self.ws.on_open = self.on_open
        self.ws.run_forever()

if __name__ == "__main__":
    okcoin = OkCoin()
    okcoin.connect()

@@ -4,16 +4,30 @@
 ort sys%0A
+import signal%0A
 import w
@@ -685,16 +685,71 @@
 (deJson)
+%0A        else:%0A            pass%0A            #print(msg)
 %0A%0A    de
@@ -831,24 +831,38 @@
 s):%0A        
+pass%0A        #
 print(%22#### 
@@ -986,24 +986,25 @@
 %7D%22)%0A        
+#
 print('### o
@@ -1409,57 +1409,299 @@
     
-self.ws.run_forever()%0A%0Aif __name__ == %22__main__%22:
+while True:%0A            sys.stdout.write('%5C033%5B1A%5C033%5BK')%0A            self.ws.run_forever()%0A%0A%0Adef sigint_handler(signum,frame):%0A    print %22exit%22%0A    sys.exit()%0A%0A%0Aif __name__ == %22__main__%22:%0A    signal.signal(signal.SIGINT, sigint_handler)%0A    print('### start ###')%0A    print('### start ###')
 %0A   

Fix stop refresh from disconnect