def _process_data(self):
self.conn = create_connection(self.addr, timeout=4)
for pair in self.pairs:
payload = [{'event': 'addChannel',
'channel': 'ok_sub_spotusd_%s_ticker' % pair},
{'event': 'addChannel',
'channel': 'ok_sub_spotusd_%s_depth_60' % pair},
{'event': 'addChannel',
'channel': 'ok_sub_spotusd_%s_trades' % pair},
{'event': 'addChannel',
'channel': 'ok_sub_spotusd_%s_kline_1min' % pair}]
log.debug(payload)
self.conn.send(json.dumps(payload))
while self.running:
try:
data = json.loads(self.conn.recv())
except (WebSocketTimeoutException, ConnectionResetError):
self._controller_q.put('restart')
if 'data' in data:
pair = ''.join(data['channel'].split('spot')[1].split('_')[:2]).upper()
self.data_q.put((data['channel'], pair, data['data'],
time.time()))
else:
log.debug(data)
self.conn = None
评论列表
文章目录