Created
April 26, 2018 12:51
-
-
Save nagadomi/670408b58ef6b1caab80ee160eb9e73d to your computer and use it in GitHub Desktop.
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
import websocket | |
import json | |
from pprint import pprint | |
def on_message(ws, message): | |
message = json.loads(message) | |
pprint(message) | |
def on_error(ws, error): | |
print(error) | |
def on_close(ws): | |
print("### closed ###") | |
def on_open(ws): | |
ws.send(json.dumps({"method": "subscribe", "params": {"channel": "lightning_executions_FX_BTC_JPY"}})) | |
ws.send(json.dumps({"method": "subscribe", "params": {"channel": "lightning_ticker_FX_BTC_JPY"}})) | |
if __name__ == "__main__": | |
#websocket.enableTrace(True) | |
ws = websocket.WebSocketApp("wss://ws.lightstream.bitflyer.com/json-rpc", | |
on_message = on_message, | |
on_error = on_error, | |
on_close = on_close) | |
ws.on_open = on_open | |
ws.run_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment