diff --git a/bfxapi/exceptions.py b/bfxapi/exceptions.py index 1033837..d876946 100644 --- a/bfxapi/exceptions.py +++ b/bfxapi/exceptions.py @@ -1,9 +1,7 @@ __all__ = [ "BfxBaseException", - + "LabelerSerializerException", - "IntegerUnderflowError", - "IntegerOverflowflowError" ] class BfxBaseException(Exception): @@ -18,18 +16,4 @@ class LabelerSerializerException(BfxBaseException): This exception indicates an error thrown by the _Serializer class in bfxapi/labeler.py. """ - pass - -class IntegerUnderflowError(BfxBaseException): - """ - This error indicates an underflow in one of the integer types defined in bfxapi/utils/integers.py. - """ - - pass - -class IntegerOverflowflowError(BfxBaseException): - """ - This error indicates an overflow in one of the integer types defined in bfxapi/utils/integers.py. - """ - pass \ No newline at end of file diff --git a/bfxapi/rest/_Requests.py b/bfxapi/rest/_Requests.py index 6e4383a..8103d03 100644 --- a/bfxapi/rest/_Requests.py +++ b/bfxapi/rest/_Requests.py @@ -4,7 +4,7 @@ from http import HTTPStatus from .enums import Error from .exceptions import ResourceNotFound, RequestParametersError, InvalidAuthenticationCredentials, UnknownGenericError -from .. utils.encoder import JSONEncoder +from ..utils.JSONEncoder import JSONEncoder class _Requests(object): def __init__(self, host, API_KEY = None, API_SECRET = None): diff --git a/bfxapi/rest/types.py b/bfxapi/rest/types.py index ad28321..084bcc5 100644 --- a/bfxapi/rest/types.py +++ b/bfxapi/rest/types.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from .. labeler import _Type from .. notification import Notification -from .. utils.encoder import JSON +from ..utils.JSONEncoder import JSON __types__ = [ "PlatformStatus", "TradingPairTicker", "FundingCurrencyTicker", diff --git a/bfxapi/utils/encoder.py b/bfxapi/utils/JSONEncoder.py similarity index 100% rename from bfxapi/utils/encoder.py rename to bfxapi/utils/JSONEncoder.py diff --git a/bfxapi/utils/cid.py b/bfxapi/utils/cid.py deleted file mode 100644 index 43150bb..0000000 --- a/bfxapi/utils/cid.py +++ /dev/null @@ -1,4 +0,0 @@ -import time - -def generate_unique_cid(multiplier: int = 1000) -> int: - return int(round(time.time() * multiplier)) diff --git a/bfxapi/utils/integers.py b/bfxapi/utils/integers.py deleted file mode 100644 index 08582c6..0000000 --- a/bfxapi/utils/integers.py +++ /dev/null @@ -1,43 +0,0 @@ -from typing import cast, TypeVar, Union - -from .. exceptions import IntegerUnderflowError, IntegerOverflowflowError - -__all__ = [ "Int16", "Int32", "Int45", "Int64" ] - -T = TypeVar("T") - -class _Int(int): - def __new__(cls: T, integer: int) -> T: - assert hasattr(cls, "_BITS"), "_Int must be extended by a class that has a static member _BITS (indicating the number of bits with which to represent the integers)." - - bits = cls._BITS - 1 - - min, max = -(2 ** bits), (2 ** bits) - 1 - - if integer < min: - raise IntegerUnderflowError(f"Underflow. Cannot store <{integer}> in {cls._BITS} bits integer. The min and max bounds are {min} and {max}.") - - if integer > max: - raise IntegerOverflowflowError(f"Overflow. Cannot store <{integer}> in {cls._BITS} bits integer. The min and max bounds are {min} and {max}.") - - return cast(T, super().__new__(int, integer)) - -class Int16(_Int): - _BITS = 16 - -int16 = Union[Int16, int] - -class Int32(_Int): - _BITS = 32 - -int32 = Union[Int32, int] - -class Int45(_Int): - _BITS = 45 - -int45 = Union[Int45, int] - -class Int64(_Int): - _BITS = 64 - -int64 = Union[Int64, int] \ No newline at end of file diff --git a/bfxapi/websocket/BfxWebsocketClient.py b/bfxapi/websocket/BfxWebsocketClient.py index e5c7efb..3bdb3d9 100644 --- a/bfxapi/websocket/BfxWebsocketClient.py +++ b/bfxapi/websocket/BfxWebsocketClient.py @@ -10,7 +10,7 @@ from ._BfxWebsocketInputs import _BfxWebsocketInputs from .handlers import Channels, PublicChannelsHandler, AuthenticatedChannelsHandler from .exceptions import WebsocketAuthenticationRequired, InvalidAuthenticationCredentials, EventNotSupported -from ..utils.encoder import JSONEncoder +from ..utils.JSONEncoder import JSONEncoder from ..utils.logger import Formatter, CustomLogger diff --git a/bfxapi/websocket/types.py b/bfxapi/websocket/types.py index 3e0991f..d1c8ab4 100644 --- a/bfxapi/websocket/types.py +++ b/bfxapi/websocket/types.py @@ -4,7 +4,7 @@ from dataclasses import dataclass from ..labeler import _Type from ..notification import Notification -from .. utils.encoder import JSON +from ..utils.JSONEncoder import JSON __types__ = [ "TradingPairTicker", "FundingCurrencyTicker", "TradingPairTrade",