Rewrite all websocket examples according to v3.0.0b3's changes.

This commit is contained in:
Davide Casale
2023-10-26 17:59:44 +02:00
parent 1ec6c49428
commit 1accf92c57
7 changed files with 111 additions and 84 deletions

View File

@@ -1,12 +1,11 @@
# python -c "import examples.websocket.public.ticker"
from bfxapi import Client, PUB_WSS_HOST
from bfxapi import Client
from bfxapi.types import TradingPairTicker
from bfxapi.websocket.subscriptions import Ticker
from bfxapi.websocket.enums import Channel
bfx = Client(wss_host=PUB_WSS_HOST)
bfx = Client()
@bfx.wss.on("t_ticker_update")
def on_t_ticker_update(subscription: Ticker, data: TradingPairTicker):
@@ -14,8 +13,10 @@ def on_t_ticker_update(subscription: Ticker, data: TradingPairTicker):
print(f"Data: {data}")
@bfx.wss.on("open")
async def on_open():
await bfx.wss.subscribe(Channel.TICKER, symbol="tBTCUSD")
await bfx.wss.subscribe("ticker", symbol="tBTCUSD")
bfx.wss.run()