mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
Apply pylint's linting rules to examples/websocket/public/*.py.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user