diff --git a/bfxapi/types/dataclasses.py b/bfxapi/types/dataclasses.py index 4c375e5..8b0b69f 100644 --- a/bfxapi/types/dataclasses.py +++ b/bfxapi/types/dataclasses.py @@ -129,7 +129,7 @@ class Liquidation(_Type): base_price: float is_match: int is_market_sold: int - price_acquired: float + liquidation_price: float @dataclass class Leaderboard(_Type): diff --git a/bfxapi/types/serializers.py b/bfxapi/types/serializers.py index f7838bf..d1f2ab9 100644 --- a/bfxapi/types/serializers.py +++ b/bfxapi/types/serializers.py @@ -230,7 +230,7 @@ Liquidation = generate_labeler_serializer( "is_match", "is_market_sold", "_PLACEHOLDER", - "price_acquired" + "liquidation_price" ] ) diff --git a/bfxapi/websocket/enums.py b/bfxapi/websocket/enums.py index 227bf69..8fe6028 100644 --- a/bfxapi/websocket/enums.py +++ b/bfxapi/websocket/enums.py @@ -1,5 +1,5 @@ #pylint: disable-next=wildcard-import,unused-wildcard-import -from ..enums import * +from bfxapi.enums import * class Channel(str, Enum): TICKER = "ticker" diff --git a/bfxapi/websocket/handlers/auth_events_handler.py b/bfxapi/websocket/handlers/auth_events_handler.py index 8c5cab3..f411e7b 100644 --- a/bfxapi/websocket/handlers/auth_events_handler.py +++ b/bfxapi/websocket/handlers/auth_events_handler.py @@ -1,5 +1,5 @@ from typing import TYPE_CHECKING, \ - Union, Dict, Tuple, Any + Dict, Tuple, Any from bfxapi.types import serializers @@ -71,14 +71,16 @@ class AuthEventsHandler: break def __notification(self, stream: Any) -> None: - _Types = Union[None, "Order", "FundingOffer"] + event: str = "notification" - event, serializer = "notification", _Notification[_Types](serializer=None) + serializer: _Notification = _Notification[None](serializer=None) if stream[1] == "on-req" or stream[1] == "ou-req" or stream[1] == "oc-req": - event, serializer = f"{stream[1]}-notification", _Notification[_Types](serializer=serializers.Order) + event, serializer = f"{stream[1]}-notification", \ + _Notification["Order"](serializer=serializers.Order) if stream[1] == "fon-req" or stream[1] == "foc-req": - event, serializer = f"{stream[1]}-notification", _Notification[_Types](serializer=serializers.FundingOffer) + event, serializer = f"{stream[1]}-notification", \ + _Notification["FundingOffer"](serializer=serializers.FundingOffer) self.__event_emitter.emit(event, serializer.parse(*stream)) diff --git a/bfxapi/websocket/handlers/public_channels_handler.py b/bfxapi/websocket/handlers/public_channels_handler.py index 456ecd8..6a4a919 100644 --- a/bfxapi/websocket/handlers/public_channels_handler.py +++ b/bfxapi/websocket/handlers/public_channels_handler.py @@ -24,7 +24,8 @@ class PublicChannelsHandler: "t_ticker_update", "f_ticker_update", "t_trade_execution", "t_trade_execution_update", "f_trade_execution", "f_trade_execution_update", "t_book_update", "f_book_update", "t_raw_book_update", - "f_raw_book_update", "candles_update", "derivatives_status_update" + "f_raw_book_update", "candles_update", "derivatives_status_update", + "liquidation_feed_update" ] def __init__(self, @@ -97,7 +98,7 @@ class PublicChannelsHandler: for sub_stream in stream[0] ]) def __book_channel_handler(self, subscription: "Book", stream: List[Any]) -> None: - t_or_f = subscription["symbol"][0] + symbol = subscription["symbol"] is_raw_book = subscription["prec"] == "R0" @@ -106,17 +107,17 @@ class PublicChannelsHandler: or serializers.TradingPairBook, "f": is_raw_book and serializers.FundingCurrencyRawBook \ or serializers.FundingCurrencyBook - }[t_or_f] + }[symbol[0]] if all(isinstance(sub_stream, list) for sub_stream in stream[0]): - event = t_or_f + "_" + \ + event = symbol[0] + "_" + \ (is_raw_book and "raw_book" or "book") + "_snapshot" return self.__emit(event, subscription, \ [ serializer.parse(*sub_stream) \ for sub_stream in stream[0] ]) - event = t_or_f + "_" + \ + event = symbol[0] + "_" + \ (is_raw_book and "raw_book" or "book") + "_update" return self.__emit(event, subscription, \ @@ -135,3 +136,7 @@ class PublicChannelsHandler: if subscription["key"].startswith("deriv:"): return self.__emit("derivatives_status_update", subscription, \ serializers.DerivativesStatus.parse(*stream[0])) + + if subscription["key"].startswith("liq:"): + return self.__emit("liquidation_feed_update", subscription, \ + serializers.Liquidation.parse(*stream[0][0]))