mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
Rename bfxapi.websocket.handlers.authenticated_events_handler to auth_events_handler (AuthenticatedEventsHandler -> AuthEventsHandler).
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, AuthenticatedEventsHandler
|
from ..handlers import PublicChannelsHandler, AuthEventsHandler
|
||||||
from ..exceptions import WebSocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, \
|
from ..exceptions import WebSocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported, \
|
||||||
ZeroConnectionsError, ReconnectionTimeoutError, OutdatedClientVersion
|
ZeroConnectionsError, ReconnectionTimeoutError, OutdatedClientVersion
|
||||||
|
|
||||||
@@ -57,14 +57,14 @@ class BfxWebSocketClient:
|
|||||||
|
|
||||||
ONCE_EVENTS = [
|
ONCE_EVENTS = [
|
||||||
"open", "authenticated", "disconnection",
|
"open", "authenticated", "disconnection",
|
||||||
*AuthenticatedEventsHandler.ONCE_EVENTS
|
*AuthEventsHandler.ONCE_EVENTS
|
||||||
]
|
]
|
||||||
|
|
||||||
EVENTS = [
|
EVENTS = [
|
||||||
"subscribed", "wss-error",
|
"subscribed", "wss-error",
|
||||||
*ONCE_EVENTS,
|
*ONCE_EVENTS,
|
||||||
*PublicChannelsHandler.EVENTS,
|
*PublicChannelsHandler.EVENTS,
|
||||||
*AuthenticatedEventsHandler.ON_EVENTS
|
*AuthEventsHandler.ON_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"):
|
||||||
@@ -76,7 +76,7 @@ class BfxWebSocketClient:
|
|||||||
|
|
||||||
self.event_emitter = AsyncIOEventEmitter()
|
self.event_emitter = AsyncIOEventEmitter()
|
||||||
|
|
||||||
self.handler = AuthenticatedEventsHandler(event_emitter=self.event_emitter)
|
self.handler = AuthEventsHandler(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_events_handler import AuthenticatedEventsHandler
|
from .auth_events_handler import AuthEventsHandler
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from ...types import serializers
|
|||||||
|
|
||||||
from ...types.serializers import _Notification
|
from ...types.serializers import _Notification
|
||||||
|
|
||||||
class AuthenticatedEventsHandler:
|
class AuthEventsHandler:
|
||||||
__once_abbreviations = {
|
__once_abbreviations = {
|
||||||
"os": "order_snapshot", "ps": "position_snapshot", "fos": "funding_offer_snapshot",
|
"os": "order_snapshot", "ps": "position_snapshot", "fos": "funding_offer_snapshot",
|
||||||
"fcs": "funding_credit_snapshot", "fls": "funding_loan_snapshot", "ws": "wallet_snapshot"
|
"fcs": "funding_credit_snapshot", "fls": "funding_loan_snapshot", "ws": "wallet_snapshot"
|
||||||
@@ -49,9 +49,9 @@ class AuthenticatedEventsHandler:
|
|||||||
if abbrevation == "n":
|
if abbrevation == "n":
|
||||||
return self.__notification(stream)
|
return self.__notification(stream)
|
||||||
|
|
||||||
for abbrevations, serializer in AuthenticatedEventsHandler.__serializers.items():
|
for abbrevations, serializer in AuthEventsHandler.__serializers.items():
|
||||||
if abbrevation in abbrevations:
|
if abbrevation in abbrevations:
|
||||||
event = AuthenticatedEventsHandler.__abbreviations[abbrevation]
|
event = AuthEventsHandler.__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