Skip to content

Commit

Permalink
[Feature] Adds Router Path For Economic Surveys (#6498)
Browse files Browse the repository at this point in the history
* add router path for economic surveys

* chicago economic conditions

* reference.json

* add manufacturing outlook survey for texas

* test file name

---------

Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
  • Loading branch information
deeleeramone and IgorWounds authored Jun 17, 2024
1 parent 5ec2db7 commit 6445b97
Show file tree
Hide file tree
Showing 21 changed files with 4,546 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""Manufacturing Outlook - Texas - Standard Model."""

from datetime import (
date as dateType,
)
from typing import Optional

from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class ManufacturingOutlookTexasQueryParams(QueryParams):
"""Manufacturing Outlook - Texas - Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class ManufacturingOutlookTexasData(Data):
"""Manufacturing Outlook - Texas - Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
topic: Optional[str] = Field(
default=None, description="Topic of the survey response."
)
diffusion_index: Optional[float] = Field(
default=None, description="Diffusion Index."
)
percent_reporting_increase: Optional[float] = Field(
default=None,
description="Percent of respondents reporting an increase over the last month.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percent_reporting_decrease: Optional[float] = Field(
default=None,
description="Percent of respondents reporting a decrease over the last month.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
percent_reporting_no_change: Optional[float] = Field(
default=None,
description="Percent of respondents reporting no change over the last month.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Senior Loan Officer Opinion Survey Standard Model."""

from datetime import (
date as dateType,
)
from typing import Optional

from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class SeniorLoanOfficerSurveyQueryParams(QueryParams):
"""Senior Loan Officer Opinion Survey Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class SeniorLoanOfficerSurveyData(Data):
"""Senior Loan Officer Opinion Survey Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
symbol: Optional[str] = Field(
default=None, description=DATA_DESCRIPTIONS.get("symbol", "")
)
value: float = Field(description="Survey value.")
title: Optional[str] = Field(description="Survey title.")
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Survey Of Economic Conditions - Chicago - Standard Model."""

from datetime import (
date as dateType,
)
from typing import Optional

from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class SurveyOfEconomicConditionsChicagoQueryParams(QueryParams):
"""Survey Of Economic Conditions - Chicago - Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class SurveyOfEconomicConditionsChicagoData(Data):
"""Survey Of Economic Conditions - Chicago - Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
activity_index: Optional[float] = Field(default=None, description="Activity Index.")
one_year_outlook: Optional[float] = Field(
default=None, description="One Year Outlook Index."
)
manufacturing_activity: Optional[float] = Field(
default=None, description="Manufacturing Activity Index."
)
non_manufacturing_activity: Optional[float] = Field(
default=None, description="Non-Manufacturing Activity Index."
)
capital_expenditures_expectations: Optional[float] = Field(
default=None, description="Capital Expenditures Expectations Index."
)
hiring_expectations: Optional[float] = Field(
default=None, description="Hiring Expectations Index."
)
current_hiring: Optional[float] = Field(
default=None, description="Current Hiring Index."
)
labor_costs: Optional[float] = Field(default=None, description="Labor Costs Index.")
non_labor_costs: Optional[float] = Field(
default=None, description="Non-Labor Costs Index."
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""University Of Michigan Survey Standard Model."""

from datetime import (
date as dateType,
)
from typing import Optional

from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class UofMichiganQueryParams(QueryParams):
"""University Of Michigan Survey Query."""

start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)


class UofMichiganData(Data):
"""University Of Michigan Survey Data."""

date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
consumer_sentiment: Optional[float] = Field(
default=None,
description="Index of the results of the University of Michigan's monthly Survey of Consumers,"
+ " which is used to estimate future spending and saving. (1966:Q1=100).",
)
inflation_expectation: Optional[float] = Field(
default=None,
description="Median expected price change next 12 months, Surveys of Consumers.",
json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
109 changes: 109 additions & 0 deletions openbb_platform/extensions/economy/integration/test_economy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,3 +815,112 @@ def test_economy_retail_prices(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"frequency": None,
"provider": "fred",
"start_date": "2022-01-01",
"end_date": "2024-04-01",
"transform": None,
"aggregation_method": None,
}
),
],
)
@pytest.mark.integration
def test_economy_survey_university_of_michigan(params, headers):
"""Test the economy survey university_of_michigan endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = (
f"http://0.0.0.0:8000/api/v1/economy/survey/university_of_michigan?{query_str}"
)
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"category": "auto",
"provider": "fred",
"start_date": "2022-01-01",
"end_date": "2024-04-01",
}
),
],
)
@pytest.mark.integration
def test_economy_survey_sloos(params, headers):
"""Test the economy survey sloos endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/economy/survey/sloos?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"provider": "fred",
"start_date": "2024-01-01",
"end_date": "2024-04-01",
"transform": None,
"aggregation_method": None,
"frequency": None,
}
),
],
)
@pytest.mark.integration
def test_economy_survey_economic_conditions_chicago(params, headers):
"""Test the economy survey economic_conditions_chicago endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/economy/survey/economic_conditions_chicago?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"provider": "fred",
"topic": "business_outlook,new_orders",
"start_date": "2024-01-01",
"end_date": "2024-04-01",
"transform": None,
"aggregation_method": None,
"frequency": None,
}
),
],
)
@pytest.mark.integration
def test_economy_survey_manufacturing_outlook_texas(params, headers):
"""Test the economy survey manufacturing outlook texas endpoint"""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/economy/survey/manufacturing_outlook_texas?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Loading

0 comments on commit 6445b97

Please sign in to comment.