vnpy/beta/api/coincheck/test3.py

33 lines
619 B
Python
Raw Normal View History

# encoding: utf-8
2018-05-07 17:25:06 +00:00
from __future__ import print_function
from __future__ import absolute_import
from .vncoincheck import *
import socket
import json
import websocket
from websocket import create_connection
ws = None
def open():
global ws
2018-05-07 17:25:06 +00:00
print("open")
ws.send( json.dumps({"type": "subscribe", "channel": "btc_jpy-trades"}))
def testWebsocket():
global ws
while 1:
ws = create_connection("wss://ws-api.coincheck.com/", on_open=open)
if ws.connected:
2018-05-07 17:25:06 +00:00
print(ws.recv())
sleep(5)
# 阻塞
input()
if __name__ == '__main__':
testWebsocket()