Created
May 29, 2023 10:38
-
-
Save MtkN1/5ccbf2cdd9ff7a887e5d0c1bcecd890d to your computer and use it in GitHub Desktop.
Sample of connecting to Socket.IO v2 WebSocket in bitbank with pybotters
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
""" | |
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