Add derivatives_status_update event in handlers.py. Add DerivativesStatus in serializers.py and typings.py.

This commit is contained in:
Davide Casale
2022-11-16 18:45:25 +01:00
parent 6448fd59b9
commit 41aa49d2bb
3 changed files with 52 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ class PublicChannelsHandler(object):
Channels.TRADES: self.__trades_channel_handler, Channels.TRADES: self.__trades_channel_handler,
Channels.BOOK: self.__book_channel_handler, Channels.BOOK: self.__book_channel_handler,
Channels.CANDLES: self.__candles_channel_handler, Channels.CANDLES: self.__candles_channel_handler,
Channels.STATUS: self.__status_channel_handler
} }
def handle(self, subscription, *stream): def handle(self, subscription, *stream):
@@ -116,6 +117,16 @@ class PublicChannelsHandler(object):
serializers.Candle(*stream[0]) serializers.Candle(*stream[0])
) )
def __status_channel_handler(self, subscription, *stream):
subscription = _get_sub_dictionary(subscription, [ "chanId", "key" ])
if subscription["key"].startswith("deriv:"):
return self.event_emitter.emit(
"derivatives_status_update",
subscription,
serializers.DerivativesStatus(*stream[0])
)
class AuthenticatedChannelsHandler(object): class AuthenticatedChannelsHandler(object):
def __init__(self, event_emitter, strict = False): def __init__(self, event_emitter, strict = False):
self.event_emitter, self.strict = event_emitter, strict self.event_emitter, self.strict = event_emitter, strict

View File

@@ -96,3 +96,29 @@ Candle = _Serializer("Candle", labels=[
"LOW", "LOW",
"VOLUME" "VOLUME"
]) ])
DerivativesStatus = _Serializer("DerivativesStatus", labels=[
"TIME_MS",
"_PLACEHOLDER",
"DERIV_PRICE",
"SPOT_PRICE",
"_PLACEHOLDER",
"INSURANCE_FUND_BALANCE",
"_PLACEHOLDER",
"NEXT_FUNDING_EVT_TIMESTAMP_MS",
"NEXT_FUNDING_ACCRUED",
"NEXT_FUNDING_STEP",
"_PLACEHOLDER",
"CURRENT_FUNDING"
"_PLACEHOLDER",
"_PLACEHOLDER",
"MARK_PRICE",
"_PLACEHOLDER",
"_PLACEHOLDER",
"OPEN_INTEREST",
"_PLACEHOLDER",
"_PLACEHOLDER",
"_PLACEHOLDER",
"CLAMP_MIN",
"CLAMP_MAX"
])

View File

@@ -117,6 +117,21 @@ Candle = TypedDict("Candle", {
Candles = List[Candle] Candles = List[Candle]
DerivativesStatus = TypedDict("DerivativesStatus", {
"TIME_MS": int,
"DERIV_PRICE": float,
"SPOT_PRICE": float,
"INSURANCE_FUND_BALANCE": float,
"NEXT_FUNDING_EVT_TIMESTAMP_MS": int,
"NEXT_FUNDING_ACCRUED": float,
"NEXT_FUNDING_STEP": int,
"CURRENT_FUNDING": float,
"MARK_PRICE": float,
"OPEN_INTEREST": float,
"CLAMP_MIN": float,
"CLAMP_MAX": float
})
#endregion #endregion
#region Type hinting for Websocket Authenticated Channels #region Type hinting for Websocket Authenticated Channels