From e93ab2ffd961e4336a7a649b91e70a41bcbd730a Mon Sep 17 00:00:00 2001 From: Danglewood <85772166+deeleeramone@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:37:35 -0800 Subject: [PATCH] got some missing stock quote indicator definitions --- .../openbb_fmp/models/websocket_connection.py | 21 +++++++++++------- .../polygon/openbb_polygon/utils/constants.py | 9 +++++++- .../models/websocket_connection.py | 5 +++++ .../openbb_tiingo/utils/websocket_client.py | 22 +++++++++---------- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/openbb_platform/providers/fmp/openbb_fmp/models/websocket_connection.py b/openbb_platform/providers/fmp/openbb_fmp/models/websocket_connection.py index 4a5b43c93dc..68d662e4a16 100644 --- a/openbb_platform/providers/fmp/openbb_fmp/models/websocket_connection.py +++ b/openbb_platform/providers/fmp/openbb_fmp/models/websocket_connection.py @@ -69,24 +69,24 @@ class FmpWebSocketData(WebSocketData): type: Literal["quote", "trade", "break"] = Field( description="The type of data.", ) + bid_size: Optional[float] = Field( + default=None, + description="The size of the bid.", + ) bid_price: Optional[float] = Field( default=None, description="The price of the bid.", json_schema_extra={"x-unit_measurement": "currency"}, ) - bid_size: Optional[float] = Field( - default=None, - description="The size of the bid.", - ) - ask_size: Optional[float] = Field( - default=None, - description="The size of the ask.", - ) ask_price: Optional[float] = Field( default=None, description="The price of the ask.", json_schema_extra={"x-unit_measurement": "currency"}, ) + ask_size: Optional[float] = Field( + default=None, + description="The size of the ask.", + ) last_price: Optional[float] = Field( default=None, description="The last trade price.", @@ -97,6 +97,11 @@ class FmpWebSocketData(WebSocketData): description="The size of the trade.", ) + @field_validator("symbol", mode="before") + def _validate_symbol(cls, v): + """Validate the symbol.""" + return v.upper() + @field_validator("type", mode="before", check_fields=False) def _valiidate_data_type(cls, v): """Validate the data type.""" diff --git a/openbb_platform/providers/polygon/openbb_polygon/utils/constants.py b/openbb_platform/providers/polygon/openbb_polygon/utils/constants.py index 41ab54d99f1..5501c44ee13 100644 --- a/openbb_platform/providers/polygon/openbb_polygon/utils/constants.py +++ b/openbb_platform/providers/polygon/openbb_polygon/utils/constants.py @@ -159,7 +159,14 @@ STOCK_QUOTE_CONDITIONS = { } STOCK_QUOTE_INDICATORS = { - 1: "EXCHANGE_ACQUISITION", + 1: "LULD_NBB_NBO_EXECUTABLE", + 22: "LULD_REPUBLISHED_LULD_PRICE_BAND", + 52: "FINANCIAL_STATUS_DEFICIENT", + 301: "SHORT_SALES_RESTRICTION_ACTIVATED", + 302: "SHORT_SALES_RESTRICTION_CONTINUED", + 303: "SHORT_SALES_RESTRICTION_DEACTIVATED", + 304: "SHORT_SALES_RESTRICTION_IN_EFFECT", + 305: "SHORT_SALES_RESTRICTION_MAX", 601: "NBBO_NO_CHANGE", 602: "NBBO_QUOTE_IS_NBBO", 603: "NBBO_NO_BB_NO_BO", diff --git a/openbb_platform/providers/tiingo/openbb_tiingo/models/websocket_connection.py b/openbb_platform/providers/tiingo/openbb_tiingo/models/websocket_connection.py index 0aef53649ac..3b083645952 100644 --- a/openbb_platform/providers/tiingo/openbb_tiingo/models/websocket_connection.py +++ b/openbb_platform/providers/tiingo/openbb_tiingo/models/websocket_connection.py @@ -165,6 +165,11 @@ class TiingoWebSocketData(WebSocketData): description="True if the order is not subject to NMS Rule 611. Only for stock.", ) + @field_validator("symbol", mode="before", check_fields=False) + def _validate_symbol(cls, v): + """Validate the symbol.""" + return v.upper() + @field_validator("type", mode="before", check_fields=False) def _valiidate_data_type(cls, v): """Validate the data type.""" diff --git a/openbb_platform/providers/tiingo/openbb_tiingo/utils/websocket_client.py b/openbb_platform/providers/tiingo/openbb_tiingo/utils/websocket_client.py index cc2e0684126..b93aa328720 100644 --- a/openbb_platform/providers/tiingo/openbb_tiingo/utils/websocket_client.py +++ b/openbb_platform/providers/tiingo/openbb_tiingo/utils/websocket_client.py @@ -223,16 +223,17 @@ async def connect_and_stream( connect_kwargs["close_timeout"] = None try: - async with websockets.connect(url, **connect_kwargs) as websocket: - logger.info("PROVIDER INFO: WebSocket connection established.") - await websocket.send(json.dumps(subscribe_event)) - while True: - message = await websocket.recv() - await queue.enqueue(message) + try: + async with websockets.connect(url, **connect_kwargs) as websocket: + logger.info("PROVIDER INFO: WebSocket connection established.") + await websocket.send(json.dumps(subscribe_event)) + while True: + message = await websocket.recv() + await queue.enqueue(message) - except UnauthorizedError as e: - logger.error(str(e)) - sys.exit(1) + except UnauthorizedError as e: + logger.error(str(e)) + sys.exit(1) except websockets.ConnectionClosed as e: msg = ( @@ -284,9 +285,6 @@ if __name__ == "__main__": ) loop.run_forever() - except websockets.ConnectionClosed: - logger.error("PROVIDER ERROR: WebSocket connection closed") - except Exception as e: # pylint: disable=broad-except msg = f"Unexpected error -> {e.__class__.__name__}: {e.__str__()}" logger.error(msg)