Skip to content

Commit

Permalink
Rename stocks to equity (#5688)
Browse files Browse the repository at this point in the history
* Rename stocks folder

* Rename openbb_stocks package

* Rename routers

* Reroute equity menu

* Update routes based on feedback

* StockNews -> EquityNews

* StockInfo -> EquityProfile

* Rename Equity calendars

* Equity peers rename

* Rename discovery

* Rename fundamental

* Rename price command models

* Rename shorts

* Update charting router

* Fix seeking alpha upcoming release date

* Fix linting errors

* Update tests

* Fix tests

* Skip econometrics api tests because it's python only

* Update integration tests and test data

* Historical analyst estimates

* Skip cboe options chain test. Unable to record vcr cassette

* re-record cboe cassettes

* Document CBOE unit test creation caveats

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
  • Loading branch information
piiq and deeleeramone authored Nov 10, 2023
1 parent 511558e commit 7c2d0ed
Show file tree
Hide file tree
Showing 141 changed files with 7,320 additions and 3,675 deletions.
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ repos:
rev: 6.3.0
hooks:
- id: pydocstyle
additional_dependencies: [tomli]
name: pydocstyle
entry: pydocstyle
language: python
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/dev_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
openbb-fixedincome = { path = "./extensions/fixedincome", develop = true }
openbb-news = { path = "./extensions/news", develop = true }
openbb-regulators = { path = "./extensions/regulators", develop = true }
openbb-stocks = { path = "./extensions/stocks", develop = true }
openbb-equity = { path = "./extensions/equity", develop = true }
# Community dependencies
openbb-alpha-vantage = { path = "./providers/alpha_vantage", optional = true, develop = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ def headers():
return get_headers()


data = {}
# pylint:disable=redefined-outer-name

data: dict = {}


def get_headers():
Expand All @@ -29,12 +31,12 @@ def get_headers():
return data["headers"]


def get_stocks_data():
"""Get stocks data."""
def get_equity_data():
"""Get equity data."""
if "stocks_data" in data:
return data["stocks_data"]

url = "http://0.0.0.0:8000/api/v1/stocks/load?symbol=AAPL&provider=fmp"
url = "http://0.0.0.0:8000/api/v1/equity/price/historical?symbol=AAPL&provider=fmp"
result = requests.get(url, headers=get_headers(), timeout=10)
data["stocks_data"] = result.json()["results"]

Expand All @@ -54,12 +56,12 @@ def get_stocks_data():
],
)
@pytest.mark.integration
def test_chart_stocks_load(params, headers):
"""Test chart stocks load."""
def test_chart_equity_price_historical(params, headers):
"""Test chart equity load."""
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/stocks/load?{query_str}"
url = f"http://0.0.0.0:8000/api/v1/equity/price/historical?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Expand All @@ -77,12 +79,12 @@ def test_chart_stocks_load(params, headers):
[({"symbol": "AAPL", "limit": 100, "chart": True})],
)
@pytest.mark.integration
def test_chart_stocks_multiples(params, headers):
"""Test chart stocks multiples."""
def test_chart_equity_fundamental_multiples(params, headers):
"""Test chart equity multiples."""
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/stocks/multiples?{query_str}"
url = f"http://0.0.0.0:8000/api/v1/equity/fundamental/multiples?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Expand All @@ -100,12 +102,12 @@ def test_chart_stocks_multiples(params, headers):
[({"provider": "yfinance", "symbols": "AAPL", "limit": 20, "chart": True})],
)
@pytest.mark.integration
def test_chart_stocks_news(params, headers):
"""Test chart stocks news."""
def test_chart_equity_news(params, headers):
"""Test chart equity news."""
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/stocks/news?{query_str}"
url = f"http://0.0.0.0:8000/api/v1/equity/news?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Expand Down Expand Up @@ -137,7 +139,7 @@ def test_chart_stocks_news(params, headers):
def test_chart_ta_adx(params, headers):
"""Test chart ta adx."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/adx?{query_str}"
Expand All @@ -161,7 +163,7 @@ def test_chart_ta_adx(params, headers):
def test_chart_ta_aroon(params, headers):
"""Test chart ta aroon."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/aroon?{query_str}"
Expand Down Expand Up @@ -196,7 +198,7 @@ def test_chart_ta_aroon(params, headers):
def test_chart_ta_ema(params, headers):
"""Test chart ta ema."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/ema?{query_str}"
Expand Down Expand Up @@ -231,7 +233,7 @@ def test_chart_ta_ema(params, headers):
def test_chart_ta_hma(params, headers):
"""Test chart ta hma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/hma?{query_str}"
Expand Down Expand Up @@ -267,7 +269,7 @@ def test_chart_ta_hma(params, headers):
def test_chart_ta_macd(params, headers):
"""Test chart ta macd."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/macd?{query_str}"
Expand Down Expand Up @@ -303,7 +305,7 @@ def test_chart_ta_macd(params, headers):
def test_chart_ta_rsi(params, headers):
"""Test chart ta rsi."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/rsi?{query_str}"
Expand Down Expand Up @@ -338,7 +340,7 @@ def test_chart_ta_rsi(params, headers):
def test_chart_ta_sma(params, headers):
"""Test chart ta sma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/sma?{query_str}"
Expand Down Expand Up @@ -373,7 +375,7 @@ def test_chart_ta_sma(params, headers):
def test_chart_ta_wma(params, headers):
"""Test chart ta wma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/wma?{query_str}"
Expand Down Expand Up @@ -408,7 +410,7 @@ def test_chart_ta_wma(params, headers):
def test_chart_ta_zlma(params, headers):
"""Test chart ta zlma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_stocks_data())
body = json.dumps(get_equity_data())

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/ta/zlma?{query_str}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
from openbb_core.app.model.obbject import OBBject


# pylint:disable=inconsistent-return-statements
@pytest.fixture(scope="session")
def obb(pytestconfig):
"""Fixture to setup obb."""
if pytestconfig.getoption("markexpr") != "not integration":
import openbb
import openbb # pylint:disable=import-outside-toplevel

return openbb.obb


data = {}
# pylint:disable=redefined-outer-name

data: dict = {}

def get_stocks_data():
"""Get stocks data."""

def get_equity_data():
"""Get equity data."""
import openbb # pylint:disable=import-outside-toplevel

if "stocks_data" in data:
Expand All @@ -27,7 +30,7 @@ def get_stocks_data():
symbol = "AAPL"
provider = "fmp"

data["stocks_data"] = openbb.obb.stocks.load(
data["stocks_data"] = openbb.obb.equity.price.historical(
symbol=symbol, provider=provider
).results
return data["stocks_data"]
Expand All @@ -46,9 +49,9 @@ def get_stocks_data():
],
)
@pytest.mark.integration
def test_chart_stocks_load(params, obb):
"""Test chart stocks load."""
result = obb.stocks.load(**params)
def test_chart_equity_price_historical(params, obb):
"""Test chart equity price historical."""
result = obb.equity.price.historical(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Expand All @@ -63,11 +66,11 @@ def test_chart_stocks_load(params, obb):
],
)
@pytest.mark.integration
def test_chart_stocks_multiples(params, obb):
"""Test chart stocks multiples."""
def test_chart_equity_fundamental_multiples(params, obb):
"""Test chart equity multiples."""
params = {p: v for p, v in params.items() if v}

result = obb.stocks.multiples(**params)
result = obb.equity.fundamental.multiples(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Expand All @@ -89,11 +92,11 @@ def test_chart_stocks_multiples(params, obb):
],
)
@pytest.mark.integration
def test_chart_stocks_news(params, obb):
"""Test chart stocks news."""
def test_chart_equity_news(params, obb):
"""Test chart equity news."""
params = {p: v for p, v in params.items() if v}

result = obb.stocks.news(**params)
result = obb.equity.news(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Expand Down Expand Up @@ -121,7 +124,7 @@ def test_chart_ta_adx(params, obb):
"""Test chart ta adx."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.adx(**params)
assert result
Expand Down Expand Up @@ -150,7 +153,7 @@ def test_chart_ta_aroon(params, obb):
"""Test chart ta aroon."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.aroon(**params)
assert result
Expand Down Expand Up @@ -180,7 +183,7 @@ def test_chart_ta_ema(params, obb):
"""Test chart ta ema."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.ema(**params)
assert result
Expand Down Expand Up @@ -210,7 +213,7 @@ def test_chart_ta_hma(params, obb):
"""Test chart ta hma."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.hma(**params)
assert result
Expand Down Expand Up @@ -241,7 +244,7 @@ def test_chart_ta_macd(params, obb):
"""Test chart ta macd."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.macd(**params)
assert result
Expand Down Expand Up @@ -272,7 +275,7 @@ def test_chart_ta_rsi(params, obb):
"""Test chart ta rsi."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.rsi(**params)
assert result
Expand Down Expand Up @@ -302,7 +305,7 @@ def test_chart_ta_sma(params, obb):
"""Test chart ta sma."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.sma(**params)
assert result
Expand Down Expand Up @@ -332,7 +335,7 @@ def test_chart_ta_wma(params, obb):
"""Test chart ta wma."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.wma(**params)
assert result
Expand Down Expand Up @@ -362,7 +365,7 @@ def test_chart_ta_zlma(params, obb):
"""Test chart ta zlma."""
params = {p: v for p, v in params.items() if v}

params["data"] = get_stocks_data()
params["data"] = get_equity_data()

result = obb.ta.zlma(**params)
assert result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CHART_FORMAT = ChartFormat.plotly


def stocks_load(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
def equity_price_historical(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
"""Stocks load chart."""

def handle_indicators(ma):
Expand Down Expand Up @@ -41,8 +41,8 @@ def handle_indicators(ma):
return fig, content


def stocks_news(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
"""Render stocks news table."""
def equity_news(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
"""Render equity news table."""
data = basemodel_to_df(kwargs["obbject_item"], index=kwargs.get("index", "date"))
standard_params = kwargs["standard_params"].__dict__
columnwidth = standard_params.get("columnwidth", None)
Expand All @@ -56,7 +56,7 @@ def stocks_news(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
def _ta_ma(ma_type: str, **kwargs):
"""Plot moving average helper."""
data = basemodel_to_df(kwargs["data"], index=kwargs.get("index", "date"))
window = kwargs.get("windowstocks_load", 50)
window = kwargs.get("window", 50)
offset = kwargs.get("offset", 0)
symbol = kwargs.get("symbol", "")

Expand Down Expand Up @@ -186,7 +186,7 @@ def ta_ema(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
return _ta_ma(ma_type, **kwargs)


def stocks_multiples(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
def equity_fundamental_multiples(**kwargs) -> Tuple[OpenBBFigure, Dict[str, Any]]:
"""Stocks multiples chart."""
data = basemodel_to_df(kwargs["obbject_item"], index=kwargs.get("index", "date"))
standard_params = kwargs["standard_params"].__dict__
Expand Down
Loading

0 comments on commit 7c2d0ed

Please sign in to comment.