mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 22:34:21 +01:00
Add pause/resume logic in class BfxWebSocketClient.
This commit is contained in:
@@ -78,7 +78,9 @@ class BfxWebSocketClient(Connection):
|
||||
super().__init__(host)
|
||||
|
||||
self.__credentials, self.__timeout, self.__logger = \
|
||||
credentials, timeout, logger
|
||||
credentials, \
|
||||
timeout, \
|
||||
logger
|
||||
|
||||
self.__buckets: Dict[BfxWebSocketBucket, Optional[Task]] = { }
|
||||
|
||||
@@ -99,15 +101,16 @@ class BfxWebSocketClient(Connection):
|
||||
stack_trace = traceback.format_exception( \
|
||||
type(exception), exception, exception.__traceback__)
|
||||
|
||||
self.__logger.critical( \
|
||||
header + "\n" + str().join(stack_trace)[:-1])
|
||||
self.__logger.critical(header + "\n" + \
|
||||
str().join(stack_trace)[:-1])
|
||||
|
||||
@property
|
||||
def inputs(self) -> BfxWebSocketInputs:
|
||||
return self.__inputs
|
||||
|
||||
def run(self) -> None:
|
||||
return asyncio.run(self.start())
|
||||
return asyncio.get_event_loop() \
|
||||
.run_until_complete(self.start())
|
||||
|
||||
#pylint: disable-next=too-many-branches
|
||||
async def start(self) -> None:
|
||||
|
||||
@@ -9,9 +9,9 @@ from pyee.asyncio import AsyncIOEventEmitter
|
||||
from bfxapi.websocket.exceptions import UnknownEventError
|
||||
|
||||
_ONCE_PER_CONNECTION = [
|
||||
"open", "authenticated", "disconnected",
|
||||
"order_snapshot", "position_snapshot", "funding_offer_snapshot",
|
||||
"funding_credit_snapshot", "funding_loan_snapshot", "wallet_snapshot"
|
||||
"open", "authenticated", "order_snapshot",
|
||||
"position_snapshot", "funding_offer_snapshot", "funding_credit_snapshot",
|
||||
"funding_loan_snapshot", "wallet_snapshot"
|
||||
]
|
||||
|
||||
_ONCE_PER_SUBSCRIPTION = [
|
||||
@@ -21,25 +21,26 @@ _ONCE_PER_SUBSCRIPTION = [
|
||||
]
|
||||
|
||||
_COMMON = [
|
||||
"error", "wss-error", "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", "liquidation_feed_update",
|
||||
"order_new", "order_update", "order_cancel",
|
||||
"position_new", "position_update", "position_close",
|
||||
"funding_offer_new", "funding_offer_update", "funding_offer_cancel",
|
||||
"funding_credit_new", "funding_credit_update", "funding_credit_close",
|
||||
"funding_loan_new", "funding_loan_update", "funding_loan_close",
|
||||
"trade_execution", "trade_execution_update", "wallet_update",
|
||||
"notification", "on-req-notification", "ou-req-notification",
|
||||
"oc-req-notification", "fon-req-notification", "foc-req-notification"
|
||||
"error", "wss-error", "disconnected",
|
||||
"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",
|
||||
"liquidation_feed_update", "order_new", "order_update",
|
||||
"order_cancel", "position_new", "position_update",
|
||||
"position_close", "funding_offer_new", "funding_offer_update",
|
||||
"funding_offer_cancel", "funding_credit_new", "funding_credit_update",
|
||||
"funding_credit_close", "funding_loan_new", "funding_loan_update",
|
||||
"funding_loan_close", "trade_execution", "trade_execution_update",
|
||||
"wallet_update", "notification", "on-req-notification",
|
||||
"ou-req-notification", "oc-req-notification", "fon-req-notification",
|
||||
"foc-req-notification"
|
||||
]
|
||||
|
||||
class BfxEventEmitter(AsyncIOEventEmitter):
|
||||
_EVENTS = _ONCE_PER_CONNECTION + \
|
||||
_ONCE_PER_SUBSCRIPTION + \
|
||||
_COMMON
|
||||
_ONCE_PER_SUBSCRIPTION + \
|
||||
_COMMON
|
||||
|
||||
def __init__(self, loop: Optional[AbstractEventLoop] = None) -> None:
|
||||
super().__init__(loop)
|
||||
|
||||
Reference in New Issue
Block a user