fix missing descriptions (#5420)

* fix missing descriptions

* black & ruff

* remove f string

* update desc

* update desc

* update desc

* update desc

* update desc

* update desc
This commit is contained in:
montezdesousa
2023-09-08 12:11:46 +01:00
committed by GitHub
parent 735389f0ce
commit 3ad3375c6a
21 changed files with 99 additions and 102 deletions

View File

@@ -65,7 +65,7 @@ class CLASS_economy(Container):
region : Optional[str]
Region for the index. Valid only for European indices (provider: cboe)
symbol : Optional[str]
Symbol for the index. (provider: cboe)
Symbol for the index. (provider: cboe, yfinance)
description : Optional[str]
Description for the index. Valid only for US indices. (provider: cboe)
data_delay : Optional[int]
@@ -364,7 +364,7 @@ class CLASS_economy(Container):
If None, the provider specified in defaults is selected or 'cboe' if there is
no default.
interval : Union[Literal['1d', '1m'], NoneType]
Use interval, 1m, for intraday prices during the most recent trading period. (provider: cboe)
Data granularity. (provider: cboe)
Returns
-------
@@ -532,7 +532,7 @@ class CLASS_economy(Container):
If None, the provider specified in defaults is selected or 'cboe' if there is
no default.
interval : Union[Literal['1d', '1m'], NoneType, Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]
None
Data granularity. (provider: cboe, fmp, yfinance)
timeseries : Union[pydantic.types.NonNegativeInt, NoneType]
Number of days to look back. (provider: fmp)
timespan : Literal['minute', 'hour', 'day', 'week', 'month', 'quarter', 'year']

View File

@@ -23,4 +23,4 @@
"quandl@0.1.0a0",
"yfinance@0.1.0a0"
]
}
}

View File

@@ -113,7 +113,7 @@ class CLASS_news(Container):
site : Optional[str]
Site of the news. (provider: fmp)
id : Optional[str]
Intrinio ID for the news article. (provider: intrinio)
Article ID. (provider: intrinio)
company : Optional[Mapping[str, Any]]
Company details related to the news article. (provider: intrinio)""" # noqa: E501

View File

@@ -206,11 +206,11 @@ class CLASS_stocks(Container):
If None, the provider specified in defaults is selected or 'alpha_vantage' if there is
no default.
period : Union[Literal['intraday', 'daily', 'weekly', 'monthly'], Literal['1d', '5d', '1mo', '3mo', '6mo', '1y', '2y', '5y', '10y', 'ytd', 'max'], NoneType]
None
Period of the data to return. (provider: alpha_vantage, yfinance)
interval : Union[Literal['1min', '5min', '15min', '30min', '60min'], NoneType, Literal['1d', '1m'], Literal['1min', '5min', '15min', '30min', '1hour', '4hour', '1day'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1wk', '1mo', '3mo']]
None
Data granularity. (provider: alpha_vantage, cboe, fmp, yfinance)
adjusted : Union[bool, NoneType]
None
Output time series is adjusted by historical split and dividend events. (provider: alpha_vantage, polygon)
extended_hours : Union[bool, NoneType]
Extended trading hours during pre-market and after-hours. (provider: alpha_vantage)
month : Union[str, NoneType]
@@ -230,7 +230,7 @@ class CLASS_stocks(Container):
interval_size : Union[Literal['1m', '5m', '10m', '15m', '30m', '60m', '1h'], NoneType]
The data time frequency. (provider: intrinio)
limit : Union[pydantic.types.NonNegativeInt, NoneType, pydantic.types.PositiveInt]
None
The number of data entries to return. (provider: intrinio, polygon)
next_page : Union[str, NoneType]
Token to get the next page of data from a previous API call. (provider: intrinio)
all_pages : Union[bool, NoneType]
@@ -295,7 +295,7 @@ class CLASS_stocks(Container):
unadjusted_volume : Optional[float]
Unadjusted volume of the symbol. (provider: fmp)
change : Optional[float]
Change in the price of the symbol from the previous day. (provider: fmp)
Change in the price of the symbol from the previous day. (provider: fmp, intrinio)
change_percent : Optional[float]
Change \\% in the price of the symbol. (provider: fmp)
label : Optional[str]
@@ -565,7 +565,7 @@ class CLASS_stocks(Container):
published_since : Union[int, NoneType]
Number of seconds since the news was published. (provider: benzinga)
sort : Union[Literal['published_at', 'updated_at', 'title', 'author', 'channel', 'ticker', 'topic', 'content_type'], NoneType, str]
None
Order in which to sort the news. (provider: benzinga, polygon)
isin : Union[str, NoneType]
The ISIN of the news to retrieve. (provider: benzinga)
cusip : Union[str, NoneType]
@@ -583,25 +583,25 @@ class CLASS_stocks(Container):
all_pages : Union[bool, NoneType]
Returns all pages of data from the API call at once. (provider: intrinio)
ticker_lt : Union[str, NoneType]
Less than, by default None (provider: polygon)
Less than. (provider: polygon)
ticker_lte : Union[str, NoneType]
Less than or equal, by default None (provider: polygon)
Less than or equal. (provider: polygon)
ticker_gt : Union[str, NoneType]
Greater than, by default None (provider: polygon)
Greater than. (provider: polygon)
ticker_gte : Union[str, NoneType]
Greater than or equal, by default None (provider: polygon)
Greater than or equal. (provider: polygon)
published_utc : Union[str, NoneType]
Published date of the query, by default None (provider: polygon)
Published date of the query. (provider: polygon)
published_utc_lt : Union[str, NoneType]
Less than, by default None (provider: polygon)
Less than. (provider: polygon)
published_utc_lte : Union[str, NoneType]
Less than or equal, by default None (provider: polygon)
Less than or equal. (provider: polygon)
published_utc_gt : Union[str, NoneType]
Greater than, by default None (provider: polygon)
Greater than. (provider: polygon)
published_utc_gte : Union[str, NoneType]
Greater than or equal, by default None (provider: polygon)
Greater than or equal. (provider: polygon)
order : Union[Literal['asc', 'desc'], NoneType]
Sort order of the query, by default None (provider: polygon)
Sort order of the query. (provider: polygon)
Returns
-------
@@ -644,7 +644,7 @@ class CLASS_stocks(Container):
site : Optional[str]
Name of the news source. (provider: fmp)
id : Optional[str]
Intrinio ID for the news article. (provider: intrinio)
Article ID. (provider: intrinio, polygon)
amp_url : Optional[str]
AMP URL. (provider: polygon)
author : Optional[str]
@@ -654,7 +654,7 @@ class CLASS_stocks(Container):
keywords : Optional[List[str]]
Keywords in the article (provider: polygon)
publisher : Union[PolygonPublisher, NoneType, str]
Publisher of the article. (provider: polygon)
Publisher of the article. (provider: polygon, yfinance)
tickers : Optional[List[str]]
Tickers covered in the article. (provider: polygon)
uuid : Optional[str]

View File

@@ -80,11 +80,11 @@ class CLASS_stocks_options(Container):
theoretical : Optional[float]
Theoretical value of the option. (provider: cboe)
open : Optional[float]
Opening price of the option. (provider: cboe)
Opening price of the option. (provider: cboe, intrinio)
high : Optional[float]
High price of the option. (provider: cboe)
High price of the option. (provider: cboe, intrinio)
low : Optional[float]
Low price of the option. (provider: cboe)
Low price of the option. (provider: cboe, intrinio)
last_trade_price : Optional[float]
Last trade price of the option. (provider: cboe)
tick : Optional[str]
@@ -96,21 +96,21 @@ class CLASS_stocks_options(Container):
change_percent : Optional[float]
Change, in percent, of the option. (provider: cboe)
implied_volatility : Optional[float]
Implied volatility of the option. (provider: cboe)
Implied volatility of the option. (provider: cboe, intrinio)
delta : Optional[float]
Delta of the option. (provider: cboe)
Delta of the option. (provider: cboe, intrinio)
gamma : Optional[float]
Gamma of the option. (provider: cboe)
Gamma of the option. (provider: cboe, intrinio)
vega : Optional[float]
Vega of the option. (provider: cboe)
Vega of the option. (provider: cboe, intrinio)
theta : Optional[float]
Theta of the option. (provider: cboe)
Theta of the option. (provider: cboe, intrinio)
rho : Optional[float]
Rho of the option. (provider: cboe)
last_trade_timestamp : Optional[datetime]
Last trade timestamp of the option. (provider: cboe)
dte : Optional[int]
Days to expiration for the option. (provider: cboe)
Days to expiration for the option. (provider: cboe, intrinio)
mark : Optional[float]
The mid-price between the latest bid-ask spread. (provider: intrinio)
open_bid : Optional[float]
@@ -126,7 +126,7 @@ class CLASS_stocks_options(Container):
ask_high : Optional[float]
The highest ask price for the option that day. (provider: intrinio)
close : Optional[float]
The close price for the option that day. (provider: intrinio)
Close price for the option that day. (provider: intrinio)
eod_date : Optional[date]
Historical date for which the options chains data is from. (provider: intrinio)
""" # noqa: E501

View File

@@ -38,7 +38,7 @@ class AVStockHistoricalQueryParams(StockHistoricalQueryParams):
default="daily", description=QUERY_DESCRIPTIONS.get("period", "")
)
interval: Optional[Literal["1min", "5min", "15min", "30min", "60min"]] = Field(
description="The interval between two consecutive data points in the time series.",
description="Data granularity.",
default="60min",
available_on_functions=["TIME_SERIES_INTRADAY"],
required_on_functions=["TIME_SERIES_INTRADAY"],

View File

@@ -52,11 +52,7 @@ class BenzingaStockNewsQueryParams(StockNewsQueryParams):
"topic",
"content_type",
]
] = Field(
default=None,
description="Order in which to sort the news. "
"Options are: published_at, updated_at, title, author, channel, ticker, topic, content_type.",
)
] = Field(default=None, description="Order in which to sort the news.")
isin: Optional[str] = Field(
default=None, description="The ISIN of the news to retrieve."
)

View File

@@ -22,7 +22,7 @@ class CboeEuropeanIndexHistoricalQueryParams(EuropeanIndexHistoricalQueryParams)
"""
interval: Optional[Literal["1d", "1m"]] = Field(
description="Use interval, 1m, for intraday prices during the most recent trading period.",
description="Data granularity.",
default="1d",
)

View File

@@ -26,7 +26,7 @@ class CboeMajorIndicesHistoricalQueryParams(MajorIndicesHistoricalQueryParams):
"""
interval: Optional[Literal["1d", "1m"]] = Field(
description="Use interval, 1m, for intraday prices during the most recent trading period.",
description="Data granularity.",
default="1d",
)

View File

@@ -27,7 +27,7 @@ class CboeStockHistoricalQueryParams(StockHistoricalQueryParams):
"""
interval: Optional[Literal["1d", "1m"]] = Field(
description="Use interval, 1m, for intraday prices during the most recent trading period.",
description="Data granularity.",
default="1d",
)

View File

@@ -26,7 +26,7 @@ class FMPMajorIndicesHistoricalQueryParams(MajorIndicesHistoricalQueryParams):
)
interval: Literal[
"1min", "5min", "15min", "30min", "1hour", "4hour", "1day"
] = Field(default="1day", description="Interval of the data to fetch.")
] = Field(default="1day", description="Data granularity.")
class FMPMajorIndicesHistoricalData(MajorIndicesHistoricalData):

View File

@@ -26,7 +26,7 @@ class FMPStockHistoricalQueryParams(StockHistoricalQueryParams):
)
interval: Literal[
"1min", "5min", "15min", "30min", "1hour", "4hour", "1day"
] = Field(default="1day", description="Interval of the data to fetch.")
] = Field(default="1day", description="Data granularity.")
class FMPStockHistoricalData(StockHistoricalData):

View File

@@ -45,7 +45,7 @@ class IntrinioGlobalNewsData(GlobalNewsData):
"text": "summary",
}
id: str = Field(description="Intrinio ID for the news article.")
id: str = Field(description="Article ID.")
company: Dict[str, Any] = Field(
description="Company details related to the news article."
)

View File

@@ -273,23 +273,21 @@ class IntrinioOptionsChainsData(OptionsChainsData):
ask_high: Optional[float] = Field(
description="The highest ask price for the option that day."
)
open: Optional[float] = Field(description="The open price for the option that day.")
high: Optional[float] = Field(description="The high price for the option that day.")
low: Optional[float] = Field(description="The low price for the option that day.")
close: Optional[float] = Field(
description="The close price for the option that day."
)
open: Optional[float] = Field(description="Opening price of the option.")
high: Optional[float] = Field(description="High price of the option.")
low: Optional[float] = Field(description="Low price of the option.")
close: Optional[float] = Field(description="Close price for the option that day.")
implied_volatility: Optional[float] = Field(
description="The implied volatility for the option at the end of day."
description="Implied volatility of the option."
)
delta: Optional[float] = Field(description="The delta value at the end of day.")
gamma: Optional[float] = Field(description="The gamma value at the end of day.")
vega: Optional[float] = Field(description="The vega value at the end of day.")
theta: Optional[float] = Field(description="The theta value at the end of day.")
delta: Optional[float] = Field(description="Delta of the option.")
gamma: Optional[float] = Field(description="Gamma of the option.")
vega: Optional[float] = Field(description="Vega of the option.")
theta: Optional[float] = Field(description="Theta of the option.")
eod_date: Optional[dateType] = Field(
description="Historical date for which the options chains data is from.",
)
dte: Optional[int] = Field(description="The number of days until expiry.")
dte: Optional[int] = Field(description="Days to expiration for the option.")
@validator("expiration", pre=True, check_fields=False)
def date_validate(cls, v): # pylint: disable=E0213

View File

@@ -43,7 +43,7 @@ class IntrinioStockHistoricalQueryParams(StockHistoricalQueryParams):
)
limit: Optional[NonNegativeInt] = Field(
default=300,
description=f"{QUERY_DESCRIPTIONS.get('limit', '')}. Max value allowed is 300.",
description=f"{QUERY_DESCRIPTIONS.get('limit', '')}",
)
next_page: Optional[str] = Field(
description="Token to get the next page of data from a previous API call."

View File

@@ -54,7 +54,7 @@ class IntrinioStockNewsData(StockNewsData):
"text": "summary",
}
id: str = Field(description="Intrinio ID for the news article.")
id: str = Field(description="Article ID.")
@validator("publication_date", pre=True, check_fields=False)
def date_validate(cls, v): # pylint: disable=E0213

View File

@@ -33,7 +33,10 @@ class PolygonStockHistoricalQueryParams(StockHistoricalQueryParams):
limit: PositiveInt = Field(
default=49999, description=QUERY_DESCRIPTIONS.get("limit", "")
)
adjusted: bool = Field(default=True, description="Whether the data is adjusted.")
adjusted: bool = Field(
default=True,
description="Output time series is adjusted by historical split and dividend events.",
)
multiplier: PositiveInt = Field(
default=1, description="Multiplier of the timespan."
)

View File

@@ -23,38 +23,28 @@ class PolygonStockNewsQueryParams(StockNewsQueryParams):
class Config:
fields = {"symbols": "ticker"}
ticker_lt: Optional[str] = Field(
default=None, description="Less than, by default None"
)
ticker_lte: Optional[str] = Field(
default=None, description="Less than or equal, by default None"
)
ticker_gt: Optional[str] = Field(
default=None, description="Greater than, by default None"
)
ticker_lt: Optional[str] = Field(default=None, description="Less than.")
ticker_lte: Optional[str] = Field(default=None, description="Less than or equal.")
ticker_gt: Optional[str] = Field(default=None, description="Greater than.")
ticker_gte: Optional[str] = Field(
default=None, description="Greater than or equal, by default None"
default=None, description="Greater than or equal."
)
published_utc: Optional[str] = Field(
default=None, description="Published date of the query, by default None"
)
published_utc_lt: Optional[str] = Field(
default=None, description="Less than, by default None"
default=None, description="Published date of the query."
)
published_utc_lt: Optional[str] = Field(default=None, description="Less than.")
published_utc_lte: Optional[str] = Field(
default=None, description="Less than or equal, by default None"
)
published_utc_gt: Optional[str] = Field(
default=None, description="Greater than, by default None"
default=None, description="Less than or equal."
)
published_utc_gt: Optional[str] = Field(default=None, description="Greater than.")
published_utc_gte: Optional[str] = Field(
default=None, description="Greater than or equal, by default None"
default=None, description="Greater than or equal."
)
order: Optional[Literal["asc", "desc"]] = Field(
default=None, description="Sort order of the query, by default None"
default=None, description="Sort order of the query."
)
sort: Optional[str] = Field(
default=None, description="Sort of the query, by default None"
default=None, description="Order in which to sort the news."
)

View File

@@ -23,9 +23,7 @@ class YFinanceAvailableIndicesData(AvailableIndicesData):
code: str = Field(
description="ID code for keying the index in the OpenBB Terminal."
)
symbol: str = Field(
description="yFinance ticker symbol for the index.", alias="ticker"
)
symbol: str = Field(description="Symbol for the index.", alias="ticker")
class YFinanceAvailableIndicesFetcher(

View File

@@ -1,12 +1,13 @@
from dataclasses import dataclass, make_dataclass
from typing import Any, Dict, List, Literal, Optional, Tuple, Type, Union
from difflib import SequenceMatcher
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Type, Union
from fastapi import Query
from openbb_provider.query_executor import QueryExecutor
from openbb_provider.registry_map import MapType, RegistryMap
from openbb_provider.utils.helpers import to_snake_case
from pydantic import BaseConfig, BaseModel, Extra, Field, create_model
from pydantic.fields import ModelField
from pydantic.fields import FieldInfo, ModelField
from openbb_core.app.model.abstract.singleton import SingletonMeta
@@ -154,15 +155,33 @@ class ProviderInterface(metaclass=SingletonMeta):
) -> DataclassField:
current_name = current.name
current_type = current.type_
incoming_type = incoming.type_
current_desc = getattr(current.default, "description", "")
if query:
merged_default = Query(
default=current.default.default,
title=f"{current.default.title}, {incoming.default.title}",
)
incoming_type = incoming.type_
incoming_desc = getattr(incoming.default, "description", "")
F: Union[Callable, object] = Query if query else FieldInfo
def split_desc(desc: str) -> Tuple[str, str]:
"""Split field description"""
item = desc.split(" (provider: ")
detail = item[0] if item else ""
prov = item[-1].replace(")", "") if len(item) > 1 else ""
return detail, prov
curr_detail, curr_prov = split_desc(current_desc)
inc_detail, inc_prov = split_desc(incoming_desc)
if SequenceMatcher(None, curr_detail, inc_detail).ratio() > 0.8:
new_desc = f"{curr_detail} (provider: {curr_prov}, {inc_prov})"
else:
merged_default = current.default
new_desc = f"{current_desc}; {incoming_desc}"
merged_default = F( # type: ignore
default=current.default.default,
title=f"{current.default.title},{incoming.default.title}",
description=new_desc,
)
merged_type = (
Union[current_type, incoming_type]
@@ -256,13 +275,6 @@ class ProviderInterface(metaclass=SingletonMeta):
else:
updated = incoming
if not updated.default.title.startswith(
"Available for providers:"
):
updated.default.title = (
"Available for providers: " + updated.default.title
)
extra[updated.name] = (
updated.name,
updated.type_,
@@ -331,7 +343,7 @@ class ProviderInterface(metaclass=SingletonMeta):
pageSize: int = Query(default=15, title="benzinga")
displayOutput: int = Query(default="headline", title="benzinga")
...
sort: str = Query(default=None, title="benzinga, polygon")
sort: str = Query(default=None, title="benzinga,polygon")
"""
result: Dict = {}

View File

@@ -46,7 +46,7 @@ class Query:
for k, v in original.items():
f = fields[k]
providers = f.title.replace("Available for providers: ", "").split(", ")
providers = f.title.split(",")
if v != f.default:
if provider_name in providers:
filtered[k] = v