Skip to content

Instantly share code, notes, and snippets.

View atitawat-pol's full-sized avatar

hken atitawat-pol

  • Thailand
View GitHub Profile
@atitawat-pol
atitawat-pol / simple_websocket.py
Created September 11, 2022 14:26
Real-Time Cryptocurrencies Prices from FTX/Binance using Python
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",
@atitawat-pol
atitawat-pol / simple_websocket_binance.py
Created September 11, 2022 14:37
Binance simeple websocket Python
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):