Files
bitfinex-api-py/bfxapi/examples/ws/start_stop_connection.py
2020-04-16 10:45:20 +01:00

22 lines
398 B
Python

import os
import sys
sys.path.append('../../../')
from bfxapi import Client
bfx = Client(
logLevel='DEBUG',
)
@bfx.ws.on('order_book_snapshot')
async def log_snapshot(data):
print ("Snapshot: {}".format(data))
# stop the websocket once a snapshot is received
await bfx.ws.stop()
async def start():
await bfx.ws.subscribe('book', 'tBTCUSD')
bfx.ws.on('connected', start)
bfx.ws.run()