Apply refactoring to root package bfxapi.

This commit is contained in:
Davide Casale
2023-02-17 18:38:07 +01:00
parent d72fcf3981
commit ab66170cf3
29 changed files with 81 additions and 78 deletions

View File

@@ -1,39 +1,27 @@
from .rest import BfxRestInterface
from .websocket import BfxWebsocketClient
from .urls import REST_HOST, WSS_HOST
from typing import List, Optional
from enum import Enum
class Constants(str, Enum):
REST_HOST = "https://api.bitfinex.com/v2"
PUB_REST_HOST = "https://api-pub.bitfinex.com/v2"
STAGING_REST_HOST = "https://api.staging.bitfinex.com/v2"
WSS_HOST = "wss://api.bitfinex.com/ws/2"
PUB_WSS_HOST = "wss://api-pub.bitfinex.com/ws/2"
STAGING_WSS_HOST = "wss://api.staging.bitfinex.com/ws/2"
class Client(object):
def __init__(
self,
REST_HOST: str = Constants.REST_HOST,
WSS_HOST: str = Constants.WSS_HOST,
REST_HOST: str = REST_HOST,
WSS_HOST: str = WSS_HOST,
API_KEY: Optional[str] = None,
API_SECRET: Optional[str] = None,
filter: Optional[List[str]] = None,
log_level: str = "INFO"
):
credentials = {
"API_KEY": API_KEY,
"API_SECRET": API_SECRET,
"filter": filter
}
credentials = None
if API_KEY and API_SECRET:
credentials = { "API_KEY": API_KEY, "API_SECRET": API_SECRET, "filter": filter }
self.rest = BfxRestInterface(
host=REST_HOST,
API_KEY=API_KEY,
API_SECRET=API_SECRET
credentials=credentials
)
self.wss = BfxWebsocketClient(