diff --git a/examples/websocket/create_order.py b/examples/websocket/create_order.py index b3146e9..7a6f645 100644 --- a/examples/websocket/create_order.py +++ b/examples/websocket/create_order.py @@ -4,7 +4,7 @@ import os from bfxapi.client import Client, Constants from bfxapi.websocket.enums import Error, OrderType -from bfxapi.websocket.typings import Notification, Order +from bfxapi.websocket.types import Notification, Order bfx = Client( WSS_HOST=Constants.WSS_HOST, @@ -30,7 +30,7 @@ async def on_authenticated(event): print("The order has been sent.") @bfx.wss.on("on-req-notification") -async def on_notification(notification: Notification): +async def on_notification(notification: Notification[Order]): print(f"Notification: {notification}.") @bfx.wss.on("order_new") diff --git a/examples/websocket/order_book.py b/examples/websocket/order_book.py index 0035cf8..fb583e1 100644 --- a/examples/websocket/order_book.py +++ b/examples/websocket/order_book.py @@ -7,7 +7,7 @@ from typing import List from bfxapi import Client, Constants from bfxapi.websocket.enums import Channels, Error -from bfxapi.websocket.typings import Subscriptions, TradingPairBook +from bfxapi.websocket.types import Subscriptions, TradingPairBook class OrderBook(object): def __init__(self, symbols: List[str]): @@ -18,7 +18,7 @@ class OrderBook(object): } def update(self, symbol: str, data: TradingPairBook) -> None: - price, count, amount = data["PRICE"], data["COUNT"], data["AMOUNT"] + price, count, amount = data.PRICE, data.COUNT, data.AMOUNT kind = (amount > 0) and "bids" or "asks" diff --git a/examples/websocket/raw_order_book.py b/examples/websocket/raw_order_book.py index 6cfc3c1..6819820 100644 --- a/examples/websocket/raw_order_book.py +++ b/examples/websocket/raw_order_book.py @@ -7,7 +7,7 @@ from typing import List from bfxapi import Client, Constants from bfxapi.websocket.enums import Channels, Error -from bfxapi.websocket.typings import Subscriptions, TradingPairRawBook +from bfxapi.websocket.types import Subscriptions, TradingPairRawBook class RawOrderBook(object): def __init__(self, symbols: List[str]): @@ -18,7 +18,7 @@ class RawOrderBook(object): } def update(self, symbol: str, data: TradingPairRawBook) -> None: - order_id, price, amount = data["ORDER_ID"], data["PRICE"], data["AMOUNT"] + order_id, price, amount = data.ORDER_ID, data.PRICE, data.AMOUNT kind = (amount > 0) and "bids" or "asks" diff --git a/examples/websocket/ticker.py b/examples/websocket/ticker.py index 5db8ed1..92e7058 100644 --- a/examples/websocket/ticker.py +++ b/examples/websocket/ticker.py @@ -1,10 +1,8 @@ # python -c "from examples.websocket.ticker import *" -import asyncio - from bfxapi import Client, Constants from bfxapi.websocket.enums import Channels -from bfxapi.websocket.typings import Subscriptions, TradingPairTicker +from bfxapi.websocket.types import Subscriptions, TradingPairTicker bfx = Client(WSS_HOST=Constants.PUB_WSS_HOST)