Skip to content

Instantly share code, notes, and snippets.

@MtkN1
Created May 29, 2023 10:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MtkN1/5ccbf2cdd9ff7a887e5d0c1bcecd890d to your computer and use it in GitHub Desktop.
Save MtkN1/5ccbf2cdd9ff7a887e5d0c1bcecd890d to your computer and use it in GitHub Desktop.
Sample of connecting to Socket.IO v2 WebSocket in bitbank with pybotters
"""
Sample of connecting to Socket.IO v2 WebSocket in bitbank with pybotters
"""
import asyncio
import pybotters
async def main():
async with pybotters.Client() as client:
store = pybotters.bitbankDataStore()
await client.ws_connect(
"wss://stream.bitbank.cc/socket.io/?EIO=2&transport=websocket",
send_str=[
'42["join-room","depth_diff_btc_jpy"]',
'42["join-room","depth_whole_btc_jpy"]',
],
hdlr_str=store.onmessage,
)
while True:
depth = store.depth.sorted()
print(*({k: v[:1]} for k, v in depth.items()), sep="\n", end="\n\n")
await asyncio.sleep(1.0)
if __name__ == "__main__":
try:
asyncio.run(main())
except KeyboardInterrupt:
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment