From 387ce008a628cbbc86440f88130db168343d345a Mon Sep 17 00:00:00 2001 From: Jacob Plaster Date: Fri, 16 Nov 2018 14:40:22 +0000 Subject: [PATCH] examples: adds wallet_balance example --- bfxapi/examples/wallet_balance.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 bfxapi/examples/wallet_balance.py diff --git a/bfxapi/examples/wallet_balance.py b/bfxapi/examples/wallet_balance.py new file mode 100644 index 0000000..d5ced1e --- /dev/null +++ b/bfxapi/examples/wallet_balance.py @@ -0,0 +1,28 @@ +import os +import sys +sys.path.append('../') + +from bfxapi.websockets.LiveWebsocket import LiveBfxWebsocket + +API_KEY=os.getenv("BFX_KEY") +API_SECRET=os.getenv("BFX_SECRET") + +ws = LiveBfxWebsocket( + API_KEY=API_KEY, + API_SECRET=API_SECRET, + logLevel='INFO' +) + +@ws.on('wallet_snapshot') +def log_snapshot(data): + print ("Opening balance: {}".format(data)) + +@ws.on('wallet_update') +def log_update(data): + print ("Balance updates: {}".format(data)) + +ws.on('error') +def log_error(msg): + print ("Error: {}".format(msg)) + +ws.run()