From 6a368d139db82a4e99afab0870d44133e0e896ff Mon Sep 17 00:00:00 2001 From: Davide Casale Date: Fri, 9 Dec 2022 16:23:51 +0100 Subject: [PATCH] Add support for GET liquidations/hist endpoint. --- bfxapi/rest/BfxRestInterface.py | 7 ++++++- bfxapi/rest/serializers.py | 15 +++++++++++++++ bfxapi/rest/typings.py | 13 +++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/bfxapi/rest/BfxRestInterface.py b/bfxapi/rest/BfxRestInterface.py index e511692..375d0d6 100644 --- a/bfxapi/rest/BfxRestInterface.py +++ b/bfxapi/rest/BfxRestInterface.py @@ -119,4 +119,9 @@ class BfxRestInterface(object): params = { "sort": sort, "start": start, "end": end, "limit": limit } - return [ serializers.DerivativesStatus.parse(*subdata, skip=[ "KEY" ]) for subdata in self.__GET(endpoint, params=params) ] \ No newline at end of file + return [ serializers.DerivativesStatus.parse(*subdata, skip=[ "KEY" ]) for subdata in self.__GET(endpoint, params=params) ] + + def liquidations(self, sort: Optional[int] = None, start: Optional[str] = None, end: Optional[str] = None, limit: Optional[int] = None) -> Liquidations: + params = { "sort": sort, "start": start, "end": end, "limit": limit } + + return [ serializers.Liquidation.parse(*subdata[0]) for subdata in self.__GET("liquidations/hist", params=params) ] \ No newline at end of file diff --git a/bfxapi/rest/serializers.py b/bfxapi/rest/serializers.py index 43f6ace..22817e0 100644 --- a/bfxapi/rest/serializers.py +++ b/bfxapi/rest/serializers.py @@ -161,4 +161,19 @@ DerivativesStatus = _Serializer[typings.DerivativesStatus]("DerivativesStatus", "CLAMP_MAX" ]) +Liquidation = _Serializer[typings.Liquidation]("Liquidation", labels=[ + "_PLACEHOLDER", + "POS_ID", + "MTS", + "_PLACEHOLDER", + "SYMBOL", + "AMOUNT", + "BASE_PRICE", + "_PLACEHOLDER", + "IS_MATCH", + "IS_MARKET_SOLD", + "_PLACEHOLDER", + "PRICE_ACQUIRED" +]) + #endregion \ No newline at end of file diff --git a/bfxapi/rest/typings.py b/bfxapi/rest/typings.py index 7c8f127..5afc040 100644 --- a/bfxapi/rest/typings.py +++ b/bfxapi/rest/typings.py @@ -104,4 +104,17 @@ DerivativesStatus = TypedDict("DerivativesStatus", { DerivativeStatuses = List[DerivativesStatus] +Liquidation = TypedDict("Liquidation", { + "POS_ID": int, + "MTS": int, + "SYMBOL": str, + "AMOUNT": float, + "BASE_PRICE": float, + "IS_MATCH": int, + "IS_MARKET_SOLD": int, + "PRICE_ACQUIRED": float +}) + +Liquidations = List[Liquidation] + #endregion \ No newline at end of file