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 TradingPairBook
class OrderBook(object):
class OrderBook:
def __init__(self, symbols: List[str]):
self.__order_book = {
symbol: {
symbol: {
"bids": OrderedDict(), "asks": OrderedDict()
} for symbol in symbols
}
def update(self, symbol: str, data: TradingPairBook) -> None:
price, count, amount = data.price, data.count, data.amount
kind = (amount > 0) and "bids" or "asks"
kind = "bids" if amount > 0 else "asks"
if count > 0:
self.__order_book[symbol][kind][price] = {
self.__order_book[symbol][kind][price] = {
"price": price,
"count": count,
"amount": amount
@@ -62,4 +62,4 @@ def on_t_book_snapshot(subscription: subscriptions.Book, snapshot: List[TradingP
def on_t_book_update(subscription: subscriptions.Book, data: TradingPairBook):
order_book.update(subscription["symbol"], data)
bfx.wss.run()
bfx.wss.run()