This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_connection(): | |
import websocket | |
import json | |
# What to do when opening a new connection | |
def on_open(self): | |
# Prepare sending message | |
sub = json.dumps({ | |
"op": "subscribe", | |
"channel": "trades", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import websocket | |
import json | |
quote = "ethusdt" | |
interval = "15m" | |
# socket = f"wss://stream.binance.com:9443/ws/{quote}@kline_{interval}" | |
socket = f"wss://stream.binance.com:9443/ws/{quote}@trade" | |
# What to do when receiving a message from the server | |
def on_message(self, message): |