-1

I'm trying to create a trading bot for binance. this lines of code to read messages from binance stream through websocket client is not responding at all and no error appeared

import websocket


SOCKET = "wss://stream.binance.com:9443/ws/ethusdt@kline_1m"

def on_open(ws):
    print('opened connection')

def on_close(ws):
    print('closed connection')

def on_message(ws):
    print('receive message')
    
ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close, on_message=on_message)
ws.run_forever()
furas
  • 134,197
  • 12
  • 106
  • 148

1 Answers1

0

You forgot second argument in def on_message(ws, message): and this may generate error - but websocket catch all errors and hide them (to work all time even if there are some problems)

import websocket

SOCKET = "wss://stream.binance.com:9443/ws/ethusdt@kline_1m"

def on_open(ws):
    print('opened connection', ws)

def on_close(ws):
    print('closed connection', ws)

def on_message(ws, message):
    print('receive message', ws)
    print(message)
    
ws = websocket.WebSocketApp(SOCKET, on_open=on_open, on_close=on_close, on_message=on_message)
ws.run_forever()
furas
  • 134,197
  • 12
  • 106
  • 148