summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanglewood <85772166+deeleeramone@users.noreply.github.com>2024-01-22 12:21:48 -0800
committerGitHub <noreply@github.com>2024-01-22 20:21:48 +0000
commit04df52d06a0d9018e704b73ce054d30f1e0e4743 (patch)
tree2d44d36c619ed26d33ab0a312bfc7a8d621015e4
parent7f657d9867af3cdc48d6229192214ddef14a1342 (diff)
feature/finviz-provider: Adds Community Finviz Provider Extension (#5952)
* add finviz provider * recapture tests * recapture tests again? * invalid test param * static packages * units_measurement -> unit_measurement * static packages as core only * openbb_core version bump in pyproject.toml * try adding user-agent to test response * fix tests * linting * provider model cosmetic changes * fix install script and typo in openbb toml * static * fix: re-record unittests * empty data error * definitions as a file --------- Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Co-authored-by: Pratyush Shukla <ps4534@nyu.edu> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/compare_groups.py26
-rw-r--r--openbb_platform/dev_install.py1
-rw-r--r--openbb_platform/extensions/equity/integration/test_equity_api.py23
-rw-r--r--openbb_platform/extensions/equity/integration/test_equity_python.py20
-rw-r--r--openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py11
-rw-r--r--openbb_platform/extensions/etf/integration/test_etf_api.py5
-rw-r--r--openbb_platform/extensions/etf/integration/test_etf_python.py5
-rw-r--r--openbb_platform/openbb/package/derivatives_options.py80
-rw-r--r--openbb_platform/openbb/package/equity.py28
-rw-r--r--openbb_platform/openbb/package/equity_price.py26
-rw-r--r--openbb_platform/openbb/package/index.py32
-rw-r--r--openbb_platform/poetry.lock18
-rw-r--r--openbb_platform/providers/finviz/README.md15
-rw-r--r--openbb_platform/providers/finviz/__init__.py0
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/__init__.py21
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/__init__.py0
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/compare_groups.py254
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/equity_profile.py194
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/key_metrics.py276
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/price_performance.py117
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/price_target.py115
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/models/py.typed0
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/py.typed0
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/utils/__init__.py0
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/utils/definitions.py45
-rw-r--r--openbb_platform/providers/finviz/openbb_finviz/utils/py.typed0
-rw-r--r--openbb_platform/providers/finviz/poetry.lock1662
-rw-r--r--openbb_platform/providers/finviz/pyproject.toml20
-rw-r--r--openbb_platform/providers/finviz/tests/__init__.py0
-rw-r--r--openbb_platform/providers/finviz/tests/record/http/test_finviz_fetchers/test_finviz_compare_groups_fetcher.yaml531
-rw-r--r--openbb_platform/providers/finviz/tests/record/http/test_finviz_fetchers/test_finviz_equity_profile_fetcher.yaml1405
-rw-r--r--openbb_platform/providers/finviz/tests/record/http/test_finviz_fetchers/test_finviz_key_metrics_fetcher.yaml1386
-rw-r--r--openbb_platform/providers/finviz/tests/record/http/test_finviz_fetchers/test_finviz_price_performance_fetcher.yaml574
-rw-r--r--openbb_platform/providers/finviz/tests/record/http/test_finviz_fetchers/test_finviz_price_target_fetcher.yaml1404
-rw-r--r--openbb_platform/providers/finviz/tests/test_finviz_fetchers.py73
-rw-r--r--openbb_platform/pyproject.toml5
36 files changed, 8314 insertions, 58 deletions
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/compare_groups.py b/openbb_platform/core/openbb_core/provider/standard_models/compare_groups.py
new file mode 100644
index 00000000000..4f8515f28be
--- /dev/null
+++ b/openbb_platform/core/openbb_core/provider/standard_models/compare_groups.py
@@ -0,0 +1,26 @@
+"""Compare Groups Model."""
+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
+
+
+class CompareGroupsQueryParams(QueryParams):
+ """Compare Groups Query."""
+
+ group: Optional[str] = Field(
+ default=None,
+ description="The group to compare - i.e., 'sector', 'industry', 'country'. Choices vary by provider.",
+ )
+ metric: Optional[str] = Field(
+ default=None,
+ description="The type of metrics to compare - i.e, 'valuation', 'performance'. Choices vary by provider.",
+ )
+
+
+class CompareGroupsData(Data):
+ """Compare Groups Data."""
+
+ name: str = Field(description="Name or label of the group.")
diff --git a/openbb_platform/dev_install.py b/openbb_platform/dev_install.py
index c5ddd34a064..cc77e4a0f5a 100644
--- a/openbb_platform/dev_install.py
+++ b/openbb_platform/dev_install.py
@@ -45,6 +45,7 @@ openbb-biztoc = { path = "./providers/biztoc", optional = true, develop = true }
openbb-cboe = { path = "./providers/cboe", optional = true, develop = true }
openbb-ecb = { path = "./providers/ecb", optional = true, develop = true }
openbb-finra = { path = "./providers/finra", optional = true, develop = true }
+openbb-finviz = { path = "./providers/finviz", optional = true, develop = true }
openbb-government-us = { path = "./providers/government_us", optional = true, develop = true }
openbb-nasdaq = { path = "./providers/nasdaq", optional = true, develop = true }
openbb-seeking-alpha = { path = "./providers/seeking_alpha", optional = true, develop = true }
diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py
index 005ff9f0bbb..a21696c5b33 100644
--- a/openbb_platform/extensions/equity/integration/test_equity_api.py
+++ b/openbb_platform/extensions/equity/integration/test_equity_api.py
@@ -546,6 +546,7 @@ def test_equity_calendar_ipo(params, headers):
}
),
({"provider": "intrinio", "symbol": "AAPL", "period": "annual", "limit": 100}),
+ ({"provider": "finviz", "symbol": "AAPL,GOOG"}),
],
)
@pytest.mark.integration
@@ -608,6 +609,7 @@ def test_equity_ownership_major_holders(params, headers):
"params",
[
({"symbol": "AAPL", "limit": 10, "provider": "fmp"}),
+ ({"symbol": "AAPL", "provider": "finviz"}),
(
{
"symbol": "AAPL",
@@ -809,6 +811,21 @@ def test_equity_compare_peers(params, headers):
@parametrize(
"params",
+ [({"group": "country", "metric": "overview", "provider": "finviz"})],
+)
+@pytest.mark.integration
+def test_equity_compare_groups(params, headers):
+ 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/equity/compare/groups?{query_str}"
+ result = requests.get(url, headers=headers, timeout=10)
+ assert isinstance(result, requests.Response)
+ assert result.status_code == 200
+
+
+@parametrize(
+ "params",
[
(
{
@@ -1171,6 +1188,7 @@ def test_equity_price_quote(params, headers):
({"symbol": "MSFT", "provider": "intrinio"}),
({"symbol": "AAPL,MSFT", "provider": "cboe"}),
({"symbol": "AAPL,MSFT", "provider": "intrinio"}),
+ ({"symbol": "AAPL,MSFT", "provider": "finviz"}),
({"symbol": "AAPL,MSFT", "provider": "yfinance"}),
],
)
@@ -1232,7 +1250,10 @@ def test_equity_discovery_active(params, headers):
@parametrize(
"params",
- [({"symbol": "AAPL", "provider": "fmp"})],
+ [
+ ({"symbol": "AAPL", "provider": "fmp"}),
+ ({"symbol": "AAPL,MSFT", "provider": "finviz"}),
+ ],
)
@pytest.mark.integration
def test_equity_price_performance(params, headers):
diff --git a/openbb_platform/extensions/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py
index 76b3e87c61b..66116efcb5e 100644
--- a/openbb_platform/extensions/equity/integration/test_equity_python.py
+++ b/openbb_platform/extensions/equity/integration/test_equity_python.py
@@ -510,6 +510,7 @@ def test_equity_calendar_ipo(params, obb):
}
),
({"provider": "intrinio", "symbol": "AAPL", "period": "annual", "limit": 100}),
+ ({"provider": "finviz", "symbol": "AAPL,GOOG"}),
],
)
@pytest.mark.integration
@@ -586,6 +587,7 @@ def test_equity_ownership_major_holders(params, obb):
"firm": None,
}
),
+ ({"symbol": "AAPL", "provider": "finviz"}),
],
)
@pytest.mark.integration
@@ -764,6 +766,18 @@ def test_equity_compare_peers(params, obb):
@parametrize(
"params",
+ [({"group": "country", "metric": "overview", "provider": "finviz"})],
+)
+@pytest.mark.integration
+def test_equity_compare_groups(params, obb):
+ result = obb.equity.compare.groups(**params)
+ assert result
+ assert isinstance(result, OBBject)
+ assert result.results is not None
+
+
+@parametrize(
+ "params",
[
(
{
@@ -1113,6 +1127,7 @@ def test_equity_price_quote(params, obb):
({"symbol": "MSFT", "provider": "intrinio"}),
({"symbol": "AAPL,MSFT", "provider": "cboe"}),
({"symbol": "AAPL,MSFT", "provider": "intrinio"}),
+ ({"symbol": "AAPL,MSFT", "provider": "finviz"}),
({"symbol": "AAPL,MSFT", "provider": "yfinance"}),
],
)
@@ -1171,7 +1186,10 @@ def test_equity_discovery_active(params, obb):
@parametrize(
"params",
- [({"symbol": "AAPL"})],
+ [
+ ({"symbol": "AAPL", "provider": "fmp"}),
+ ({"symbol": "AAPL,MSFT", "provider": "finviz"}),
+ ],
)
@pytest.mark.integration
def test_equity_price_performance(params, obb):
diff --git a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py
index 3834dbf7722..d324f444df7 100644
--- a/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py
+++ b/openbb_platform/extensions/equity/openbb_equity/compare/compare_router.py
@@ -24,3 +24,14 @@ async def peers(
) -> OBBject[BaseModel]:
"""Equity Peers. Company peers."""
return await OBBject.from_query(Query(**locals()))
+
+
+@router.command(model="CompareGroups")
+async def groups(
+ cc: CommandContext,
+ provider_choices: ProviderChoices,
+ standard_params: StandardParams,
+ extra_params: ExtraParams,
+) -> OBBject[BaseModel]:
+ """Compare Equity Sector and Industry Groups."""
+ return await OBBject.from_query(Query(**locals()))
diff --git a/openbb_platform/extensions/etf/integration/test_etf_api.py b/openbb_platform/extensions/etf/integration/test_etf_api.py
index 1b59abae3cc..fb96327c512 100644
--- a/openbb_platform/extensions/etf/integration/test_etf_api.py
+++ b/openbb_platform/extensions/etf/integration/test_etf_api.py
@@ -171,7 +171,10 @@ def test_etf_holdings(params, headers):
@parametrize(
"params",
- [({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"})],
+ [
+ ({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"}),
+ ({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "finviz"}),
+ ],
)
@pytest.mark.integration
def test_etf_price_performance(params, headers):
diff --git a/openbb_platform/extensions/etf/integration/test_etf_python.py b/openbb_platform/extensions/etf/integration/test_etf_python.py
index 283a8834a4f..8c98779a46f 100644
--- a/openbb_platform/extensions/etf/integration/test_etf_python.py
+++ b/openbb_platform/extensions/etf/integration/test_etf_python.py
@@ -163,7 +163,10 @@ def test_etf_holdings(params, obb):
@parametrize(
"params",
- [({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"})],
+ [
+ ({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "fmp"}),
+ ({"symbol": "SPY,VOO,QQQ,IWM,IWN,GOVT,JNK", "provider": "finviz"}),
+ ],
)
@pytest.mark.integration
def test_etf_price_performance(params, obb):
diff --git a/openbb_platform/openbb/package/derivatives_options.py b/openbb_platform/openbb/package/derivatives_options.py
index 7e43dfe1afe..43077b374bb 100644
--- a/openbb_platform/openbb/package/derivatives_options.py
+++ b/openbb_platform/openbb/package/derivatives_options.py
@@ -40,7 +40,7 @@ class ROUTER_derivatives_options(Container):
If None, the provider specified in defaults is selected or 'intrinio' if there is
no default.
date : Optional[datetime.date]
- Date for which the options chains are returned. (provider: intrinio)
+ The end-of-day date for options chains data. (provider: intrinio)
Returns
-------
@@ -58,48 +58,80 @@ class ROUTER_derivatives_options(Container):
OptionsChains
-------------
+ symbol : Optional[str]
+ Symbol representing the entity requested in the data. Here, it is the underlying symbol for the option.
contract_symbol : str
Contract symbol for the option.
- symbol : Optional[str]
- Symbol representing the entity requested in the data. Here its the underlying symbol for the option.
+ eod_date : Optional[date]
+ Date for which the options chains are returned.
expiration : date
Expiration date of the contract.
strike : float
Strike price of the contract.
option_type : str
Call or Put.
- eod_date : Optional[date]
- Date for which the options chains are returned.
- close : Optional[float]
- The close price.
- close_bid : Optional[float]
- The closing bid price for the option that day.
- close_ask : Optional[float]
- The closing ask price for the option that day.
- volume : Optional[float]
+ open_interest : Optional[int]
+ Open interest on the contract.
+ volume : Optional[int]
The trading volume.
+ theoretical_price : Optional[float]
+ Theoretical value of the option.
+ last_trade_price : Optional[float]
+ Last trade price of the option.
+ tick : Optional[str]
+ Whether the last tick was up or down in price.
+ bid : Optional[float]
+ Current bid price for the option.
+ bid_size : Optional[int]
+ Bid size for the option.
+ ask : Optional[float]
+ Current ask price for the option.
+ ask_size : Optional[int]
+ Ask size for the option.
+ mark : Optional[float]
+ The mid-price between the latest bid and ask.
open : Optional[float]
The open price.
open_bid : Optional[float]
The opening bid price for the option that day.
open_ask : Optional[float]
The opening ask price for the option that day.
- open_interest : Optional[float]
- Open interest on the contract.
high : Optional[float]
The high price.
- low : Optional[float]
- The low price.
- mark : Optional[float]
- The mid-price between the latest bid-ask spread.
- ask_high : Optional[float]
- The highest ask price for the option that day.
- ask_low : Optional[float]
- The lowest ask price for the option that day.
bid_high : Optional[float]
The highest bid price for the option that day.
+ ask_high : Optional[float]
+ The highest ask price for the option that day.
+ low : Optional[float]
+ The low price.
bid_low : Optional[float]
The lowest bid price for the option that day.
+ ask_low : Optional[float]
+ The lowest ask price for the option that day.
+ close : Optional[float]
+ The close price.
+ close_size : Optional[int]
+ The closing trade size for the option that day.
+ close_time : Optional[datetime]
+ The time of the closing price for the option that day.
+ close_bid : Optional[float]
+ The closing bid price for the option that day.
+ close_bid_size : Optional[int]
+ The closing bid size for the option that day.
+ close_bid_time : Optional[datetime]
+ The time of the bid closing price for the option that day.
+ close_ask : Optional[float]
+ The closing ask price for the option that day.
+ close_ask_size : Optional[int]
+ The closing ask size for the option that day.
+ close_ask_time : Optional[datetime]
+ The time of the ask closing price for the option that day.
+ prev_close : Optional[float]
+
+ change : Optional[float]
+ The change in the price of the option.
+ change_percent : Optional[float]
+ Change, in normalizezd percentage points, of the option.
implied_volatility : Optional[float]
Implied volatility of the option.
delta : Optional[float]
@@ -110,6 +142,10 @@ class ROUTER_derivatives_options(Container):
Theta of the option.
vega : Optional[float]
Vega of the option.
+ rho : Optional[float]
+ Rho of the option.
+ exercise_style : Optional[str]
+ The exercise style of the option, American or European. (provider: intrinio)
Example
-------
diff --git a/openbb_platform/openbb/package/equity.py b/openbb_platform/openbb/package/equity.py
index 63924b32bc2..423a43264f6 100644
--- a/openbb_platform/openbb/package/equity.py
+++ b/openbb_platform/openbb/package/equity.py
@@ -143,7 +143,7 @@ class ROUTER_equity(Container):
Price to earnings ratio. (provider: fmp)
exchange : Optional[str]
The exchange of the stock. (provider: fmp)
- timestamp : Optional[Union[int, float]]
+ timestamp : Optional[Union[float, int]]
The timestamp of the data. (provider: fmp)
earnings_announcement : Optional[str]
The earnings announcement of the stock. (provider: fmp)
@@ -224,7 +224,7 @@ class ROUTER_equity(Container):
Union[str, List[str]],
OpenBBCustomParameter(description="Symbol to get data for."),
],
- provider: Optional[Literal["intrinio"]] = None,
+ provider: Optional[Literal["intrinio", "yfinance"]] = None,
**kwargs
) -> OBBject:
"""Equity Info. Get general price and performance metrics of a stock.
@@ -233,7 +233,7 @@ class ROUTER_equity(Container):
----------
symbol : str
Symbol to get data for.
- provider : Optional[Literal['intrinio']]
+ provider : Optional[Literal['intrinio', 'yfinance']]
The provider to use for the query, by default None.
If None, the provider specified in defaults is selected or 'intrinio' if there is
no default.
@@ -243,7 +243,7 @@ class ROUTER_equity(Container):
OBBject
results : List[EquityInfo]
Serializable results.
- provider : Optional[Literal['intrinio']]
+ provider : Optional[Literal['intrinio', 'yfinance']]
Provider name.
warnings : Optional[List[Warning_]]
List of warnings.
@@ -330,6 +330,26 @@ class ROUTER_equity(Container):
Intrinio ID for the company. (provider: intrinio)
thea_enabled : Optional[bool]
Whether the company has been enabled for Thea. (provider: intrinio)
+ exchange_timezone : Optional[str]
+ The timezone of the exchange. (provider: yfinance)
+ issue_type : Optional[str]
+ The issuance type of the asset. (provider: yfinance)
+ currency : Optional[str]
+ The currency in which the asset is traded. (provider: yfinance)
+ market_cap : Optional[int]
+ The market capitalization of the asset. (provider: yfinance)
+ shares_outstanding : Optional[int]
+ The number of listed shares outstanding. (provider: yfinance)
+ shares_float : Optional[int]
+ The number of shares in the public float. (provider: yfinance)
+ shares_implied_outstanding : Optional[int]
+ The implied total number of shares outstanding. (provider: yfinance)
+ shares_short : Optional[int]
+ The reported number of shares short. (provider: yfinance)
+ dividend_yield : Optional[float]
+ The dividend yield of the asset, as a normalized percent. (provider: yfinance)
+ beta : Optional[float]
+ The beta of the asset relative to the broad market. (provider: yfinance)
Example
-------
diff --git a/openbb_platform/openbb/package/equity_price.py b/openbb_platform/openbb/package/equity_price.py
index fe56b6dd829..886a3c04d01 100644
--- a/openbb_platform/openbb/package/equity_price.py
+++ b/openbb_platform/openbb/package/equity_price.py
@@ -105,7 +105,7 @@ class ROUTER_equity_price(Container):
EquityHistorical
----------------
- date