From 7b313ddcab7b90326a19a66e45e90a1e61fc27ca Mon Sep 17 00:00:00 2001 From: Davide Casale Date: Tue, 31 Jan 2023 17:27:14 +0100 Subject: [PATCH] Merge TradeExecutionUpdate and TradeExecuted serializers and types in websocket subpackage. --- bfxapi/rest/exceptions.py | 1 + bfxapi/websocket/handlers.py | 3 +-- bfxapi/websocket/serializers.py | 17 +---------------- bfxapi/websocket/types.py | 19 +++---------------- 4 files changed, 6 insertions(+), 34 deletions(-) diff --git a/bfxapi/rest/exceptions.py b/bfxapi/rest/exceptions.py index beff7bc..9fbf3a4 100644 --- a/bfxapi/rest/exceptions.py +++ b/bfxapi/rest/exceptions.py @@ -3,6 +3,7 @@ from .. exceptions import BfxBaseException __all__ = [ "BfxRestException", + "ResourceNotFound", "RequestParametersError", "ResourceNotFound", "InvalidAuthenticationCredentials" diff --git a/bfxapi/websocket/handlers.py b/bfxapi/websocket/handlers.py index c56046a..1456937 100644 --- a/bfxapi/websocket/handlers.py +++ b/bfxapi/websocket/handlers.py @@ -134,8 +134,7 @@ class AuthenticatedChannelsHandler(object): __serializers = { ("os", "on", "ou", "oc",): serializers.Order, ("ps", "pn", "pu", "pc",): serializers.Position, - ("te",): serializers.TradeExecuted, - ("tu",): serializers.TradeExecutionUpdate, + ("te", "tu"): serializers.Trade, ("fos", "fon", "fou", "foc",): serializers.FundingOffer, ("fcs", "fcn", "fcu", "fcc",): serializers.FundingCredit, ("fls", "fln", "flu", "flc",): serializers.FundingLoan, diff --git a/bfxapi/websocket/serializers.py b/bfxapi/websocket/serializers.py index 5991cc9..bee2f7a 100644 --- a/bfxapi/websocket/serializers.py +++ b/bfxapi/websocket/serializers.py @@ -176,22 +176,7 @@ Position = generate_labeler_serializer("Position", klass=types.Position, labels= "meta" ]) -TradeExecuted = generate_labeler_serializer("TradeExecuted", klass=types.TradeExecuted, labels=[ - "id", - "symbol", - "mts_create", - "order_id", - "exec_amount", - "exec_price", - "order_type", - "order_price", - "maker", - "_PLACEHOLDER", - "_PLACEHOLDER", - "cid" -]) - -TradeExecutionUpdate = generate_labeler_serializer("TradeExecutionUpdate", klass=types.TradeExecutionUpdate, labels=[ +Trade = generate_labeler_serializer("Trade", klass=types.Trade, labels=[ "id", "symbol", "mts_create", diff --git a/bfxapi/websocket/types.py b/bfxapi/websocket/types.py index 91bac2a..cc70793 100644 --- a/bfxapi/websocket/types.py +++ b/bfxapi/websocket/types.py @@ -152,7 +152,7 @@ class Position(_Type): meta: JSON @dataclass -class TradeExecuted(_Type): +class Trade(_Type): id: int symbol: str mts_create: int @@ -162,21 +162,8 @@ class TradeExecuted(_Type): order_type: str order_price: float maker:int - cid: int - -@dataclass -class TradeExecutionUpdate(_Type): - id: int - symbol: str - mts_create: int - order_id: int - exec_amount: float - exec_price: float - order_type: str - order_price: float - maker:int - fee: float - fee_currency: str + fee: Optional[float] + fee_currency: Optional[str] cid: int @dataclass