mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 23:34:21 +01:00
Adds checksum orderbook validation
This commit is contained in:
31
bfxapi/examples/subscribe_orderbook.py
Normal file
31
bfxapi/examples/subscribe_orderbook.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('../')
|
||||
|
||||
from bfxapi import Client
|
||||
|
||||
bfx = Client(
|
||||
logLevel='INFO',
|
||||
# Verifies that the local orderbook is up to date
|
||||
# with the bitfinex servers
|
||||
manageOrderBooks=True
|
||||
)
|
||||
|
||||
@bfx.ws.on('error')
|
||||
def log_error(err):
|
||||
print ("Error: {}".format(err))
|
||||
|
||||
@bfx.ws.on('order_book_update')
|
||||
def log_update(data):
|
||||
print ("Book update: {}".format(data))
|
||||
|
||||
@bfx.ws.on('order_book_snapshot')
|
||||
def log_snapshot(data):
|
||||
print ("Initial book: {}".format(data))
|
||||
|
||||
def start():
|
||||
bfx.ws.subscribe('book', 'tBTCUSD')
|
||||
bfx.ws.subscribe('book', 'tETHUSD')
|
||||
|
||||
bfx.ws.on('connected', start)
|
||||
bfx.ws.run()
|
||||
Reference in New Issue
Block a user