Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hotfix/Frontend sync #6327

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class EquityQuoteData(Data):
change_percent: Optional[float] = Field(
default=None,
description="Change in price as a normalized percentage.",
json_schema_extra={"x-frontendmultiply": 100},
json_schema_extra={"x-frontend_multiply": 100},
)
year_high: Optional[float] = Field(
default=None, description="The one year high (52W High)."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class EtfEquityExposureData(Data):
weight: Optional[float] = Field(
default=None,
description="The weight of the equity in the ETF, as a normalized percent.",
json_schema_extra={"units_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
market_value: Optional[Union[int, float]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class EUYieldCurveData(Data):
rate: Optional[float] = Field(
description="Yield curve rate, as a normalized percent.",
default=None,
json_schema_extra={"unit_measurement": "percent.", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class IndexHistoricalData(Data):

@field_validator("date", mode="before", check_fields=False)
@classmethod
def date_validate(cls, v):
def date_validate(cls, v): # pylint: disable=E0213
"""Return formatted datetime."""
if ":" in str(v):
return parser.isoparse(str(v))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,65 +33,65 @@ class TreasuryRatesData(Data):
week_4: Optional[float] = Field(
default=None,
description="4 week Treasury bills rate (secondary market).",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
month_1: Optional[float] = Field(
description="1 month Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
month_2: Optional[float] = Field(
description="2 month Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
month_3: Optional[float] = Field(
description="3 month Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
month_6: Optional[float] = Field(
description="6 month Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_1: Optional[float] = Field(
description="1 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_2: Optional[float] = Field(
description="2 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_3: Optional[float] = Field(
description="3 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_5: Optional[float] = Field(
description="5 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_7: Optional[float] = Field(
description="7 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_10: Optional[float] = Field(
description="10 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_20: Optional[float] = Field(
description="20 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
year_30: Optional[float] = Field(
description="30 year Treasury rate.",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ class BenzingaAnalystSearchData(AnalystSearchData):
overall_success_rate: Optional[float] = Field(
default=None,
description="The percentage (normalized) of gain/loss ratings that resulted in a gain overall.",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
overall_avg_return_percentile: Optional[float] = Field(
default=None,
description="The percentile (normalized) of this analyst's overall average"
+ " return per rating in comparison to other analysts' overall average returns per rating.",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
total_ratings_percentile: Optional[float] = Field(
default=None,
description="The percentile (normalized) of this analyst's total number of ratings"
+ " in comparison to the total number of ratings published by all other analysts",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
total_ratings: Optional[int] = Field(
default=None,
Expand All @@ -119,13 +119,13 @@ class BenzingaAnalystSearchData(AnalystSearchData):
overall_average_return: Optional[float] = Field(
default=None,
description="The average percent (normalized) price difference per rating since the date of recommendation",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
overall_std_dev: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings since the date of recommendation",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="overall_stdev",
)
gain_count_1m: Optional[int] = Field(
Expand All @@ -141,14 +141,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
average_return_1m: Optional[float] = Field(
default=None,
description="The average percent (normalized) price difference per rating over the last month",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="1m_average_return",
)
std_dev_1m: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last month",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="1m_stdev",
)
smart_score_1m: Optional[float] = Field(
Expand Down Expand Up @@ -176,14 +176,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 3 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="3m_average_return",
)
std_dev_3m: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 3 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="3m_stdev",
)
smart_score_3m: Optional[float] = Field(
Expand Down Expand Up @@ -211,14 +211,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 6 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="6m_average_return",
)
std_dev_6m: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 6 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="6m_stdev",
)
gain_count_9m: Optional[int] = Field(
Expand All @@ -235,14 +235,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 9 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="9m_average_return",
)
std_dev_9m: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 9 months",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="9m_stdev",
)
smart_score_9m: Optional[float] = Field(
Expand Down Expand Up @@ -270,14 +270,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 1 year",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="1y_average_return",
)
std_dev_1y: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 1 year",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="1y_stdev",
)
smart_score_1y: Optional[float] = Field(
Expand Down Expand Up @@ -305,14 +305,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 2 years",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="2y_average_return",
)
std_dev_2y: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 2 years",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="2y_stdev",
)
smart_score_2y: Optional[float] = Field(
Expand Down Expand Up @@ -340,14 +340,14 @@ class BenzingaAnalystSearchData(AnalystSearchData):
default=None,
description="The average percent (normalized) price difference per rating over"
+ " the last 3 years",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="3y_average_return",
)
std_dev_3y: Optional[float] = Field(
default=None,
description="The standard deviation in percent (normalized) price difference in the"
+ " analyst's ratings over the last 3 years",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
alias="3y_stdev",
)
smart_score_3y: Optional[float] = Field(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,26 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
Source: https://docs.benzinga.io/benzinga-apis/calendar/get-ratings
"""

# using __alias_dict__ for the aliasing of the fields instead of `Field` alias kwarg
# otherwise openapi schema shows as `parameters[date_from]` instead of `start_date`
__alias_dict__ = {
"limit": "pagesize",
"symbol": "parameters[tickers]",
"date": "parameters[date]",
"start_date": "parameters[date_from]",
"end_date": "parameters[date_to]",
"updated": "parameters[updated]",
"importance": "parameters[importance]",
"action": "parameters[action]",
"analyst_ids": "parameters[analyst_id]",
"firm_ids": "parameters[firm_id]",
}
__json_schema_extra__ = {
"symbol": ["multiple_items_allowed"],
"analyst_ids": ["multiple_items_allowed"],
"firm_ids": ["multiple_items_allowed"],
"fields": ["multiple_items_allowed"],
}
__json_schema_extra__ = {"symbol": ["multiple_items_allowed"]}

page: Optional[int] = Field(
default=0,
Expand All @@ -60,31 +75,26 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
date: Optional[dateType] = Field(
default=None,
description="Date for calendar data, shorthand for date_from and date_to.",
alias="parameters[date]",
)
start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
alias="parameters[date_from]",
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
alias="parameters[date_to]",
)
updated: Optional[Union[dateType, int]] = Field(
default=None,
description="Records last Updated Unix timestamp (UTC)."
+ " This will force the sort order to be Greater Than or Equal to the timestamp indicated."
+ " The date can be a date string or a Unix timestamp."
+ " The date string must be in the format of YYYY-MM-DD.",
alias="parameters[updated]",
)
importance: Optional[int] = Field(
default=None,
description="Importance level to filter by."
+ " Uses Greater Than or Equal To the importance indicated",
alias="parameters[importance]",
)
action: Optional[
Literal[
Expand All @@ -103,18 +113,15 @@ class BenzingaPriceTargetQueryParams(PriceTargetQueryParams):
] = Field(
default=None,
description="Filter by a specific action_company.",
alias="parameters[action]",
)
analyst_ids: Optional[Union[List[str], str]] = Field(
default=None,
description="Comma-separated list of analyst (person) IDs."
+ " Omitting will bring back all available analysts.",
alias="parameters[analyst_id]",
)
firm_ids: Optional[Union[List[str], str]] = Field(
default=None,
description="Comma-separated list of firm IDs.",
alias="parameters[firm_id]",
)
fields: Optional[Union[List[str], str]] = Field(
default=None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
amake_request,
get_querystring,
)
from openbb_fmp.utils.helpers import get_interval
from pydantic import Field
from openbb_fmp.utils.helpers import get_interval, parse_date
from pydantic import Field, field_validator


class FMPEquityHistoricalQueryParams(EquityHistoricalQueryParams):
Expand All @@ -43,6 +43,7 @@ class FMPEquityHistoricalQueryParams(EquityHistoricalQueryParams):
class FMPEquityHistoricalData(EquityHistoricalData):
"""FMP Equity Historical Price Data."""

symbol: Optional[str] = Field(default=None, description="Symbol of the equity.")
adj_close: Optional[float] = Field(
default=None, description=DATA_DESCRIPTIONS.get("adj_close", "")
)
Expand All @@ -60,6 +61,11 @@ class FMPEquityHistoricalData(EquityHistoricalData):
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)

@field_validator("date", mode="before", check_fields=False)
def date_validate(cls, v): # pylint: disable=E0213
"""Return formatted datetime."""
return parse_date(v, "America/New_York")


class FMPEquityHistoricalFetcher(
Fetcher[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class FMPEtfHoldingsData(EtfHoldingsData):
description="The weight of the holding, as a normalized percent.",
alias="pctVal",
default=None,
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
payoff_profile: Optional[str] = Field(
description="The payoff profile of the holding.",
Expand Down
Loading
Loading