mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 23:04:21 +01:00
Rewrite, edit and organize examples/websocket demos.
This commit is contained in:
30
examples/websocket/authenticated/wallets.py
Normal file
30
examples/websocket/authenticated/wallets.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# python -c "import examples.websocket.authenticated.wallets"
|
||||
|
||||
import os
|
||||
|
||||
from bfxapi import Client
|
||||
from bfxapi.enums import Error
|
||||
from bfxapi.websocket.types import List, Wallet
|
||||
|
||||
bfx = Client(
|
||||
API_KEY=os.getenv("BFX_API_KEY"),
|
||||
API_SECRET=os.getenv("BFX_API_SECRET"),
|
||||
filter=["wallet"]
|
||||
)
|
||||
|
||||
@bfx.wss.on("wss-error")
|
||||
def on_wss_error(code: Error, msg: str):
|
||||
print(code, msg)
|
||||
|
||||
@bfx.wss.on("wallet_snapshot")
|
||||
def on_wallet_snapshot(wallets: List[Wallet]):
|
||||
for wallet in wallets:
|
||||
print(f"Wallet: {wallet.wallet_type} | {wallet.currency}")
|
||||
print(f"Available balance: {wallet.available_balance}")
|
||||
print(f"Wallet trade details: {wallet.trade_details}")
|
||||
|
||||
@bfx.wss.on("wallet_update")
|
||||
def on_wallet_update(wallet: Wallet):
|
||||
print(f"Wallet update: {wallet}")
|
||||
|
||||
bfx.wss.run()
|
||||
Reference in New Issue
Block a user