mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-22 00:04:20 +01:00
Implement bfxapi/notifications.py in websocket subpackage.
This commit is contained in:
@@ -146,7 +146,13 @@ class AuthenticatedChannelsHandler(object):
|
||||
("bu",): serializers.BalanceInfo
|
||||
}
|
||||
|
||||
EVENTS = [ "notification", *list(__abbreviations.values()) ]
|
||||
EVENTS = [
|
||||
"notification",
|
||||
"on-req-notification", "ou-req-notification", "oc-req-notification",
|
||||
"oc_multi-notification",
|
||||
"fon-req-notification", "foc-req-notification",
|
||||
*list(__abbreviations.values())
|
||||
]
|
||||
|
||||
def __init__(self, event_emitter, strict = False):
|
||||
self.event_emitter, self.strict = event_emitter, strict
|
||||
@@ -168,4 +174,13 @@ class AuthenticatedChannelsHandler(object):
|
||||
raise BfxWebsocketException(f"Event of type <{type}> not found in self.__handlers.")
|
||||
|
||||
def __notification(self, stream):
|
||||
return self.event_emitter.emit("notification", serializers.Notification.parse(*stream))
|
||||
if stream[1] == "on-req" or stream[1] == "ou-req" or stream[1] == "oc-req":
|
||||
return self.event_emitter.emit(f"{stream[1]}-notification", serializers._Notification(serializer=serializers.Order).parse(*stream))
|
||||
|
||||
if stream[1] == "oc_multi-req":
|
||||
return self.event_emitter.emit(f"{stream[1]}-notification", serializers._Notification(serializer=serializers.Order, iterate=True).parse(*stream))
|
||||
|
||||
if stream[1] == "fon-req" or stream[1] == "foc-req":
|
||||
return self.event_emitter.emit(f"{stream[1]}-notification", serializers._Notification(serializer=serializers.FundingOffer).parse(*stream))
|
||||
|
||||
return self.event_emitter.emit("notification", serializers._Notification(serializer=None).parse(*stream))
|
||||
@@ -2,6 +2,8 @@ from . import typings
|
||||
|
||||
from .. labeler import _Serializer
|
||||
|
||||
from .. notification import _Notification
|
||||
|
||||
#region Serializers definition for Websocket Public Channels
|
||||
|
||||
TradingPairTicker = _Serializer[typings.TradingPairTicker]("TradingPairTicker", labels=[
|
||||
@@ -292,19 +294,4 @@ BalanceInfo = _Serializer[typings.BalanceInfo]("BalanceInfo", labels=[
|
||||
"AUM_NET",
|
||||
])
|
||||
|
||||
#endregion
|
||||
|
||||
#region Serializers definition for Notifications channel
|
||||
|
||||
Notification = _Serializer[typings.Notification]("Notification", labels=[
|
||||
"MTS",
|
||||
"TYPE",
|
||||
"MESSAGE_ID",
|
||||
"_PLACEHOLDER",
|
||||
"NOTIFY_INFO",
|
||||
"CODE",
|
||||
"STATUS",
|
||||
"TEXT"
|
||||
])
|
||||
|
||||
#endregion
|
||||
@@ -1,5 +1,7 @@
|
||||
from typing import Type, Tuple, List, Dict, TypedDict, Union, Optional, Any
|
||||
|
||||
from .. notification import Notification
|
||||
|
||||
JSON = Union[Dict[str, "JSON"], List["JSON"], bool, int, float, str, Type[None]]
|
||||
|
||||
#region Type hinting for subscription objects
|
||||
@@ -272,17 +274,4 @@ class BalanceInfo(TypedDict):
|
||||
AUM: float
|
||||
AUM_NET: float
|
||||
|
||||
#endregion
|
||||
|
||||
#region Type hinting for Notifications channel
|
||||
|
||||
class Notification(TypedDict):
|
||||
MTS: int
|
||||
TYPE: str
|
||||
MESSAGE_ID: int
|
||||
NOTIFY_INFO: JSON
|
||||
CODE: int
|
||||
STATUS: str
|
||||
TEXT: str
|
||||
|
||||
#endregion
|
||||
Reference in New Issue
Block a user