Created
December 6, 2022 02:59
-
-
Save MtkN1/4a9e4dbd5c3c1efceb98b81c4d1fc418 to your computer and use it in GitHub Desktop.
みんかぶ WebSocket Sample
This file contains hidden or 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 socketio | |
| sio = socketio.Client() | |
| usdjpy = {} | |
| @sio.event | |
| def connect(): | |
| sio.emit("subscribe", "USDJPY") | |
| @sio.event | |
| def USDJPY(data): | |
| usdjpy.update(data) | |
| print(usdjpy) | |
| """stdout | |
| { | |
| 'pair': 'USDJPY', | |
| 'time': 1670295120000, | |
| 'range': '1m', | |
| 'open_bid': 136.96, | |
| 'open_ask': 136.968, | |
| 'open_time': 1670295123032, | |
| 'high_bid': 136.963, | |
| 'high_ask': 136.97, | |
| 'low_bid': 136.958, | |
| 'low_ask': 136.963, | |
| 'close_bid': 136.963, | |
| 'close_ask': 136.97, | |
| 'close_time': 1670295124432 | |
| } | |
| """ | |
| if __name__ == "__main__": | |
| try: | |
| sio.connect('wss://fx.minkabu.jp', transports=['websocket']) # バックグラウンドで接続される | |
| sio.wait() # プログラムの終了をブロック | |
| except KeyboardInterrupt: | |
| pass |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements
Web
https://fx.minkabu.jp/pair/USDJPY