From 1e82e1e08f2c95ca23e75fb8fdab9dc93dfcb4bd Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Sun, 10 Nov 2024 13:08:40 -0800 Subject: [PATCH] polygon symbol handling edge case --- .../extensions/websockets/openbb_websockets/client.py | 3 ++- .../websockets/openbb_websockets/websockets_router.py | 6 +++--- .../polygon/openbb_polygon/utils/websocket_client.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openbb_platform/extensions/websockets/openbb_websockets/client.py b/openbb_platform/extensions/websockets/openbb_websockets/client.py index e5b90918585..85a0ee8c1c2 100644 --- a/openbb_platform/extensions/websockets/openbb_websockets/client.py +++ b/openbb_platform/extensions/websockets/openbb_websockets/client.py @@ -705,7 +705,8 @@ def send_message( else: client.logger.error("Broadcast process is not running.") except Exception as e: - client.logger.error(f"Error sending message to WebSocket process: {e}") + msg = f"Error sending message to WebSocket process: {e.__class__.__name__} -> {e.__str__()}" + client.logger.error(msg) def read_message_queue( diff --git a/openbb_platform/extensions/websockets/openbb_websockets/websockets_router.py b/openbb_platform/extensions/websockets/openbb_websockets/websockets_router.py index e75e7d9457f..bd061c032b7 100644 --- a/openbb_platform/extensions/websockets/openbb_websockets/websockets_router.py +++ b/openbb_platform/extensions/websockets/openbb_websockets/websockets_router.py @@ -57,9 +57,9 @@ async def create_connection( await asyncio.sleep(1) - if not client.is_running: - if client._exception: - exc = getattr(client, "_exception", None) + if not client.is_running or client._exception: + exc = getattr(client, "_exception", None) + if exc: client._atexit() if isinstance(exc, UnauthorizedError): raise exc diff --git a/openbb_platform/providers/polygon/openbb_polygon/utils/websocket_client.py b/openbb_platform/providers/polygon/openbb_polygon/utils/websocket_client.py index f7248f3cd5e..f0c21e379d2 100644 --- a/openbb_platform/providers/polygon/openbb_polygon/utils/websocket_client.py +++ b/openbb_platform/providers/polygon/openbb_polygon/utils/websocket_client.py @@ -65,9 +65,9 @@ async def handle_symbol(symbol): if ticker and "." not in ticker: ticker = f"{feed}.{ticker}" - if ASSET_TYPE == "crypto" and "-" not in ticker and ticker != "*": + if ASSET_TYPE == "crypto" and "-" not in ticker and "*" not in ticker: ticker = ticker[:3] + "-" + ticker[3:] - elif ASSET_TYPE == "fx" and "/" not in ticker and ticker != "*": + elif ASSET_TYPE == "fx" and "/" not in ticker and "*" not in ticker: ticker = ticker[:3] + "/" + ticker[3:] elif ASSET_TYPE == "fx" and "-" in ticker: ticker = ticker.replace("-", "/")