MCPcopy Create free account
hub / github.com/sammchardy/python-binance / websocket_example

Function websocket_example

examples/verbose_example.py:49–69  ·  view source on GitHub ↗

Example 3: WebSocket with verbose mode

()

Source from the content-addressed store, hash-verified

47
48
49async def websocket_example():
50 """Example 3: WebSocket with verbose mode"""
51 print("\n" + "=" * 80)
52 print("Example 3: WebSocket Streams (verbose=True)")
53 print("=" * 80)
54
55 client = await AsyncClient.create()
56
57 # Create socket manager with verbose mode
58 bm = BinanceSocketManager(client, verbose=True)
59
60 # Start trade socket - will show detailed WebSocket logs
61 ts = bm.trade_socket("ETHUSDT")
62
63 print("Receiving 3 trade messages...\n")
64 async with ts as tscm:
65 for i in range(3):
66 msg = await tscm.recv()
67 print(f"Trade {i + 1}: Price={msg['p']}, Qty={msg['q']}")
68
69 await client.close_connection()
70
71
72async def combined_example():

Callers 1

mainFunction · 0.85

Calls 5

trade_socketMethod · 0.95
createMethod · 0.80
recvMethod · 0.45
close_connectionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…