summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-03-15 05:24:55 -0700
committerGitHub <noreply@github.com>2024-03-15 12:24:55 +0000
commit46f4834cb222a4cd425a172f4e6620ff822f54a7 (patch)
treec4f337a4a495f691be34a6c024362eae2e1a450e
parent9b0d34076fa73bded605f3dd3116c290b29d68f5 (diff)
[Feature] Intrinio ETF Price Performance (#6220)
* remap to etf router * add the intrinio files this time * update standard model * the rest of the changes * static files * black * pylint * test thing * black * fix test? * try another way? * ruff * maybe? * new cassette?
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/recent_performance.py104
-rw-r--r--openbb_platform/extensions/etf/integration/test_etf_api.py8
-rw-r--r--openbb_platform/extensions/etf/integration/test_etf_python.py8
-rw-r--r--openbb_platform/extensions/etf/openbb_etf/etf_router.py4
-rw-r--r--openbb_platform/openbb/assets/reference.json224
-rw-r--r--openbb_platform/openbb/package/etf.py72
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/__init__.py1
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/price_performance.py13
-rw-r--r--openbb_platform/providers/fmp/openbb_fmp/__init__.py1
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/__init__.py4
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/models/etf_price_performance.py227
-rw-r--r--openbb_platform/providers/intrinio/openbb_intrinio/utils/references.py33
-rw-r--r--openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_etf_price_performance_fetcher.yaml82
-rw-r--r--openbb_platform/providers/intrinio/tests/test_intrinio_fetchers.py12
14 files changed, 726 insertions, 67 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/recent_performance.py b/openbb_platform/core/openbb_core/provider/standard_models/recent_performance.py
index 37314e80c50..3955e4eacd7 100644
--- a/openbb_platform/core/openbb_core/provider/standard_models/recent_performance.py
+++ b/openbb_platform/core/openbb_core/provider/standard_models/recent_performance.py
@@ -6,7 +6,10 @@ from pydantic import Field, field_validator
from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
-from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
+from openbb_core.provider.utils.descriptions import (
+ DATA_DESCRIPTIONS,
+ QUERY_DESCRIPTIONS,
+)
class RecentPerformanceQueryParams(QueryParams):
@@ -22,23 +25,88 @@ class RecentPerformanceQueryParams(QueryParams):
class RecentPerformanceData(Data):
- """Recent Performance Data."""
-
- one_day: Optional[float] = Field(description="One-day return.", default=None)
- wtd: Optional[float] = Field(description="Week to date return.", default=None)
- one_week: Optional[float] = Field(description="One-week return.", default=None)
- mtd: Optional[float] = Field(description="Month to date return.", default=None)
- one_month: Optional[float] = Field(description="One-month return.", default=None)
- qtd: Optional[float] = Field(description="Quarter to date return.", default=None)
+ """Recent Performance Data. All returns are normalized percents."""
+
+ symbol: Optional[str] = Field(
+ default=None, description=DATA_DESCRIPTIONS.get("symbol", "")
+ )
+ one_day: Optional[float] = Field(
+ default=None,
+ description="One-day return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ wtd: Optional[float] = Field(
+ default=None,
+ description="Week to date return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ one_week: Optional[float] = Field(
+ default=None,
+ description="One-week return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ mtd: Optional[float] = Field(
+ default=None,
+ description="Month to date return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ one_month: Optional[float] = Field(
+ default=None,
+ description="One-month return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ qtd: Optional[float] = Field(
+ default=None,
+ description="Quarter to date return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
three_month: Optional[float] = Field(
- description="Three-month return.", default=None
- )
- six_month: Optional[float] = Field(description="Six-month return.", default=None)
- ytd: Optional[float] = Field(description="Year to date return.", default=None)
- one_year: Optional[float] = Field(description="One-year return.", default=None)
- three_year: Optional[float] = Field(description="Three-year return.", default=None)
- five_year: Optional[float] = Field(description="Five-year return.", default=None)
- ten_year: Optional[float] = Field(description="Ten-year return.", default=None)
+ default=None,
+ description="Three-month return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ six_month: Optional[float] = Field(
+ default=None,
+ description="Six-month return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ ytd: Optional[float] = Field(
+ default=None,
+ description="Year to date return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ one_year: Optional[float] = Field(
+ default=None,
+ description="One-year return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ two_year: Optional[float] = Field(
+ default=None,
+ description="Two-year return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ three_year: Optional[float] = Field(
+ default=None,
+ description="Three-year return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ four_year: Optional[float] = Field(
+ default=None,
+ description="Four-year",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ five_year: Optional[float] = Field(
+ default=None,
+ description="Five-year return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
+ ten_year: Optional[float] = Field(
+ default=None,
+ description="Ten-year return.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
+ )
max: Optional[float] = Field(
- description="Return from the beginning of the time series.", default=None
+ default=None,
+ description="Return from the beginning of the time series.",
+ json_schema_extra={"x-unit_measurement": "percent", "x-frontend_multiply": 100},
)
diff --git a/openbb_platform/extensions/etf/integration/test_etf_api.py b/openbb_platform/extensions/etf/integration/test_etf_api.py
index b53b4bfb2b1..d0b03385a36 100644
--- a/openbb_platform/extensions/etf/integration/test_etf_api.py
+++ b/openbb_platform/extensions/etf/integration/test_etf_api.py
@@ -351,6 +351,14 @@ def test_etf_holdings(params, headers):
[
({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"}),
({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "finviz"}),
+ (
+ {
+ "symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK",
+ "return_type": "trailing",
+ "adjustment": "splits_and_dividends",
+ "provider": "intrinio",
+ }
+ ),
],
)
@pytest.mark.integration
diff --git a/openbb_platform/extensions/etf/integration/test_etf_python.py b/openbb_platform/extensions/etf/integration/test_etf_python.py
index 6f76921edb5..417c4eae3a9 100644
--- a/openbb_platform/extensions/etf/integration/test_etf_python.py
+++ b/openbb_platform/extensions/etf/integration/test_etf_python.py
@@ -342,6 +342,14 @@ def test_etf_holdings(params, obb):
[
({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"}),
({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "finviz"}),
+ (
+ {
+ "symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK",
+ "return_type": "trailing",
+ "adjustment": "splits_and_dividends",
+ "provider": "intrinio",
+ }
+ ),
],
)
@pytest.mark.integration
diff --git a/openbb_platform/extensions/etf/openbb_etf/etf_router.py b/openbb_platform/extensions/etf/openbb_etf/etf_router.py
index caa8c90938b..3476644510d 100644
--- a/openbb_platform/extensions/etf/openbb_etf/etf_router.py
+++ b/openbb_platform/extensions/etf/openbb_etf/etf_router.py
@@ -116,7 +116,7 @@ async def countries(
@router.command(
- model="PricePerformance",
+ model="EtfPricePerformance",
examples=[
APIEx(parameters={"symbol": "QQQ", "provider": "fmp"}),
APIEx(parameters={"symbol": "SPY,QQQ,IWM,DJIA", "provider": "fmp"}),
@@ -128,7 +128,7 @@ async def price_performance(
standard_params: StandardParams,
extra_params: ExtraParams,
) -> OBBject:
- """Price performance as a return, over different periods. This is a proxy for `equity.price.performance`."""
+ """Price performance as a return, over different periods."""
return await OBBject.from_query(Query(**locals()))
diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json
index bdbae0cf973..beb7f8439a4 100644
--- a/openbb_platform/openbb/assets/reference.json
+++ b/openbb_platform/openbb/assets/reference.json
@@ -17730,6 +17730,13 @@
"data": {
"standard": [
{
+ "name": "symbol",
+ "type": "str",
+ "description": "Symbol representing the entity requested in the data.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "one_day",
"type": "float",
"description": "One-day return.",
@@ -17800,6 +17807,13 @@
"optional": true
},
{
+ "name": "two_year",
+ "type": "float",
+ "description": "Two-year return.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "three_year",
"type": "float",
"description": "Three-year return.",
@@ -17807,6 +17821,13 @@
"optional": true
},
{
+ "name": "four_year",
+ "type": "float",
+ "description": "Four-year",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "five_year",
"type": "float",
"description": "Five-year return.",
@@ -17828,15 +17849,7 @@
"optional": true
}
],
- "fmp": [
- {
- "name": "symbol",
- "type": "str",
- "description": "The ticker symbol.",
- "default": "",
- "optional": false
- }
- ]
+ "fmp": []
},
"model": "PricePerformance"
},
@@ -21252,37 +21265,53 @@
"flag": null,
"message": null
},
- "description": "Price performance as a return, over different periods. This is a proxy for `equity.price.performance`.",
+ "description": "Price performance as a return, over different periods.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.etf.price_performance(symbol='QQQ', provider='fmp')\nobb.etf.price_performance(symbol='SPY,QQQ,IWM,DJIA', provider='fmp')\n```\n\n",
"parameters": {
"standard": [
{
"name": "symbol",
"type": "Union[str, List[str]]",
- "description": "Symbol to get data for. Multiple items allowed for provider(s): fmp.",
+ "description": "Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio.",
"default": "",
"optional": false
},
{
"name": "provider",
- "type": "Literal['fmp']",
+ "type": "Literal['fmp', 'intrinio']",
"description": "The provider to use for the query, by default None. If None, the provider specified in defaults is selected or 'fmp' if there is no default.",
"default": "fmp",
"optional": true
}
],
- "fmp": []
+ "fmp": [],
+ "intrinio": [
+ {
+ "name": "return_type",
+ "type": "Literal['trailing', 'calendar']",
+ "description": "The type of returns to return, a trailing or calendar window.",
+ "default": "trailing",
+ "optional": true
+ },
+ {
+ "name": "adjustment",
+ "type": "Literal['splits_only', 'splits_and_dividends']",
+ "description": "The adjustment factor, 'splits_only' will return pure price performance.",
+ "default": "splits_and_dividends",
+ "optional": true
+ }
+ ]
},
"returns": {
"OBBject": [
{
"name": "results",
- "type": "List[PricePerformance]",
+ "type": "List[EtfPricePerformance]",
"description": "Serializable results."
},
{
"name": "provider",
- "type": "Optional[Literal['fmp']]",
+ "type": "Optional[Literal['fmp', 'intrinio']]",
"description": "Provider name."
},
{
@@ -21305,6 +21334,13 @@
"data": {
"standard": [
{
+ "name": "symbol",
+ "type": "str",
+ "description": "Symbol representing the entity requested in the data.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "one_day",
"type": "float",
"description": "One-day return.",
@@ -21375,6 +21411,13 @@
"optional": true
},
{
+ "name": "two_year",
+ "type": "float",
+ "description": "Two-year return.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "three_year",
"type": "float",
"description": "Three-year return.",
@@ -21382,6 +21425,13 @@
"optional": true
},
{
+ "name": "four_year",
+ "type": "float",
+ "description": "Four-year",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "five_year",
"type": "float",
"description": "Five-year return.",
@@ -21403,17 +21453,116 @@
"optional": true
}
],
- "fmp": [
+ "fmp": [],
+ "intrinio": [
{
- "name": "symbol",
- "type": "str",
- "description": "The ticker symbol.",
- "default": "",
- "optional": false
+ "name": "max_annualized",
+ "type": "float",
+ "description": "Annualized rate of return from inception.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volatility_one_year",
+ "type": "float",
+ "description": "Trailing one-year annualized volatility.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volatility_three_year",
+ "type": "float",
+ "description": "Trailing three-year annualized volatility.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volatility_five_year",
+ "type": "float",
+ "description": "Trailing five-year annualized volatility.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volume",
+ "type": "int",
+ "description": "The trading volume.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volume_avg_30",
+ "type": "float",
+ "description": "The one-month average daily volume.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volume_avg_90",
+ "type": "float",
+ "description": "The three-month average daily volume.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "volume_avg_180",
+ "type": "float",
+ "description": "The six-month average daily volume.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "beta",
+ "type": "float",
+ "description": "Beta compared to the S&P 500.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "nav",
+ "type": "float",
+ "description": "Net asset value per share.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "year_high",
+ "type": "float",
+ "description": "The 52-week high price.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "year_low",
+ "type": "float",
+ "description": "The 52-week low price.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "market_cap",
+ "type": "float",
+ "description": "The market capitalization.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "shares_outstanding",
+ "type": "int",
+ "description": "The number of shares outstanding.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "updated",
+ "type": "date",
+ "description": "The date of the data.",
+ "default": null,
+ "optional": true
}
]
},
- "model": "PricePerformance"
+ "model": "EtfPricePerformance"
},
"/etf/holdings": {
"deprecated": {
@@ -22318,6 +22467,13 @@
"data": {
"standard": [
{
+ "name": "symbol",
+ "type": "str",
+ "description": "Symbol representing the entity requested in the data.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "one_day",
"type": "float",
"description": "One-day return.",
@@ -22388,6 +22544,13 @@
"optional": true
},
{
+ "name": "two_year",
+ "type": "float",
+ "description": "Two-year return.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "three_year",
"type": "float",
"description": "Three-year return.",
@@ -22395,6 +22558,13 @@
"optional": true
},
{
+ "name": "four_year",
+ "type": "float",
+ "description": "Four-year",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "five_year",
"type": "float",
"description": "Five-year return.",
@@ -22416,15 +22586,7 @@
"optional": true
}
],
- "fmp": [
- {
- "name": "symbol",
- "type": "str",
- "description": "The ticker symbol.",
- "default": "",
- "optional": false
- }
- ]
+ "fmp": []
},
"model": "EtfHoldingsPerformance"
},
diff --git a/openbb_platform/openbb/package/etf.py b/openbb_platform/openbb/package/etf.py
index 663014c576d..74703b23143 100644
--- a/openbb_platform/openbb/package/etf.py
+++ b/openbb_platform/openbb/package/etf.py
@@ -716,6 +716,8 @@ class ROUTER_etf(Container):
EtfHoldingsPerformance
----------------------
+ symbol : Optional[str]
+ Symbol representing the entity requested in the data.
one_day : Optional[float]
One-day return.
wtd : Optional[float]
@@ -736,16 +738,18 @@ class ROUTER_etf(Container):
Year to date return.
one_year : Optional[float]
One-year return.
+ two_year : Optional[float]
+ Two-year return.
three_year : Optional[float]
Three-year return.
+ four_year : Optional[float]
+ Four-year
five_year : Optional[float]
Five-year return.
ten_year : Optional[float]
Ten-year return.
max : Optional[float]
Return from the beginning of the time series.
- symbol : Optional[str]
- The ticker symbol. (provider: fmp)
Examples
--------
@@ -1170,34 +1174,38 @@ class ROUTER_etf(Container):
symbol: Annotated[
Union[str, List[str]],
OpenBBCustomParameter(
- description="Symbol to get data for. Multiple items allowed for provider(s): fmp."
+ description="Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio."
),
],
provider: Annotated[
- Optional[Literal["fmp"]],
+ Optional[Literal["fmp", "intrinio"]],
OpenBBCustomParameter(
description="The provider to use for the query, by default None.\n If None, the provider specified in defaults is selected or 'fmp' if there is\n no default."
),
] = None,
**kwargs
) -> OBBject:
- """Price performance as a return, over different periods. This is a proxy for `equity.price.performance`.
+ """Price performance as a return, over different periods.
Parameters
----------
symbol : Union[str, List[str]]
- Symbol to get data for. Multiple items allowed for provider(s): fmp.
- provider : Optional[Literal['fmp']]
+ Symbol to get data for. Multiple items allowed for provider(s): fmp, intrinio.
+ provider : Optional[Literal['fmp', 'intrinio']]
The provider to use for the query, by default None.
If None, the provider specified in defaults is selected or 'fmp' if there is
no default.
+ return_type : Literal['trailing', 'calendar']
+ The type of returns to return, a trailing or calendar window. (provider: intrinio)
+ adjustment : Literal['splits_only', 'splits_and_dividends']
+ The adjustment factor, 'splits_only' will return pure price performance. (provider: intrinio)
Returns
-------
OBBject
- results : List[PricePerformance]
+ results : List[EtfPricePerformance]
Serializable results.
- provider : Optional[Literal['fmp']]
+ provider : Optional[Literal['fmp', 'intrinio']]
Provider name.
warnings : Optional[List[Warning_]]
List of warnings.
@@ -1206,8 +1214,10 @@ class ROUTER_etf(Container):
extra : Dict[str, Any]
Extra info.
- PricePerformance
- ----------------
+ EtfPricePerformance
+ -------------------
+ symbol : Optional[str]
+ Symbol representing the entity requested in the data.
one_day : Optional[float]
One-day return.
wtd : Optional[float]
@@ -1228,16 +1238,48 @@ class ROUTER_etf(Container):
Year to date return.
one_year :