mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
Rename AuthenticatedChannelsHandler to AuthenticatedEventsHandler (and bfxapi.websocket.handlers.authenticated_channels_handler to authenticated_events_handler).
This commit is contained in:
@@ -11,7 +11,7 @@ from pyee.asyncio import AsyncIOEventEmitter
|
|||||||
from .bfx_websocket_bucket import _HEARTBEAT, F, _require_websocket_connection, BfxWebsocketBucket
|
from .bfx_websocket_bucket import _HEARTBEAT, F, _require_websocket_connection, BfxWebsocketBucket
|
||||||
|
|
||||||
from .bfx_websocket_inputs import BfxWebsocketInputs
|
from .bfx_websocket_inputs import BfxWebsocketInputs
|
||||||
from ..handlers import PublicChannelsHandler, AuthenticatedChannelsHandler
|
from ..handlers import PublicChannelsHandler, AuthenticatedEventsHandler
|
||||||
from ..exceptions import WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, \
|
from ..exceptions import WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, \
|
||||||
ZeroConnectionsError, ReconnectionTimeoutError, OutdatedClientVersion
|
ZeroConnectionsError, ReconnectionTimeoutError, OutdatedClientVersion
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class BfxWebsocketClient:
|
|||||||
EVENTS = [
|
EVENTS = [
|
||||||
*ONCE_EVENTS, "subscribed", "wss-error",
|
*ONCE_EVENTS, "subscribed", "wss-error",
|
||||||
*PublicChannelsHandler.EVENTS,
|
*PublicChannelsHandler.EVENTS,
|
||||||
*AuthenticatedChannelsHandler.EVENTS
|
*AuthenticatedEventsHandler.EVENTS
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, host, credentials, *, wss_timeout = 60 * 15, log_filename = None, log_level = "INFO"):
|
def __init__(self, host, credentials, *, wss_timeout = 60 * 15, log_filename = None, log_level = "INFO"):
|
||||||
@@ -70,7 +70,7 @@ class BfxWebsocketClient:
|
|||||||
|
|
||||||
self.event_emitter = AsyncIOEventEmitter()
|
self.event_emitter = AsyncIOEventEmitter()
|
||||||
|
|
||||||
self.handler = AuthenticatedChannelsHandler(event_emitter=self.event_emitter)
|
self.handler = AuthenticatedEventsHandler(event_emitter=self.event_emitter)
|
||||||
|
|
||||||
self.inputs = BfxWebsocketInputs(handle_websocket_input=self.__handle_websocket_input)
|
self.inputs = BfxWebsocketInputs(handle_websocket_input=self.__handle_websocket_input)
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
from .public_channels_handler import PublicChannelsHandler
|
from .public_channels_handler import PublicChannelsHandler
|
||||||
from .authenticated_channels_handler import AuthenticatedChannelsHandler
|
from .authenticated_events_handler import AuthenticatedEventsHandler
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ from .. serializers import _Notification
|
|||||||
|
|
||||||
from .. exceptions import HandlerNotFound
|
from .. exceptions import HandlerNotFound
|
||||||
|
|
||||||
class AuthenticatedChannelsHandler:
|
class AuthenticatedEventsHandler:
|
||||||
__abbreviations = {
|
__abbreviations = {
|
||||||
"os": "order_snapshot", "on": "order_new", "ou": "order_update",
|
"os": "order_snapshot", "on": "order_new", "ou": "order_update",
|
||||||
"oc": "order_cancel", "ps": "position_snapshot", "pn": "position_new",
|
"oc": "order_cancel", "ps": "position_snapshot", "pn": "position_new",
|
||||||
@@ -43,9 +43,9 @@ class AuthenticatedChannelsHandler:
|
|||||||
if abbrevation == "n":
|
if abbrevation == "n":
|
||||||
return self.__notification(stream)
|
return self.__notification(stream)
|
||||||
|
|
||||||
for abbrevations, serializer in AuthenticatedChannelsHandler.__serializers.items():
|
for abbrevations, serializer in AuthenticatedEventsHandler.__serializers.items():
|
||||||
if abbrevation in abbrevations:
|
if abbrevation in abbrevations:
|
||||||
event = AuthenticatedChannelsHandler.__abbreviations[abbrevation]
|
event = AuthenticatedEventsHandler.__abbreviations[abbrevation]
|
||||||
|
|
||||||
if all(isinstance(substream, list) for substream in stream):
|
if all(isinstance(substream, list) for substream in stream):
|
||||||
return self.event_emitter.emit(event, [ serializer.parse(*substream) for substream in stream ])
|
return self.event_emitter.emit(event, [ serializer.parse(*substream) for substream in stream ])
|
||||||
Reference in New Issue
Block a user