Apply pylint's linting rules to examples/websocket/public/*.py.

This commit is contained in:
Davide Casale
2023-03-08 21:36:25 +01:00
parent 834a664034
commit d04ebb96d5
5 changed files with 23 additions and 23 deletions

View File

@@ -10,21 +10,21 @@ from bfxapi.websocket import subscriptions
from bfxapi.websocket.enums import Channel, Error
from bfxapi.websocket.types import TradingPairRawBook
class RawOrderBook(object):
class RawOrderBook:
def __init__(self, symbols: List[str]):
self.__raw_order_book = {
symbol: {
symbol: {
"bids": OrderedDict(), "asks": OrderedDict()
} for symbol in symbols
}
def update(self, symbol: str, data: TradingPairRawBook) -> None:
order_id, price, amount = data.order_id, data.price, data.amount
kind = (amount > 0) and "bids" or "asks"
kind = "bids" if amount > 0 else "asks"
if price > 0:
self.__raw_order_book[symbol][kind][order_id] = {
self.__raw_order_book[symbol][kind][order_id] = {
"order_id": order_id,
"price": price,
"amount": amount
@@ -62,4 +62,4 @@ def on_t_raw_book_snapshot(subscription: subscriptions.Book, snapshot: List[Trad
def on_t_raw_book_update(subscription: subscriptions.Book, data: TradingPairRawBook):
raw_order_book.update(subscription["symbol"], data)
bfx.wss.run()
bfx.wss.run()