diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-07 23:15:08 -0700 |
---|---|---|
committer | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-06-07 23:15:08 -0700 |
commit | 3ed1f5907b19849652bdc44ba26770d926215b08 (patch) | |
tree | 313f5081255a104fb90e8d0d314f937c62afa6a4 | |
parent | d558b7936702bb46d5d8602da19bdab131e54b31 (diff) |
update sofr and add federal_reserve to endpoint
17 files changed, 1926 insertions, 370 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/sofr.py b/openbb_platform/core/openbb_core/provider/standard_models/sofr.py new file mode 100644 index 00000000000..d15bee0aebe --- /dev/null +++ b/openbb_platform/core/openbb_core/provider/standard_models/sofr.py @@ -0,0 +1,65 @@ +"""Secured Overnight Financing Rate 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 SOFRQueryParams(QueryParams): + """Secured Overnight Financing Rate 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 SOFRData(Data): + """SOFR Data.""" + + date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) + rate: float = Field( + description="Effective federal funds rate.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) + percentile_1: Optional[float] = Field( + default=None, + description="1st percentile of the distribution.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) + percentile_25: Optional[float] = Field( + default=None, + description="25th percentile of the distribution.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) + percentile_75: Optional[float] = Field( + default=None, + description="75th percentile of the distribution.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) + percentile_99: Optional[float] = Field( + default=None, + description="99th percentile of the distribution.", + json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100}, + ) + volume: Optional[float] = Field( + default=None, + description=DATA_DESCRIPTIONS.get("volume", "") + + "The notional volume of transactions (Billions of $).", + json_schema_extra={ + "x-unit_measurement": "currency", + "x-frontend_multiply": 1e9, + }, + ) diff --git a/openbb_platform/core/openbb_core/provider/standard_models/sofr_rates.py b/openbb_platform/core/openbb_core/provider/standard_models/sofr_rates.py deleted file mode 100644 index 2d7043a604d..00000000000 --- a/openbb_platform/core/openbb_core/provider/standard_models/sofr_rates.py +++ /dev/null @@ -1,33 +0,0 @@ -"""SOFR 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 SOFRQueryParams(QueryParams): - """SOFR 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 SOFRData(Data): - """SOFR Data.""" - - date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", "")) - rate: Optional[float] = Field(description="SOFR rate.") diff --git a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py index 0aff9d260ad..a24f4147a33 100644 --- a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py +++ b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py @@ -60,10 +60,18 @@ def test_fixedincome_government_us_yield_curve(params, headers): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06"}), ( { - "period": "overnight", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "provider": "federal_reserve", + } + ), + ( + { + "frequency": None, + "transform": None, + "aggregation_method": None, "provider": "fred", "start_date": "2023-01-01", "end_date": "2023-06-06", @@ -86,10 +94,18 @@ def test_fixedincome_sofr(params, headers): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06"}), ( { - "period": "overnight", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "provider": "federal_reserve", + } + ), + ( + { + "frequency": None, + "transform": None, + "aggregation_method": None, "provider": "fred", "start_date": "2023-01-01", "end_date": "2023-06-06", diff --git a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py index 3d1113fcde3..4376652a20a 100644 --- a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py +++ b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py @@ -51,10 +51,18 @@ def test_fixedincome_government_us_yield_curve(params, obb): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06"}), ( { - "period": "overnight", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "provider": "federal_reserve", + } + ), + ( + { + "frequency": None, + "transform": None, + "aggregation_method": None, "provider": "fred", "start_date": "2023-01-01", "end_date": "2023-06-06", @@ -74,10 +82,18 @@ def test_fixedincome_sofr(params, obb): @parametrize( "params", [ - ({"start_date": "2023-01-01", "end_date": "2023-06-06"}), ( { - "period": "overnight", + "start_date": "2023-01-01", + "end_date": "2023-06-06", + "provider": "federal_reserve", + } + ), + ( + { + "frequency": None, + "transform": None, + "aggregation_method": None, "provider": "fred", "start_date": "2023-01-01", "end_date": "2023-06-06", diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index fdf5c86fe70..ae90ec2747d 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -30092,20 +30092,64 @@ }, { "name": "provider", - "type": "Literal['fred']", - "description": "The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: f, r, e, d.", + "type": "Literal['federal_reserve', 'fred']", + "description": "The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: f, e, d, e, r, a, l, _, r, e, s, e, r, v, e.", "default": null, "optional": true } ], + "federal_reserve": [], "fred": [ { - "name": "period", - "type": "Literal['overnight', '30_day', '90_day', '180_day', 'index']", - "description": "Period of SOFR rate.", - "default": "overnight", + "name": "frequency", + "type": "Literal['a', 'q', 'm', 'w', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']", + "description": "Frequency aggregation to convert daily data to lower frequency. a = Annual q = Quarterly m = Monthly w = Weekly wef = Weekly, Ending Friday weth = Weekly, Ending Thursday wew = Weekly, Ending Wednesday wetu = Weekly, Ending Tuesday wem = Weekly, Ending Monday wesu = Weekly, Ending Sunday wesa = Weekly, Ending Saturday bwew = Biweekly, Ending Wednesday bwem = Biweekly, Ending Monday", + "default": null, "optional": true, - "choices": null + "choices": [ + "a", + "q", + "m", + "w", + "wef", + "weth", + "wew", + "wetu", + "wem", + "wesu", + "wesa", + "bwew", + "bwem" + ] + }, + { + "name": "aggregation_method", + "type": "Literal['avg', 'sum', 'eop']", + "description": "A key that indicates the aggregation method used for frequency aggregation. avg = Average sum = Sum eop = End of Period", + "default": null, + "optional": true, + "choices": [ + "avg", + "sum", + "eop" + ] + }, + { + "name": "transform", + "type": "Literal['chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log']", + "description": "Transformation type None = No transformation chg = Change ch1 = Change from Year Ago pch = Percent Change pc1 = Percent Change from Year Ago pca = Compounded Annual Rate of Change cch = Continuously Compounded Rate of Change cca = Continuously Compounded Annual Rate of Change log = Natural Log", + "default": null, + "optional": true, + "choices": [ + "chg", + "ch1", + "pch", + "pc1", + "pca", + "cch", + "cca", + "log" + ] } ] }, @@ -30118,7 +30162,7 @@ }, { "name": "provider", - "type": "Optional[Literal['fred']]", + "type": "Optional[Literal['federal_reserve', 'fred']]", "description": "Provider name." }, { @@ -30151,13 +30195,87 @@ { "name": "rate", "type": "float", - "description": "SOFR rate.", + "description": "Effective federal funds rate.", "default": "", "optional": false, "choices": null + }, + { + "name": "percentile_1", + "type": "float", + "description": "1st percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_25", + "type": "float", + "description": "25th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_75", + "type": "float", + "description": "75th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_99", + "type": "float", + "description": "99th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "volume", + "type": "float", + "description": "The trading volume.The notional volume of transactions (Billions of $).", + "default": null, + "optional": true, + "choices": null } ], - "fred": [] + "federal_reserve": [], + "fred": [ + { + "name": "average_30d", + "type": "float", + "description": "30-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "average_90d", + "type": "float", + "description": "90-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "average_180d", + "type": "float", + "description": "180-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "index", + "type": "float", + "description": "SOFR index as 2018-04-02 = 1", + "default": null, + "optional": true, + "choices": null + } + ] }, "model": "SOFR" }, @@ -32274,20 +32392,64 @@ }, { "name": "provider", - "type": "Literal['fred']", - "description": "The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: f, r, e, d.", + "type": "Literal['federal_reserve', 'fred']", + "description": "The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: f, e, d, e, r, a, l, _, r, e, s, e, r, v, e.", "default": null, "optional": true } ], + "federal_reserve": [], "fred": [ { - "name": "period", - "type": "Literal['overnight', '30_day', '90_day', '180_day', 'index']", - "description": "Period of SOFR rate.", - "default": "overnight", + "name": "frequency", + "type": "Literal['a', 'q', 'm', 'w', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']", + "description": "Frequency aggregation to convert daily data to lower frequency. a = Annual q = Quarterly m = Monthly w = Weekly wef = Weekly, Ending Friday weth = Weekly, Ending Thursday wew = Weekly, Ending Wednesday wetu = Weekly, Ending Tuesday wem = Weekly, Ending Monday wesu = Weekly, Ending Sunday wesa = Weekly, Ending Saturday bwew = Biweekly, Ending Wednesday bwem = Biweekly, Ending Monday", + "default": null, "optional": true, - "choices": null + "choices": [ + "a", + "q", + "m", + "w", + "wef", + "weth", + "wew", + "wetu", + "wem", + "wesu", + "wesa", + "bwew", + "bwem" + ] + }, + { + "name": "aggregation_method", + "type": "Literal['avg', 'sum', 'eop']", + "description": "A key that indicates the aggregation method used for frequency aggregation. avg = Average sum = Sum eop = End of Period", + "default": null, + "optional": true, + "choices": [ + "avg", + "sum", + "eop" + ] + }, + { + "name": "transform", + "type": "Literal['chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log']", + "description": "Transformation type None = No transformation chg = Change ch1 = Change from Year Ago pch = Percent Change pc1 = Percent Change from Year Ago pca = Compounded Annual Rate of Change cch = Continuously Compounded Rate of Change cca = Continuously Compounded Annual Rate of Change log = Natural Log", + "default": null, + "optional": true, + "choices": [ + "chg", + "ch1", + "pch", + "pc1", + "pca", + "cch", + "cca", + "log" + ] } ] }, @@ -32300,7 +32462,7 @@ }, { "name": "provider", - "type": "Optional[Literal['fred']]", + "type": "Optional[Literal['federal_reserve', 'fred']]", "description": "Provider name." }, { @@ -32333,13 +32495,87 @@ { "name": "rate", "type": "float", - "description": "SOFR rate.", + "description": "Effective federal funds rate.", "default": "", "optional": false, "choices": null + }, + { + "name": "percentile_1", + "type": "float", + "description": "1st percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_25", + "type": "float", + "description": "25th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_75", + "type": "float", + "description": "75th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "percentile_99", + "type": "float", + "description": "99th percentile of the distribution.", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "volume", + "type": "float", + "description": "The trading volume.The notional volume of transactions (Billions of $).", + "default": null, + "optional": true, + "choices": null } ], - "fred": [] + "federal_reserve": [], + "fred": [ + { + "name": "average_30d", + "type": "float", + "description": "30-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "average_90d", + "type": "float", + "description": "90-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "average_180d", + "type": "float", + "description": "180-Day Average SOFR", + "default": null, + "optional": true, + "choices": null + }, + { + "name": "index", + "type": "float", + "description": "SOFR index as 2018-04-02 = 1", + "default": null, + "optional": true, + "choices": null + } + ] }, "model": "SOFR" }, diff --git a/openbb_platform/openbb/package/fixedincome.py b/openbb_platform/openbb/package/fixedincome.py index f3cd57ca0a8..a7e043d10b5 100644 --- a/openbb_platform/openbb/package/fixedincome.py +++ b/openbb_platform/openbb/package/fixedincome.py @@ -212,9 +212,9 @@ class ROUTER_fixedincome(Container): OpenBBField(description="End date of the data, in YYYY-MM-DD format."), ] = None, provider: Annotated[ - Optional[Literal["fred"]], + Optional[Literal["federal_reserve", "fred"]], OpenBBField( - description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fred." + description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: federal_reserve, fred." ), ] = None, **kwargs @@ -231,17 +231,52 @@ class ROUTER_fixedincome(Container): Start date of the data, in YYYY-MM-DD format. end_date : Union[datetime.date, None, str] End date of the data, in YYYY-MM-DD format. - provider : Optional[Literal['fred']] - The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fred. - period : Literal['overnight', '30_day', '90_day', '180_day', 'index'] - Period of SOFR rate. (provider: fred) + provider : Optional[Literal['federal_reserve', 'fred']] + The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: federal_reserve, fred. + frequency : Optional[Literal['a', 'q', 'm', 'w', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']] + + Frequency aggregation to convert daily data to lower frequency. + a = Annual + q = Quarterly + m = Monthly + w = Weekly + wef = Weekly, Ending Friday + weth = Weekly, Ending Thursday + |