From 17646f9980239aa9e3857cb6cf8c825cc9aedb59 Mon Sep 17 00:00:00 2001 From: itsdeka Date: Sat, 27 Aug 2022 17:09:00 +0200 Subject: [PATCH] refactoring - moved hosts to constants.py --- bfxapi/client.py | 6 +----- bfxapi/constants.py | 4 ++++ bfxapi/websockets/bfx_websocket.py | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 bfxapi/constants.py diff --git a/bfxapi/client.py b/bfxapi/client.py index 1700f6c..1d2d57c 100644 --- a/bfxapi/client.py +++ b/bfxapi/client.py @@ -7,11 +7,7 @@ a websocket client and a rest interface client from .websockets.bfx_websocket import BfxWebsocket from .rest.bfx_rest import BfxRest - -REST_HOST = 'https://api.bitfinex.com/v2' -WS_HOST = 'wss://api.bitfinex.com/ws/2' -PUB_REST_HOST = 'https://api-pub.bitfinex.com/v2' -PUB_WS_HOST = 'wss://api-pub.bitfinex.com/ws/2' +from .constants import * class Client: """ diff --git a/bfxapi/constants.py b/bfxapi/constants.py new file mode 100644 index 0000000..a0c6525 --- /dev/null +++ b/bfxapi/constants.py @@ -0,0 +1,4 @@ +REST_HOST = 'https://api.bitfinex.com/v2' +WS_HOST = 'wss://api.bitfinex.com/ws/2' +PUB_REST_HOST = 'https://api-pub.bitfinex.com/v2' +PUB_WS_HOST = 'wss://api-pub.bitfinex.com/ws/2' \ No newline at end of file diff --git a/bfxapi/websockets/bfx_websocket.py b/bfxapi/websockets/bfx_websocket.py index 74c2371..451d975 100644 --- a/bfxapi/websockets/bfx_websocket.py +++ b/bfxapi/websockets/bfx_websocket.py @@ -14,6 +14,7 @@ from .order_manager import OrderManager from ..utils.auth import generate_auth_payload from ..utils.decorators import handle_failure from ..models import Order, Trade, OrderBook, Ticker, FundingTicker +from ..constants import PUB_WS_HOST class Flags: @@ -187,7 +188,7 @@ class BfxWebsocket(GenericWebsocket): - `unsubscribed` (Subscription): A channel has been un-subscribed """ - def __init__(self, API_KEY=None, API_SECRET=None, host='wss://api-pub.bitfinex.com/ws/2', + def __init__(self, API_KEY=None, API_SECRET=None, host=PUB_WS_HOST, manageOrderBooks=False, dead_man_switch=False, ws_capacity=25, logLevel='INFO', parse_float=float, channel_filter=[], *args, **kwargs): self.API_KEY = API_KEY