mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
got some missing stock quote indicator definitions
This commit is contained in:
@@ -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."""
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user