nord vpnnord vpn
Ad

Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
910 B
2
Indexable
Never
import requests
import websocket
import json


symbol_container = []
spot_ws = f'wss://fstream.binance.com/stream?streams=btcusdt@bookTicker/'
print(spot_ws)
def on_message(ws,message):
    json_msg = json.loads(message)
    symbol = json_msg['data']['s']
    bid = json_msg['data']['b']
    symbol_container.append(symbol)
    #print(json_msg)

def on_ping(ws, message):
    print("### on_ping ###")
    print("ping message: %s", message)

def on_pong(ws, message):
    print("### on_pong ###")
    print("pong message: %s", message)

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

def on_close(ws):
    print('connection end')
ws = websocket.WebSocketApp(spot_ws,
	on_message=on_message,
    on_ping=on_ping,
    on_pong=on_pong,
	on_close=on_close,
	on_error=on_error)
ws.run_forever(ping_interval=2, ping_timeout=1)

symbol_container = set(symbol_container)
print(symbol_container)
print(len(symbol_container))

nord vpnnord vpn
Ad