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 11 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},
)
45 changes: 27 additions & 18 deletions openbb_platform/core/tests/app/logs/test_handlers_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,24 @@ class MockFormatterWithExceptions(logging.Formatter):
def __init__(self, settings):
"""Initialize the formatter."""
self.settings = settings
self._style = logging.PercentStyle


def test_handlers_added_correctly():
"""Test if the handlers are added correctly."""
with patch(
"openbb_core.app.logs.handlers_manager.PosthogHandler",
MockPosthogHandler,
), patch(
"openbb_core.app.logs.handlers_manager.PathTrackingFileHandler",
MockPathTrackingFileHandler,
), patch(
"openbb_core.app.logs.handlers_manager.FormatterWithExceptions",
MockFormatterWithExceptions,
with (
patch(
"openbb_core.app.logs.handlers_manager.PosthogHandler",
MockPosthogHandler,
),
patch(
"openbb_core.app.logs.handlers_manager.PathTrackingFileHandler",
MockPathTrackingFileHandler,
),
patch(
"openbb_core.app.logs.handlers_manager.FormatterWithExceptions",
MockFormatterWithExceptions,
),
):
settings = Mock()
settings.handler_list = ["stdout", "stderr", "noop", "file", "posthog"]
Expand All @@ -75,15 +80,19 @@ def test_handlers_added_correctly():

def test_update_handlers():
"""Test if the handlers are updated correctly."""
with patch(
"openbb_core.app.logs.handlers_manager.PosthogHandler",
MockPosthogHandler,
), patch(
"openbb_core.app.logs.handlers_manager.PathTrackingFileHandler",
MockPathTrackingFileHandler,
), patch(
"openbb_core.app.logs.handlers_manager.FormatterWithExceptions",
MockFormatterWithExceptions,
with (
patch(
"openbb_core.app.logs.handlers_manager.PosthogHandler",
MockPosthogHandler,
),
patch(
"openbb_core.app.logs.handlers_manager.PathTrackingFileHandler",
MockPathTrackingFileHandler,
),
patch(
"openbb_core.app.logs.handlers_manager.FormatterWithExceptions",
MockFormatterWithExceptions,
),
):
settings = Mock()
settings.handler_list = ["file", "posthog"]
Expand Down
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
Loading
Loading