mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-31 14:31:20 +00:00
Merge branch 'develop' into feature/charting-obbject
This commit is contained in:
@@ -245,6 +245,7 @@ class ProviderInterface(metaclass=SingletonMeta):
|
||||
title=provider_name,
|
||||
description=description,
|
||||
alias=field.alias or None,
|
||||
json_schema_extra=field.json_schema_extra,
|
||||
)
|
||||
elif provider_name:
|
||||
default: FieldInfo = Field(
|
||||
@@ -257,6 +258,7 @@ class ProviderInterface(metaclass=SingletonMeta):
|
||||
)
|
||||
if alias_dict.get(name, [])
|
||||
else None,
|
||||
json_schema_extra=field.json_schema_extra,
|
||||
)
|
||||
|
||||
return DataclassField(new_name, type_, default)
|
||||
@@ -479,6 +481,7 @@ class ProviderInterface(metaclass=SingletonMeta):
|
||||
fields.update(extra.model_fields)
|
||||
|
||||
fields_dict: Dict[str, Tuple[Any, Any]] = {}
|
||||
|
||||
for name, field in fields.items():
|
||||
fields_dict[name] = (
|
||||
field.annotation,
|
||||
@@ -488,6 +491,7 @@ class ProviderInterface(metaclass=SingletonMeta):
|
||||
description=field.description,
|
||||
alias=field.alias,
|
||||
validation_alias=field.validation_alias,
|
||||
json_schema_extra=field.json_schema_extra,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class EquityQuoteQueryParams(QueryParams):
|
||||
|
||||
symbol: str = Field(
|
||||
description=QUERY_DESCRIPTIONS.get("symbol", "")
|
||||
+ " In this case, the comma separated list of symbols."
|
||||
+ " This endpoint will accept multiple symbols separated by commas."
|
||||
)
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@@ -33,14 +33,125 @@ class EquityQuoteQueryParams(QueryParams):
|
||||
class EquityQuoteData(Data):
|
||||
"""Equity Quote Data."""
|
||||
|
||||
day_low: Optional[float] = Field(
|
||||
symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", ""))
|
||||
asset_type: Optional[str] = Field(
|
||||
default=None, description="Type of asset - i.e, stock, ETF, etc."
|
||||
)
|
||||
name: Optional[str] = Field(
|
||||
default=None, description="Name of the company or asset."
|
||||
)
|
||||
exchange: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Lowest price of the stock in the current trading day.",
|
||||
description="The name or symbol of the venue where the data is from.",
|
||||
)
|
||||
day_high: Optional[float] = Field(
|
||||
bid: Optional[float] = Field(
|
||||
default=None, description="Price of the top bid order."
|
||||
)
|
||||
bid_size: Optional[int] = Field(
|
||||
default=None,
|
||||
description="Highest price of the stock in the current trading day.",
|
||||
description="This represents the number of round lot orders at the given price."
|
||||
+ " The normal round lot size is 100 shares."
|
||||
+ " A size of 2 means there are 200 shares available at the given price.",
|
||||
)
|
||||
date: Optional[datetime] = Field(
|
||||
description=DATA_DESCRIPTIONS.get("date", ""), default=None
|
||||
bid_exchange: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The specific trading venue where the purchase order was placed.",
|
||||
)
|
||||
ask: Optional[float] = Field(
|
||||
default=None, description="Price of the top ask order."
|
||||
)
|
||||
ask_size: Optional[int] = Field(
|
||||
default=None,
|
||||
description="This represents the number of round lot orders at the given price."
|
||||
+ " The normal round lot size is 100 shares."
|
||||
+ " A size of 2 means there are 200 shares available at the given price.",
|
||||
)
|
||||
ask_exchange: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The specific trading venue where the sale order was placed.",
|
||||
)
|
||||
quote_conditions: Optional[Union[str, int, List[str], List[int]]] = Field(
|
||||
default=None,
|
||||
description="Conditions or condition codes applicable to the quote.",
|
||||
)
|
||||
quote_indicators: Optional[Union[str, int, List[str], List[int]]] = Field(
|
||||
default=None,
|
||||
description="Indicators or indicator codes applicable to the participant"
|
||||
+ " quote related to the price bands for the issue, or the affect the quote has"
|
||||
+ " on the NBBO.",
|
||||
)
|
||||
sales_conditions: Optional[Union[str, int, List[str], List[int]]] = Field(
|
||||
default=None,
|
||||
description="Conditions or condition codes applicable to the sale.",
|
||||
)
|
||||
sequence_number: Optional[int] = Field(
|
||||
default=None,
|
||||
description="The sequence number represents the sequence in which message events happened."
|
||||
+ " These are increasing and unique per ticker symbol,"
|
||||
+ " but will not always be sequential (e.g., 1, 2, 6, 9, 10, 11).",
|
||||
)
|
||||
market_center: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The ID of the UTP participant that originated the message.",
|
||||
)
|
||||
participant_timestamp: Optional[datetime] = Field(
|
||||
default=None,
|
||||
description="Timestamp for when the quote was generated by the exchange.",
|
||||
)
|
||||
trf_timestamp: Optional[datetime] = Field(
|
||||
default=None,
|
||||
description="Timestamp for when the TRF (Trade Reporting Facility) received the message.",
|
||||
)
|
||||
sip_timestamp: Optional[datetime] = Field(
|
||||
default=None,
|
||||
description="Timestamp for when the SIP (Security Information Processor)"
|
||||
+ " received the message from the exchange.",
|
||||
)
|
||||
last_price: Optional[float] = Field(
|
||||
default=None, description="Price of the last trade."
|
||||
)
|
||||
last_tick: Optional[str] = Field(
|
||||
default=None, description="Whether the last sale was an up or down tick."
|
||||
)
|
||||
last_size: Optional[int] = Field(
|
||||
default=None, description="Size of the last trade."
|
||||
)
|
||||
last_timestamp: Optional[datetime] = Field(
|
||||
default=None, description="Date and Time when the last price was recorded."
|
||||
)
|
||||
open: Optional[float] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("open", "")
|
||||
)
|
||||
high: Optional[float] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("high", "")
|
||||
)
|
||||
low: Optional[float] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("low", "")
|
||||
)
|
||||
close: Optional[float] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("close", "")
|
||||
)
|
||||
volume: Optional[Union[int, float]] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("volume", "")
|
||||
)
|
||||
exchange_volume: Optional[Union[int, float]] = Field(
|
||||
default=None,
|
||||
description="Volume of shares exchanged during the trading day on the specific exchange.",
|
||||
)
|
||||
prev_close: Optional[float] = Field(
|
||||
default=None, description=DATA_DESCRIPTIONS.get("prev_close", "")
|
||||
)
|
||||
change: Optional[float] = Field(
|
||||
default=None, description="Change in price from previous close."
|
||||
)
|
||||
change_percent: Optional[float] = Field(
|
||||
default=None,
|
||||
description="Change in price as a normalized percentage.",
|
||||
json_schema_extra={"x-frontendmultiply": 100},
|
||||
)
|
||||
year_high: Optional[float] = Field(
|
||||
default=None, description="The one year high (52W High)."
|
||||
)
|
||||
year_low: Optional[float] = Field(
|
||||
default=None, description="The one year low (52W Low)."
|
||||
)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
"""Revenue by Business Line Standard Model."""
|
||||
|
||||
|
||||
import warnings
|
||||
from datetime import date as dateType
|
||||
from typing import Dict, List, Literal, Set, Union
|
||||
from typing import Dict, Literal, Optional
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
from openbb_core.provider.abstract.data import Data, ForceInt
|
||||
from openbb_core.provider.abstract.query_params import QueryParams
|
||||
from openbb_core.provider.utils.descriptions import (
|
||||
DATA_DESCRIPTIONS,
|
||||
QUERY_DESCRIPTIONS,
|
||||
)
|
||||
|
||||
_warn = warnings.warn
|
||||
|
||||
|
||||
class RevenueBusinessLineQueryParams(QueryParams):
|
||||
"""Revenue by Business Line Query."""
|
||||
@@ -26,17 +27,29 @@ class RevenueBusinessLineQueryParams(QueryParams):
|
||||
) # should always be flat
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
def upper_symbol(cls, v: Union[str, List[str], Set[str]]):
|
||||
@classmethod
|
||||
def upper_symbol(cls, v: str):
|
||||
"""Convert symbol to uppercase."""
|
||||
if isinstance(v, str):
|
||||
return v.upper()
|
||||
return ",".join([symbol.upper() for symbol in list(v)])
|
||||
if "," in v:
|
||||
_warn(
|
||||
f"{QUERY_DESCRIPTIONS.get('symbol_list_warning', '')} {v.split(',')[0].upper()}"
|
||||
)
|
||||
return v.split(",")[0].upper() if "," in v else v.upper()
|
||||
|
||||
|
||||
class RevenueBusinessLineData(Data):
|
||||
"""Revenue by Business Line Data."""
|
||||
|
||||
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
business_line: Dict[str, ForceInt] = Field(
|
||||
description="Day level data containing the revenue of the business line."
|
||||
period_ending: dateType = Field(description="The end date of the reporting period.")
|
||||
fiscal_period: Optional[str] = Field(
|
||||
default=None, description="The fiscal period of the reporting period."
|
||||
)
|
||||
fiscal_year: Optional[int] = Field(
|
||||
default=None, description="The fiscal year of the reporting period."
|
||||
)
|
||||
filing_date: Optional[dateType] = Field(
|
||||
default=None, description="The filing date of the report."
|
||||
)
|
||||
business_line: Dict[str, ForceInt] = Field(
|
||||
description="Dictionary containing the revenue of the business line."
|
||||
)
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
"""Revenue by Geographic Segments Standard Model."""
|
||||
|
||||
|
||||
import warnings
|
||||
from datetime import date as dateType
|
||||
from typing import Dict, List, Literal, Optional, Set, Union
|
||||
from typing import Dict, Literal, Optional
|
||||
|
||||
from pydantic import Field, field_validator
|
||||
|
||||
from openbb_core.provider.abstract.data import Data, ForceInt
|
||||
from openbb_core.provider.abstract.query_params import QueryParams
|
||||
from openbb_core.provider.utils.descriptions import (
|
||||
DATA_DESCRIPTIONS,
|
||||
QUERY_DESCRIPTIONS,
|
||||
)
|
||||
|
||||
_warn = warnings.warn
|
||||
|
||||
|
||||
class RevenueGeographicQueryParams(QueryParams):
|
||||
"""Revenue by Geographic Segments Query."""
|
||||
@@ -27,32 +28,28 @@ class RevenueGeographicQueryParams(QueryParams):
|
||||
|
||||
@field_validator("symbol", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def upper_symbol(cls, v: Union[str, List[str], Set[str]]):
|
||||
def upper_symbol(cls, v: str):
|
||||
"""Convert symbol to uppercase."""
|
||||
if isinstance(v, str):
|
||||
return v.upper()
|
||||
return ",".join([symbol.upper() for symbol in list(v)])
|
||||
if "," in v:
|
||||
_warn(
|
||||
f"{QUERY_DESCRIPTIONS.get('symbol_list_warning', '')} {v.split(',')[0].upper()}"
|
||||
)
|
||||
return v.split(",")[0].upper() if "," in v else v.upper()
|
||||
|
||||
|
||||
class RevenueGeographicData(Data):
|
||||
"""Revenue by Geographic Segments Data."""
|
||||
|
||||
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
period_ending: dateType = Field(description="The end date of the reporting period.")
|
||||
fiscal_period: Optional[str] = Field(
|
||||
default=None, description="The fiscal period of the reporting period."
|
||||
)
|
||||
fiscal_year: Optional[int] = Field(
|
||||
default=None, description="The fiscal year of the reporting period."
|
||||
)
|
||||
filing_date: Optional[dateType] = Field(
|
||||
default=None, description="The filing date of the report."
|
||||
)
|
||||
geographic_segment: Dict[str, ForceInt] = Field(
|
||||
description="Day level data containing the revenue of the geographic segment."
|
||||
)
|
||||
americas: Optional[ForceInt] = Field(
|
||||
default=None, description="Revenue from the the American segment."
|
||||
)
|
||||
europe: Optional[ForceInt] = Field(
|
||||
default=None, description="Revenue from the the European segment."
|
||||
)
|
||||
greater_china: Optional[ForceInt] = Field(
|
||||
default=None, description="Revenue from the the Greater China segment."
|
||||
)
|
||||
japan: Optional[ForceInt] = Field(
|
||||
default=None, description="Revenue from the the Japan segment."
|
||||
)
|
||||
rest_of_asia_pacific: Optional[ForceInt] = Field(
|
||||
default=None, description="Revenue from the the Rest of Asia Pacific segment."
|
||||
description="Dictionary of the revenue by geographic segment."
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
|
||||
from datetime import date as dateType
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
@@ -17,6 +18,11 @@ class TrailingDivYieldQueryParams(QueryParams):
|
||||
"""Trailing Dividend Yield Query."""
|
||||
|
||||
symbol: str = Field(default=None, description=QUERY_DESCRIPTIONS.get("symbol", ""))
|
||||
limit: Optional[int] = Field(
|
||||
default=252,
|
||||
description=f"{QUERY_DESCRIPTIONS.get('limit', '')}"
|
||||
" Default is 252, the number of trading days in a year.",
|
||||
)
|
||||
|
||||
|
||||
class TrailingDivYieldData(Data):
|
||||
|
||||
Reference in New Issue
Block a user