How can I pull the "Candles" argument from the Huobi websocket data?
I will just throw it out here, there is a better way to do it, here above I was using Huobi SDK but I find using websocket without any external libraries better. A great template for websocket connection below:
import gzip
import json
import pprint
import threading

import time
import websocket


def send_message(ws, message_dict):
    data = json.dumps(message_dict).encode()
    print(&quot;Sending Message:&quot;)
    pprint.pprint(message_dict)
    ws.send(data)


def on_message(ws, message):
    unzipped_data = gzip.decompress(message).decode()
    msg_dict = json.loads(unzipped_data)
    print(&quot;Recieved Message: &quot;)
    pprint.pprint(msg_dict)
    if 'ping' in msg_dict:
        data = {
            &quot;pong&quot;: msg_dict['ping']
        }
        send_message(ws, data)


def on_error(ws, error):
    print(&quot;Error: &quot; + str(error))
    error = gzip.decompress(error).decode()
    print(error)


def on_close(ws):
    print(&quot;### closed ###&quot;)


def on_open(ws):
    def run(*args):
        data = {
            &quot;req&quot;: &quot;market.btcusdt.kline.1min&quot;,
            &quot;id&quot;: &quot;id1&quot;
            &quot;from&quot;: int(&quot;fromtimestamp&quot;)
            &quot;to&quot;: int(&quot;to timestamp&quot;)
        }

        for i in range(5):
            time.sleep(2)
            send_message(ws, data)
        ws.close()
        print(&quot;thread terminating...&quot;)

    t = threading.Thread(target=run, args=())
    t.start()


if __name__ == &quot;__main__&quot;:
    # websocket.enableTrace(True)
    ws = websocket.WebSocketApp(
        &quot;wss://api.huobi.pro/ws&quot;,
        on_open=on_open,
        on_message=on_message,
        on_error=on_error,
        on_close=on_close
    )
    ws.run_forever()