mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Remove economy/rtps and stocks/ta/rsp (#5181)
* remove economy/rtps * remove ta/rsp * Forgot the sdk * remove from stocks/ta choices * remove terminal ta intro reference * remove sdk economy intro reference * remove from integration tests * delete gpt index txt files * more .md files to remove --------- Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
This commit is contained in:
@@ -319,8 +319,6 @@ class StocksController(model.StocksRoot):
|
||||
Attributes:
|
||||
`recom`: Get tradingview recommendation based on technical indicators\n
|
||||
`recom_chart`: Print tradingview recommendation based on technical indicators\n
|
||||
`rsp`: Relative strength percentile [Source: https://github.com/skyte/relative-strength]\n
|
||||
`rsp_chart`: Display Relative Strength Percentile [Source: https://github.com/skyte/relative-strength]\n
|
||||
`summary`: Get technical summary report provided by FinBrain's API\n
|
||||
`summary_chart`: Print technical summary report provided by FinBrain's API\n
|
||||
"""
|
||||
|
||||
@@ -48,8 +48,6 @@ class EconomyRoot(Category):
|
||||
`revenue_chart`: Governments collect revenues mainly for two purposes: to finance the goods\n
|
||||
`rgdp`: Gross domestic product (GDP) is the standard measure of the value added\n
|
||||
`rgdp_chart`: Gross domestic product (GDP) is the standard measure of the value added\n
|
||||
`rtps`: Get real-time performance sector data\n
|
||||
`rtps_chart`: Display Real-Time Performance sector. [Source: AlphaVantage]\n
|
||||
`search_index`: Search indices by keyword. [Source: FinanceDatabase]\n
|
||||
`spending`: General government spending provides an indication of the size\n
|
||||
`spending_chart`: General government spending provides an indication of the size\n
|
||||
@@ -107,8 +105,6 @@ class EconomyRoot(Category):
|
||||
self.revenue_chart = lib.economy_oecd_view.plot_revenue
|
||||
self.rgdp = lib.economy_oecd_model.get_real_gdp
|
||||
self.rgdp_chart = lib.economy_oecd_view.plot_real_gdp
|
||||
self.rtps = lib.economy_alphavantage_model.get_sector_data
|
||||
self.rtps_chart = lib.economy_alphavantage_view.realtime_performance_sector
|
||||
self.search_index = lib.economy_yfinance_model.get_search_indices
|
||||
self.spending = lib.economy_oecd_model.get_spending
|
||||
self.spending_chart = lib.economy_oecd_view.plot_spending
|
||||
|
||||
@@ -551,8 +551,6 @@ class StocksTechnicalAnalysis(Category):
|
||||
Attributes:
|
||||
`recom`: Get tradingview recommendation based on technical indicators\n
|
||||
`recom_chart`: Print tradingview recommendation based on technical indicators\n
|
||||
`rsp`: Relative strength percentile [Source: https://github.com/skyte/relative-strength]\n
|
||||
`rsp_chart`: Display Relative Strength Percentile [Source: https://github.com/skyte/relative-strength]\n
|
||||
`summary`: Get technical summary report provided by FinBrain's API\n
|
||||
`summary_chart`: Print technical summary report provided by FinBrain's API\n
|
||||
"""
|
||||
@@ -563,8 +561,6 @@ class StocksTechnicalAnalysis(Category):
|
||||
super().__init__()
|
||||
self.recom = lib.stocks_ta_tradingview_model.get_tradingview_recommendation
|
||||
self.recom_chart = lib.stocks_ta_tradingview_view.print_recommendation
|
||||
self.rsp = lib.stocks_ta_rsp_model.get_rsp
|
||||
self.rsp_chart = lib.stocks_ta_rsp_view.display_rsp
|
||||
self.summary = lib.stocks_ta_finbrain_model.get_technical_summary_report
|
||||
self.summary_chart = lib.stocks_ta_finbrain_view.technical_summary_report
|
||||
|
||||
|
||||
@@ -324,8 +324,6 @@ from openbb_terminal.fixedincome import (
|
||||
|
||||
|
||||
from openbb_terminal.economy import (
|
||||
alphavantage_model as economy_alphavantage_model,
|
||||
alphavantage_view as economy_alphavantage_view,
|
||||
econdb_model as economy_econdb_model,
|
||||
econdb_view as economy_econdb_view,
|
||||
finviz_model as economy_finviz_model,
|
||||
@@ -553,8 +551,6 @@ from openbb_terminal.stocks.screener import (
|
||||
from openbb_terminal.stocks.technical_analysis import (
|
||||
finbrain_model as stocks_ta_finbrain_model,
|
||||
finbrain_view as stocks_ta_finbrain_view,
|
||||
rsp_model as stocks_ta_rsp_model,
|
||||
rsp_view as stocks_ta_rsp_view,
|
||||
tradingview_model as stocks_ta_tradingview_model,
|
||||
tradingview_view as stocks_ta_tradingview_view,
|
||||
)
|
||||
|
||||
2
openbb_terminal/core/sdk/trail_map.csv
vendored
2
openbb_terminal/core/sdk/trail_map.csv
vendored
@@ -214,7 +214,6 @@ economy.perfmap,economy_finviz_model.get_performance_map,
|
||||
economy.performance,economy_finviz_model.get_performance_data,
|
||||
economy.revenue,economy_oecd_model.get_revenue,economy_oecd_view.plot_revenue
|
||||
economy.rgdp,economy_oecd_model.get_real_gdp,economy_oecd_view.plot_real_gdp
|
||||
economy.rtps,economy_alphavantage_model.get_sector_data,economy_alphavantage_view.realtime_performance_sector
|
||||
economy.search_index,economy_yfinance_model.get_search_indices,
|
||||
economy.spending,economy_oecd_model.get_spending,economy_oecd_view.plot_spending
|
||||
economy.treasury,economy_econdb_model.get_treasuries,economy_econdb_view.show_treasuries
|
||||
@@ -541,7 +540,6 @@ stocks.quote,stocks_model.get_quote,stocks_view.display_quote
|
||||
stocks.screener.screener_data,stocks_screener_finviz_model.get_screener_data,stocks_screener_finviz_view.screener
|
||||
stocks.search,stocks_helper.search,
|
||||
stocks.ta.recom,stocks_ta_tradingview_model.get_tradingview_recommendation,stocks_ta_tradingview_view.print_recommendation
|
||||
stocks.ta.rsp,stocks_ta_rsp_model.get_rsp,stocks_ta_rsp_view.display_rsp
|
||||
stocks.ta.summary,stocks_ta_finbrain_model.get_technical_summary_report,stocks_ta_finbrain_view.technical_summary_report
|
||||
stocks.th.all,stocks_th_bursa_model.get_all,stocks_th_bursa_view.display_all
|
||||
stocks.th.check_if_open,stocks_th_bursa_model.check_if_open,
|
||||
|
||||
|
@@ -1,325 +0,0 @@
|
||||
""" Alpha Vantage Model """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import logging
|
||||
|
||||
import pandas as pd
|
||||
from alpha_vantage.sectorperformance import SectorPerformances
|
||||
|
||||
from openbb_terminal.core.session.current_user import get_current_user
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import get_user_agent, request
|
||||
from openbb_terminal.rich_config import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_sector_data() -> pd.DataFrame:
|
||||
"""Get real-time performance sector data
|
||||
|
||||
Returns
|
||||
-------
|
||||
df_sectors : pd.Dataframe
|
||||
Real-time performance data
|
||||
"""
|
||||
current_user = get_current_user()
|
||||
sector_perf = SectorPerformances(
|
||||
key=current_user.credentials.API_KEY_ALPHAVANTAGE, output_format="pandas"
|
||||
)
|
||||
|
||||
df_sectors, _ = sector_perf.get_sector()
|
||||
|
||||
# pylint: disable=invalid-sequence-index
|
||||
df_rtp = df_sectors["Rank A: Real-Time Performance"]
|
||||
df_rtp = df_rtp.apply(lambda x: x * 100)
|
||||
df_rtp = df_rtp.to_frame().reset_index()
|
||||
|
||||
df_rtp.columns = ["Sector", "% Chg"]
|
||||
|
||||
return df_rtp
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_real_gdp(
|
||||
interval: str = "q",
|
||||
start_year: int = 2010,
|
||||
) -> pd.DataFrame:
|
||||
"""Get annual or quarterly Real GDP for US
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str, optional
|
||||
Interval for GDP, by default "a" for annual, by default "q"
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of GDP
|
||||
"""
|
||||
s_interval = "quarterly" if interval == "q" else "annual"
|
||||
|
||||
url = (
|
||||
"https://www.alphavantage.co/query?function=REAL_GDP"
|
||||
+ f"&interval={s_interval}&apikey={get_current_user().credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
|
||||
if r.status_code != 200:
|
||||
console.print(f"Request error. Response code: {str(r.status_code)}.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
|
||||
# Successful requests
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["GDP"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= f"{start_year}-01-01"]
|
||||
console.print(f"No data found for {interval}.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_gdp_capita(start_year: int = 2010) -> pd.DataFrame:
|
||||
"""Real GDP per Capita for United States
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
DataFrame of GDP per Capita
|
||||
"""
|
||||
url = (
|
||||
"https://www.alphavantage.co/query?function=REAL_GDP_PER_CAPITA"
|
||||
+ f"&apikey={get_current_user().credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
if r.status_code != 200:
|
||||
console.print(f"Request error. Response code: {str(r.status_code)}.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["GDP"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= f"{start_year}-01-01"]
|
||||
console.print("No data found.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_inflation(start_year: int = 2010) -> pd.DataFrame:
|
||||
"""Get historical Inflation for United States from AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
DataFrame of inflation rates
|
||||
"""
|
||||
url = (
|
||||
"https://www.alphavantage.co/query?function=INFLATION"
|
||||
+ f"&apikey={get_current_user().credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
if r.status_code != 200:
|
||||
console.print(f"Request error. Response code: {str(r.status_code)}.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["Inflation"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= f"{start_year}-01-01"]
|
||||
console.print("No data found.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_cpi(interval: str = "m", start_year: int = 2010) -> pd.DataFrame:
|
||||
"""Get Consumer Price Index from Alpha Vantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str
|
||||
Interval for data. Either "m" or "s" for monthly or semiannual
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of CPI
|
||||
"""
|
||||
s_interval = "semiannual" if interval == "s" else "monthly"
|
||||
url = (
|
||||
f"https://www.alphavantage.co/query?function=CPI&interval={s_interval}"
|
||||
+ f"&apikey={get_current_user().credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
|
||||
if r.status_code != 200:
|
||||
console.print(f"Request error. Response code: {str(r.status_code)}.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
|
||||
# Successful requests
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["CPI"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= f"{start_year}-01-01"]
|
||||
console.print(f"No data found for {interval}.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_treasury_yield(
|
||||
interval: str = "m", maturity: str = "10y", start_date: str = "2010-01-01"
|
||||
) -> pd.DataFrame:
|
||||
"""Get historical yield for a given maturity
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str
|
||||
Interval for data. Can be "d","w","m" for daily, weekly or monthly, by default "m"
|
||||
start_date: str
|
||||
Start date for data. Should be in YYYY-MM-DD format, by default "2010-01-01"
|
||||
maturity : str
|
||||
Maturity timeline. Can be "3mo","5y","10y" or "30y", by default "10y"
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of historical yields
|
||||
"""
|
||||
d_interval = {"d": "daily", "w": "weekly", "m": "monthly"}
|
||||
d_maturity = {"3m": "3month", "5y": "5year", "10y": "10year", "30y": "30year"}
|
||||
|
||||
url = (
|
||||
"https://www.alphavantage.co/query?function=TREASURY_YIELD"
|
||||
+ f"&interval={d_interval[interval]}"
|
||||
+ f"&maturity={d_maturity[maturity]}&apikey={get_current_user().credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
if r.status_code != 200:
|
||||
console.print(f"Request error. Response code: {str(r.status_code)}.\n")
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
|
||||
# Successful requests
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["Yield"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= start_date]
|
||||
console.print(f"No data found for {interval}.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_unemployment(start_year: int = 2010) -> pd.DataFrame:
|
||||
"""Get historical unemployment for United States
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
|
||||
Returns
|
||||
-------
|
||||
pd.DataFrame
|
||||
Dataframe of historical yields
|
||||
"""
|
||||
current_user = get_current_user()
|
||||
url = (
|
||||
"https://www.alphavantage.co/query?function=UNEMPLOYMENT&apikey="
|
||||
f"{current_user.credentials.API_KEY_ALPHAVANTAGE}"
|
||||
)
|
||||
r = request(url, headers={"User-Agent": get_user_agent()})
|
||||
if r.status_code != 200:
|
||||
return pd.DataFrame()
|
||||
|
||||
payload = r.json()
|
||||
data = pd.DataFrame()
|
||||
|
||||
# Successful requests
|
||||
if "data" in payload:
|
||||
if payload["data"]:
|
||||
data = pd.DataFrame(payload["data"])
|
||||
data["date"] = pd.to_datetime(data["date"])
|
||||
data["unemp"] = data["value"].astype(float)
|
||||
data = data.drop(columns=["value"])
|
||||
return data[data["date"] >= f"{start_year}-01-01"]
|
||||
console.print("No data found.\n")
|
||||
# Invalid API Keys
|
||||
if "Error Message" in payload:
|
||||
console.print(payload["Error Message"])
|
||||
# Premium feature, API plan is not authorized
|
||||
if "Information" in payload:
|
||||
console.print(payload["Information"])
|
||||
|
||||
return pd.DataFrame()
|
||||
@@ -1,456 +0,0 @@
|
||||
""" Alpha Vantage View """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Optional, Union
|
||||
|
||||
from openbb_terminal import OpenBBFigure, theme
|
||||
from openbb_terminal.decorators import check_api_key, log_start_end
|
||||
from openbb_terminal.economy import alphavantage_model
|
||||
from openbb_terminal.helper_funcs import export_data, print_rich_table
|
||||
from openbb_terminal.rich_config import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# pylint: disable=C0302,unused-argument
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def realtime_performance_sector(
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display Real-Time Performance sector. [Source: AlphaVantage]
|
||||
|
||||
Parameters
|
||||
----------
|
||||
raw : bool
|
||||
Output only raw data
|
||||
export : str
|
||||
Export dataframe data to csv,json,xlsx file
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
df_rtp = alphavantage_model.get_sector_data()
|
||||
|
||||
# pylint: disable=E1101
|
||||
if df_rtp.empty:
|
||||
return None
|
||||
|
||||
df_rtp_plot = df_rtp.set_index("Sector").squeeze(axis=1)
|
||||
colors = [theme.up_color if x > 0 else theme.down_color for x in df_rtp_plot.values]
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title="Real Time Performance (%) per Sector",
|
||||
yaxis=dict(side="right", dtick=1, title="Sector"),
|
||||
)
|
||||
fig.add_bar(
|
||||
orientation="h",
|
||||
x=df_rtp_plot.values,
|
||||
y=df_rtp_plot.index,
|
||||
name="Performance (%)",
|
||||
marker_color=colors,
|
||||
showlegend=False,
|
||||
)
|
||||
fig.update_layout(xaxis=dict(nticks=10))
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"rtps",
|
||||
df_rtp,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
df_rtp,
|
||||
show_index=False,
|
||||
headers=df_rtp.columns,
|
||||
title="Real-Time Performance",
|
||||
export=bool(export),
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_real_gdp(
|
||||
interval: str = "q",
|
||||
start_year: int = 2010,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display US GDP from AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str
|
||||
Interval for GDP. Either "a" or "q", by default "q"
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
raw : bool, optional
|
||||
Flag to show raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default ""
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
gdp = alphavantage_model.get_real_gdp(interval, start_year)
|
||||
|
||||
if gdp.empty:
|
||||
return None
|
||||
|
||||
int_string = "Annual" if interval == "a" else "Quarterly"
|
||||
year_str = str(start_year) if interval == "a" else str(list(gdp["date"])[-1].year)
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"{int_string} US GDP ($B) from {year_str}",
|
||||
yaxis=dict(side="right", title="US GDP ($B) "),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=gdp["date"],
|
||||
y=gdp["GDP"],
|
||||
name="GDP",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"gdp",
|
||||
gdp,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
gdp,
|
||||
headers=["Date", "GDP"],
|
||||
show_index=False,
|
||||
title="US GDP",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_gdp_capita(
|
||||
start_year: int = 2010,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display US GDP per Capita from AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
raw : bool, optional
|
||||
Flag to show raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
gdp = alphavantage_model.get_gdp_capita(start_year)
|
||||
if gdp.empty:
|
||||
return console.print("Error getting data. Check API Key")
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"US GDP per Capita (Chained 2012 USD) from {start_year}",
|
||||
yaxis=dict(side="right", title="US GDP (Chained 2012 USD) "),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=gdp["date"],
|
||||
y=gdp["GDP"],
|
||||
name="GDP",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"gdpc",
|
||||
gdp,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
gdp,
|
||||
headers=["Date", "GDP"],
|
||||
show_index=False,
|
||||
title="US GDP Per Capita",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_inflation(
|
||||
start_year: int = 2010,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display US Inflation from AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
raw : bool, optional
|
||||
Flag to show raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default ""
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
inf = alphavantage_model.get_inflation(start_year)
|
||||
if inf.empty:
|
||||
return console.print("Error getting data. Check API Key")
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"US Inflation from {list(inf['date'])[-1].year}",
|
||||
yaxis=dict(side="right", title="Inflation (%)"),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=inf["date"],
|
||||
y=inf["Inflation"],
|
||||
name="Inflation",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"inf",
|
||||
inf,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
inf,
|
||||
headers=["Date", "Inflation"],
|
||||
show_index=False,
|
||||
title="US Inflation",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_cpi(
|
||||
interval: str = "m",
|
||||
start_year: int = 2010,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display US consumer price index (CPI) from AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str
|
||||
Interval for GDP. Either "m" or "s"
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
raw : bool, optional
|
||||
Flag to show raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default ""
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
cpi = alphavantage_model.get_cpi(interval, start_year)
|
||||
if cpi.empty:
|
||||
return console.print("Error getting data. Check API Key")
|
||||
|
||||
int_string = "Semi-Annual" if interval == "s" else "Monthly"
|
||||
year_str = str(list(cpi["date"])[-1].year)
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"{int_string} Consumer Price Index from {year_str}",
|
||||
yaxis=dict(side="right", title="CPI"),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=cpi["date"],
|
||||
y=cpi["CPI"],
|
||||
name="CPI",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"cpi",
|
||||
cpi,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
cpi,
|
||||
headers=["Date", "CPI"],
|
||||
show_index=False,
|
||||
title="US CPI",
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_treasury_yield(
|
||||
interval: str = "m",
|
||||
maturity: str = "10y",
|
||||
start_date: str = "2010-01-01",
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display historical treasury yield for given maturity
|
||||
|
||||
Parameters
|
||||
----------
|
||||
interval : str
|
||||
Interval for data. Can be "d","w","m" for daily, weekly or monthly, by default "m"
|
||||
maturity : str
|
||||
Maturity timeline. Can be "3mo","5y","10y" or "30y", by default "10y"
|
||||
start_date: str
|
||||
Start date for data. Should be in YYYY-MM-DD format, by default "2010-01-01"
|
||||
raw : bool, optional
|
||||
Flag to display raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default ""
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
d_maturity = {"3m": "3month", "5y": "5year", "10y": "10year", "30y": "30year"}
|
||||
yld = alphavantage_model.get_treasury_yield(interval, maturity, start_date)
|
||||
if yld.empty:
|
||||
return console.print("Error getting data. Check API Key")
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"{d_maturity[maturity]} Treasury Yield",
|
||||
yaxis=dict(side="right", title="Yield (%)"),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=yld["date"],
|
||||
y=yld["Yield"],
|
||||
name="Yield",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"tyld",
|
||||
yld,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
yld,
|
||||
headers=["Date", "Yield"],
|
||||
title="Historical Treasury Yield",
|
||||
show_index=False,
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
||||
def display_unemployment(
|
||||
start_year: int = 2010,
|
||||
raw: bool = False,
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
external_axes: bool = False,
|
||||
limit: int = 20,
|
||||
) -> Union[OpenBBFigure, None]:
|
||||
"""Display US unemployment AlphaVantage
|
||||
|
||||
Parameters
|
||||
----------
|
||||
start_year : int, optional
|
||||
Start year for plot, by default 2010
|
||||
raw : bool, optional
|
||||
Flag to show raw data, by default False
|
||||
export : str, optional
|
||||
Format to export data, by default ""
|
||||
external_axes : bool, optional
|
||||
Whether to return the figure object or not, by default False
|
||||
"""
|
||||
|
||||
un = alphavantage_model.get_unemployment(start_year)
|
||||
|
||||
if un.empty:
|
||||
return console.print("Error getting data. Check API Key")
|
||||
|
||||
fig = OpenBBFigure(
|
||||
title=f"US Unemployment from {start_year}",
|
||||
yaxis=dict(side="right", title="US Unemployment (%)"),
|
||||
)
|
||||
|
||||
fig.add_scatter(
|
||||
x=un["date"],
|
||||
y=un["unemp"],
|
||||
name="Unemployment",
|
||||
)
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"unemp",
|
||||
un,
|
||||
sheet_name,
|
||||
fig,
|
||||
)
|
||||
|
||||
if raw:
|
||||
return print_rich_table(
|
||||
un,
|
||||
headers=["Date", "GDP"],
|
||||
title="US Unemployment",
|
||||
show_index=False,
|
||||
export=bool(export),
|
||||
limit=limit,
|
||||
)
|
||||
|
||||
return fig.show(external=external_axes)
|
||||
@@ -19,7 +19,6 @@ from openbb_terminal.core.session.current_user import get_current_user
|
||||
from openbb_terminal.custom_prompt_toolkit import NestedCompleter
|
||||
from openbb_terminal.decorators import check_api_key, log_start_end
|
||||
from openbb_terminal.economy import (
|
||||
alphavantage_view,
|
||||
commodity_view,
|
||||
econdb_model,
|
||||
econdb_view,
|
||||
@@ -77,7 +76,6 @@ class EconomyController(BaseController):
|
||||
"valuation",
|
||||
"performance",
|
||||
"map",
|
||||
"rtps",
|
||||
"bigmac",
|
||||
"events",
|
||||
"edebt",
|
||||
@@ -315,7 +313,7 @@ class EconomyController(BaseController):
|
||||
mt.add_cmd("bigmac")
|
||||
mt.add_cmd("events")
|
||||
mt.add_cmd("edebt")
|
||||
mt.add_cmd("rtps")
|
||||
mt.add_raw("\n")
|
||||
mt.add_cmd("valuation")
|
||||
mt.add_cmd("performance")
|
||||
mt.add_cmd("usdli")
|
||||
@@ -2249,34 +2247,6 @@ class EconomyController(BaseController):
|
||||
else None,
|
||||
)
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_rtps(self, other_args: List[str]):
|
||||
"""Process rtps command"""
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
prog="rtps",
|
||||
description="""
|
||||
Real-time and historical sector performances calculated from
|
||||
S&P500 incumbents. Pops plot in terminal. [Source: Alpha Vantage]
|
||||
""",
|
||||
)
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser,
|
||||
other_args,
|
||||
export_allowed=EXPORT_BOTH_RAW_DATA_AND_FIGURES,
|
||||
raw=True,
|
||||
)
|
||||
if ns_parser:
|
||||
alphavantage_view.realtime_performance_sector(
|
||||
raw=ns_parser.raw,
|
||||
export=ns_parser.export,
|
||||
sheet_name=" ".join(ns_parser.sheet_name)
|
||||
if ns_parser.sheet_name
|
||||
else None,
|
||||
)
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_valuation(self, other_args: List[str]):
|
||||
"""Process valuation command"""
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
parent_command:economy
|
||||
usage: rtps
|
||||
|
||||
Real-time and historical sector performances calculated from S&P500 incumbents. Pops plot in terminal. [Source: Alpha Vantage]
|
||||
|
||||
rtps
|
||||
Examples:
|
||||
- To view real-time and historical sector performances: economy/rtps
|
||||
- For sector performance data based on S&P500 incumbents: economy/rtps
|
||||
- To display a plot of sector performance in real-time: economy/rtps
|
||||
- To access sector performance data from Alpha Vantage: economy/rtps
|
||||
@@ -1,13 +0,0 @@
|
||||
parent_command:stocks/ta
|
||||
usage: rsp [-t]
|
||||
|
||||
IBD Style Relative Strength Percentile Ranking of Stocks (i.e. 0-100 Score). Ranks stocks on the basis of relative strength as calculated by Investor's Business Daily (Yearly performance of stock (most recent quarter is weighted
|
||||
double) divided by yearly performance of reference index (here, we use SPY) Export table to view the entire ranking Data taken from https://github.com/skyte/relative-strength
|
||||
|
||||
optional arguments:
|
||||
-t, --tickers Show other tickers in the industry the stock is part of (default: False)
|
||||
|
||||
|
||||
Examples:
|
||||
- To calculate the relative strength percentile ranking of a stock: stocks/load <SYMBOL>/ta/rsp
|
||||
- To calculate the relative strength percentile ranking and display other tickers in the same industry: stocks/load <SYMBOL>/ta/rsp -t
|
||||
2
openbb_terminal/miscellaneous/i18n/en.yml
vendored
2
openbb_terminal/miscellaneous/i18n/en.yml
vendored
@@ -420,7 +420,6 @@ en:
|
||||
stocks/ta/cci: commodity channel index
|
||||
stocks/ta/macd: moving average convergence/divergence
|
||||
stocks/ta/rsi: relative strength index
|
||||
stocks/ta/rsp: relative strength percentile
|
||||
stocks/ta/stoch: stochastic oscillator
|
||||
stocks/ta/fisher: fisher transform
|
||||
stocks/ta/cg: centre of gravity
|
||||
@@ -770,7 +769,6 @@ en:
|
||||
economy/edebt: show external debt statistics for various countries
|
||||
economy/usdli: Compare the USD Liquidity Index against a choice of indices
|
||||
economy/plot: plot data from the above commands together
|
||||
economy/rtps: real-time performance sectors
|
||||
economy/valuation: valuation of sectors, industry, country
|
||||
economy/performance: performance of sectors, industry, country
|
||||
economy/eval: create new series by performing operations on loaded data
|
||||
|
||||
@@ -21,7 +21,6 @@ events -n
|
||||
edebt --limit 10
|
||||
usdli
|
||||
usdli -o NASDAQ100
|
||||
rtps
|
||||
valuation
|
||||
valuation --group sector
|
||||
performance
|
||||
@@ -72,7 +71,6 @@ index -i sp500 --raw
|
||||
index -q ftse --limit 30
|
||||
plot --y1 T10Y2Y --y2 T5YIEM
|
||||
plot --y1 T10Y2Y,T20YIEM
|
||||
rtps
|
||||
valuation
|
||||
performance
|
||||
fred -p DGS2,DGS5
|
||||
|
||||
@@ -12,8 +12,6 @@ vwap
|
||||
cci
|
||||
macd
|
||||
rsi
|
||||
rsp
|
||||
rsp -t
|
||||
stoch
|
||||
fisher
|
||||
cg
|
||||
@@ -38,7 +36,6 @@ vwap
|
||||
cci -l 12
|
||||
macd --fast 10 --slow 20 --signal 5
|
||||
rsi -l 10 -s 90 -d 2
|
||||
rsp
|
||||
stoch -k 10 -d 2 --slowkperiod 2
|
||||
fisher -l 10
|
||||
cg -l 10
|
||||
|
||||
@@ -515,7 +515,6 @@
|
||||
"events": ["Nasdaq"],
|
||||
"edebt": ["Wikipedia"],
|
||||
"usdli": ["FRED"],
|
||||
"rtps": ["AlphaVantage"],
|
||||
"valuation": ["Finviz"],
|
||||
"performance": ["Finviz"],
|
||||
"gdp": ["OECD"],
|
||||
|
||||
43
openbb_terminal/reports/templates/economy.ipynb
vendored
43
openbb_terminal/reports/templates/economy.ipynb
vendored
@@ -171,44 +171,6 @@
|
||||
" news = pd.DataFrame()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "64729474",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"try:\n",
|
||||
" rtps_data = openbb.economy.rtps()\n",
|
||||
" subplots = OpenBBFigure.create_subplots(1, 2, horizontal_spacing=0.15)\n",
|
||||
" openbb.economy.rtps_chart(external_axes=True).to_subplot(subplots, 1, 1)\n",
|
||||
"\n",
|
||||
" chg = futures[\"%Chg\"]\n",
|
||||
" colors = [theme.up_color if x > 0 else theme.down_color for x in list(chg.values)]\n",
|
||||
" subplots.add_bar(\n",
|
||||
" y=chg.index,\n",
|
||||
" x=chg.values,\n",
|
||||
" orientation=\"h\",\n",
|
||||
" marker_color=colors,\n",
|
||||
" showlegend=False,\n",
|
||||
" row=1,\n",
|
||||
" col=2,\n",
|
||||
" )\n",
|
||||
" subplots.update_xaxes(title_text=\"Performance (%)\", row=1, col=1)\n",
|
||||
" subplots.update_xaxes(title_text=\"Change %\", row=1, col=2)\n",
|
||||
" subplots.update_layout(\n",
|
||||
" margin=dict(l=0, r=0, t=0, b=0),\n",
|
||||
" yaxis=dict(side=\"left\", nticks=15),\n",
|
||||
" yaxis2=dict(nticks=15),\n",
|
||||
" )\n",
|
||||
" chart_0 = subplots.to_html()\n",
|
||||
"except Exception as e:\n",
|
||||
" print(e)\n",
|
||||
" chart_0 = \"\"\n",
|
||||
" rtps_data = pd.DataFrame()\n",
|
||||
" \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"attachments": {},
|
||||
"cell_type": "markdown",
|
||||
@@ -673,12 +635,7 @@
|
||||
"\n",
|
||||
"htmlcode += widgets.row(\n",
|
||||
" [widgets.h(3, \"Commodities (source: WSJ)\") + futures_fig.to_html()]\n",
|
||||
" + [\n",
|
||||
" widgets.h(3, \"Real-time sector performance (source: Alphavantage)\")\n",
|
||||
" + rtps_data.to_html().replace(\"table\", 'table style=\"display:inline\"')\n",
|
||||
" ]\n",
|
||||
")\n",
|
||||
"htmlcode += widgets.row([chart_0])\n",
|
||||
"\n",
|
||||
"if not news.empty:\n",
|
||||
" htmlcode += widgets.row(\n",
|
||||
|
||||
@@ -210,8 +210,6 @@ class OpenBBSDK:
|
||||
`revenue_chart`: Governments collect revenues mainly for two purposes: to finance the goods\n
|
||||
`rgdp`: Gross domestic product (GDP) is the standard measure of the value added\n
|
||||
`rgdp_chart`: Gross domestic product (GDP) is the standard measure of the value added\n
|
||||
`rtps`: Get real-time performance sector data\n
|
||||
`rtps_chart`: Display Real-Time Performance sector. [Source: AlphaVantage]\n
|
||||
`search_index`: Search indices by keyword. [Source: FinanceDatabase]\n
|
||||
`spending`: General government spending provides an indication of the size\n
|
||||
`spending_chart`: General government spending provides an indication of the size\n
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
""" Relative Strength Percentile Model """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import logging
|
||||
from typing import Tuple
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def get_rsp(
|
||||
s_ticker: str = "",
|
||||
) -> Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame]:
|
||||
"""Relative strength percentile [Source: https://github.com/skyte/relative-strength]
|
||||
Currently takes from https://github.com/soggyomelette/rs-log in order to get desired output
|
||||
|
||||
Parameters
|
||||
----------
|
||||
s_ticker : str
|
||||
Stock Ticker
|
||||
|
||||
Returns
|
||||
-------
|
||||
Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame]
|
||||
Dataframe of stock percentile, Dataframe of industry percentile,
|
||||
Raw stock dataframe for export, Raw industry dataframe for export
|
||||
"""
|
||||
|
||||
df_stock_p = pd.read_csv(
|
||||
"https://raw.githubusercontent.com/soggyomelette/rs-log/main/output/rs_stocks.csv"
|
||||
)
|
||||
df_industries_p = pd.read_csv(
|
||||
"https://raw.githubusercontent.com/soggyomelette/rs-log/main/output/rs_industries.csv"
|
||||
)
|
||||
rsp_stock = pd.DataFrame()
|
||||
rsp_industry = pd.DataFrame()
|
||||
|
||||
if s_ticker != "":
|
||||
rsp_stock = df_stock_p[df_stock_p["Ticker"].str.match(s_ticker)]
|
||||
for i in range(len(df_industries_p)):
|
||||
if s_ticker in df_industries_p.iloc[i]["Tickers"]:
|
||||
rsp_industry = df_industries_p.iloc[[i]]
|
||||
|
||||
return (rsp_stock, rsp_industry, df_stock_p, df_industries_p) # type: ignore
|
||||
@@ -1,77 +0,0 @@
|
||||
""" Relative Strength Percentile View """
|
||||
__docformat__ = "numpy"
|
||||
|
||||
import logging
|
||||
import os
|
||||
from typing import Optional
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import export_data, print_rich_table
|
||||
from openbb_terminal.rich_config import console
|
||||
from openbb_terminal.stocks.technical_analysis import rsp_model
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def display_rsp(
|
||||
s_ticker: str = "",
|
||||
export: str = "",
|
||||
sheet_name: Optional[str] = None,
|
||||
tickers_show: bool = False,
|
||||
):
|
||||
"""Display Relative Strength Percentile [Source: https://github.com/skyte/relative-strength]
|
||||
|
||||
Parameters
|
||||
----------
|
||||
s_ticker : str
|
||||
Stock ticker
|
||||
export : str
|
||||
Format of export file
|
||||
tickers_show : bool
|
||||
Boolean to check if tickers in the same industry as the stock should be shown
|
||||
"""
|
||||
|
||||
rsp_stock, rsp_industry, df_stock_p, df_industries_p = rsp_model.get_rsp(s_ticker)
|
||||
if rsp_stock.empty or rsp_industry.empty:
|
||||
console.print(f"[red]Ticker '{s_ticker}' not found.\n[/red]")
|
||||
else:
|
||||
tickers = pd.DataFrame(rsp_industry["Tickers"])
|
||||
del rsp_industry["Tickers"]
|
||||
print_rich_table(
|
||||
rsp_stock,
|
||||
headers=list(rsp_stock.columns),
|
||||
show_index=False,
|
||||
title="Relative Strength Percentile of Stock (relative to SPY)",
|
||||
export=bool(export),
|
||||
)
|
||||
print_rich_table(
|
||||
rsp_industry,
|
||||
headers=list(rsp_industry.columns),
|
||||
show_index=False,
|
||||
title="Relative Strength Percentile of Industry the ticker is part of",
|
||||
export=bool(export),
|
||||
)
|
||||
if tickers_show:
|
||||
print_rich_table(
|
||||
tickers,
|
||||
headers=list(tickers.columns),
|
||||
show_index=False,
|
||||
title="Tickers in same industry as chosen stock",
|
||||
)
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)).replace("common", "stocks"),
|
||||
"rsp_stock",
|
||||
df_stock_p,
|
||||
sheet_name,
|
||||
)
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)).replace("common", "stocks"),
|
||||
"rsp_industry",
|
||||
df_industries_p,
|
||||
sheet_name,
|
||||
)
|
||||
@@ -39,7 +39,6 @@ from openbb_terminal.parent_classes import StockBaseController
|
||||
from openbb_terminal.rich_config import MenuText, console
|
||||
from openbb_terminal.stocks.technical_analysis import (
|
||||
finbrain_view,
|
||||
rsp_view,
|
||||
tradingview_model,
|
||||
tradingview_view,
|
||||
)
|
||||
@@ -69,7 +68,6 @@ class TechnicalAnalysisController(StockBaseController):
|
||||
"macd",
|
||||
"ichimoku",
|
||||
"rsi",
|
||||
"rsp",
|
||||
"stoch",
|
||||
"fisher",
|
||||
"cg",
|
||||
@@ -156,7 +154,6 @@ class TechnicalAnalysisController(StockBaseController):
|
||||
mt.add_cmd("fisher", not self.stock.empty)
|
||||
mt.add_cmd("ichimoku", not self.stock.empty)
|
||||
mt.add_cmd("rsi", not self.stock.empty)
|
||||
mt.add_cmd("rsp", not self.stock.empty)
|
||||
mt.add_cmd("stoch", not self.stock.empty)
|
||||
mt.add_info("_trend_")
|
||||
mt.add_cmd("adx", not self.stock.empty)
|
||||
@@ -806,51 +803,6 @@ class TechnicalAnalysisController(StockBaseController):
|
||||
else None,
|
||||
)
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_rsp(self, other_args: List[str]):
|
||||
"""Process rsp command"""
|
||||
parser = argparse.ArgumentParser(
|
||||
add_help=False,
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
||||
prog="rsp",
|
||||
description="""
|
||||
IBD Style Relative Strength Percentile Ranking of Stocks (i.e. 0-100 Score).
|
||||
Ranks stocks on the basis of relative strength as calculated by Investor's
|
||||
Business Daily (Yearly performance of stock (most recent quarter is weighted
|
||||
double) divided by yearly performance of reference index (here, we use SPY)
|
||||
Export table to view the entire ranking
|
||||
Data taken from https://github.com/skyte/relative-strength
|
||||
""",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--tickers",
|
||||
action="store_true",
|
||||
default=False,
|
||||
dest="disp_tickers",
|
||||
help="Show other tickers in the industry the stock is part of",
|
||||
)
|
||||
|
||||
ns_parser = self.parse_known_args_and_warn(
|
||||
parser,
|
||||
other_args,
|
||||
EXPORT_ONLY_RAW_DATA_ALLOWED,
|
||||
)
|
||||
|
||||
if ns_parser:
|
||||
if not self.ticker:
|
||||
no_ticker_message()
|
||||
return
|
||||
rsp_view.display_rsp(
|
||||
s_ticker=self.ticker,
|
||||
export=ns_parser.export,
|
||||
sheet_name=" ".join(ns_parser.sheet_name)
|
||||
if ns_parser.sheet_name
|
||||
else None,
|
||||
tickers_show=ns_parser.disp_tickers,
|
||||
)
|
||||
|
||||
@log_start_end(log=logger)
|
||||
def call_stoch(self, other_args: List[str]):
|
||||
"""Process stoch command"""
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
# IMPORTATION THIRDPARTY
|
||||
import pytest
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal.economy import alphavantage_model
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vcr_config():
|
||||
return {
|
||||
"filter_headers": [("User-Agent", None)],
|
||||
"filter_query_parameters": [("apikey", "MOCK_API_KEY")],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_sector_data(recorder):
|
||||
result_df = alphavantage_model.get_sector_data()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_real_gdp(recorder):
|
||||
result_df = alphavantage_model.get_real_gdp()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_gdp_capita(recorder):
|
||||
result_df = alphavantage_model.get_gdp_capita()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_inflation(recorder):
|
||||
result_df = alphavantage_model.get_inflation()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_cpi(recorder):
|
||||
result_df = alphavantage_model.get_cpi()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_treasury_yield(recorder):
|
||||
result_df = alphavantage_model.get_treasury_yield()
|
||||
recorder.capture(result_df)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_unemployment(recorder):
|
||||
result_df = alphavantage_model.get_unemployment()
|
||||
recorder.capture(result_df)
|
||||
@@ -1,105 +0,0 @@
|
||||
# IMPORTATION THIRDPARTY
|
||||
import pytest
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal.economy import alphavantage_view
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vcr_config():
|
||||
return {
|
||||
"filter_headers": [("User-Agent", None)],
|
||||
"filter_query_parameters": [("apikey", "MOCK_API_KEY")],
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.default_cassette("test_realtime_performance_sector")
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_realtime_performance_sector(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.realtime_performance_sector(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_real_gdp(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_real_gdp(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_gdp_capita(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_gdp_capita(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_inflation(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_inflation(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_cpi(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_cpi(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_treasury_yield(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_treasury_yield(raw=raw)
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
@pytest.mark.parametrize(
|
||||
"raw",
|
||||
[True, False],
|
||||
)
|
||||
@pytest.mark.record_stdout
|
||||
def test_display_unemployment(mocker, raw):
|
||||
# MOCK EXPORT_DATA
|
||||
mocker.patch(target="openbb_terminal.economy.alphavantage_view.export_data")
|
||||
|
||||
alphavantage_view.display_unemployment(raw=raw)
|
||||
@@ -4,7 +4,7 @@
|
||||
bigmac The Economist Big Mac index [Nasdaq]
|
||||
events show economic calendar [Nasdaq]
|
||||
edebt show external debt statistics for various countries [Wikipedia]
|
||||
rtps real-time performance sectors [AlphaVantage]
|
||||
|
||||
valuation valuation of sectors, industry, country [Finviz]
|
||||
performance performance of sectors, industry, country [Finviz]
|
||||
usdli Compare the USD Liquidity Index against a choice of indices [FRED]
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# IMPORTATION STANDARD
|
||||
|
||||
# IMPORTATION THIRDPARTY
|
||||
import pytest
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal.stocks.technical_analysis import rsp_model
|
||||
|
||||
|
||||
@pytest.mark.vcr
|
||||
def test_get_rsp_image(recorder):
|
||||
result = rsp_model.get_rsp()
|
||||
for df in result:
|
||||
recorder.capture(df)
|
||||
@@ -1,23 +0,0 @@
|
||||
# IMPORTATION STANDARD
|
||||
|
||||
# IMPORTATION THIRDPARTY
|
||||
import pytest
|
||||
|
||||
# IMPORTATION INTERNAL
|
||||
from openbb_terminal.stocks.technical_analysis import rsp_view
|
||||
|
||||
|
||||
# pylint: disable=E1101
|
||||
|
||||
|
||||
@pytest.mark.vcr(record_mode="none")
|
||||
@pytest.mark.record_stdout()
|
||||
@pytest.mark.parametrize(
|
||||
"ticker",
|
||||
[
|
||||
("TSLA"),
|
||||
(""),
|
||||
],
|
||||
)
|
||||
def test_view(ticker):
|
||||
rsp_view.display_rsp(ticker, tickers_show=True)
|
||||
@@ -508,21 +508,6 @@ def test_call_func_expect_queue(expected_queue, func, queue):
|
||||
sheet_name=None,
|
||||
),
|
||||
),
|
||||
(
|
||||
"call_rsp",
|
||||
[
|
||||
"-t",
|
||||
"--export=csv",
|
||||
],
|
||||
"rsp_view.display_rsp",
|
||||
[],
|
||||
dict(
|
||||
s_ticker="MOCK_TICKER",
|
||||
tickers_show=True,
|
||||
export="csv",
|
||||
sheet_name=None,
|
||||
),
|
||||
),
|
||||
(
|
||||
"call_stoch",
|
||||
[
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
- [overview](/sdk/reference/economy/overview)
|
||||
- [perfmap](/sdk/reference/economy/perfmap)
|
||||
- [performance](/sdk/reference/economy/performance)
|
||||
- [rtps](/sdk/reference/economy/rtps)
|
||||
- [search_index](/sdk/reference/economy/search_index)
|
||||
- [spectrum](/sdk/reference/economy/spectrum)
|
||||
- [treasury](/sdk/reference/economy/treasury)
|
||||
|
||||
72
website/content/sdk/reference/economy/rtps.md
vendored
72
website/content/sdk/reference/economy/rtps.md
vendored
@@ -1,72 +0,0 @@
|
||||
---
|
||||
title: rtps
|
||||
description: OpenBB SDK Function
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# rtps
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="model" label="Model" default>
|
||||
|
||||
Get real-time performance sector data
|
||||
|
||||
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/economy/alphavantage_model.py#L19)]
|
||||
|
||||
```python
|
||||
openbb.economy.rtps()
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
This function does not take any parameters.
|
||||
|
||||
---
|
||||
|
||||
## Returns
|
||||
|
||||
| Type | Description |
|
||||
| ---- | ----------- |
|
||||
| pd.Dataframe | Real-time performance data |
|
||||
---
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="view" label="Chart">
|
||||
|
||||
Display Real-Time Performance sector. [Source: AlphaVantage]
|
||||
|
||||
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/economy/alphavantage_view.py#L27)]
|
||||
|
||||
```python
|
||||
openbb.economy.rtps_chart(raw: bool = False, export: str = "", external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
| Name | Type | Description | Default | Optional |
|
||||
| ---- | ---- | ----------- | ------- | -------- |
|
||||
| raw | bool | Output only raw data | False | True |
|
||||
| export | str | Export dataframe data to csv,json,xlsx file | | True |
|
||||
| external_axes | Optional[List[plt.Axes]] | External axes (1 axis is expected in the list), by default None | None | True |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Returns
|
||||
|
||||
This function does not return anything
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
75
website/content/sdk/reference/stocks/ta/rsp.md
vendored
75
website/content/sdk/reference/stocks/ta/rsp.md
vendored
@@ -1,75 +0,0 @@
|
||||
---
|
||||
title: rsp
|
||||
description: OpenBB SDK Function
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# rsp
|
||||
|
||||
<Tabs>
|
||||
<TabItem value="model" label="Model" default>
|
||||
|
||||
Relative strength percentile [Source: https://github.com/skyte/relative-strength]
|
||||
|
||||
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/stocks/technical_analysis/rsp_model.py#L16)]
|
||||
|
||||
```python
|
||||
openbb.stocks.ta.rsp(s_ticker: str = "")
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
| Name | Type | Description | Default | Optional |
|
||||
| ---- | ---- | ----------- | ------- | -------- |
|
||||
| s_ticker | str | Stock Ticker | | True |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Returns
|
||||
|
||||
| Type | Description |
|
||||
| ---- | ----------- |
|
||||
| Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame] | Dataframe of stock percentile, Dataframe of industry percentile,<br/>Raw stock dataframe for export, Raw industry dataframe for export |
|
||||
---
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="view" label="Chart">
|
||||
|
||||
Display Relative Strength Percentile [Source: https://github.com/skyte/relative-strength]
|
||||
|
||||
Source Code: [[link](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/stocks/technical_analysis/rsp_view.py#L20)]
|
||||
|
||||
```python
|
||||
openbb.stocks.ta.rsp_chart(s_ticker: str = "", export: str = "", tickers_show: bool = False)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
| Name | Type | Description | Default | Optional |
|
||||
| ---- | ---- | ----------- | ------- | -------- |
|
||||
| s_ticker | str | Stock ticker | | True |
|
||||
| export | str | Format of export file | | True |
|
||||
| tickers_show | bool | Boolean to check if tickers in the same industry as the stock should be shown | False | True |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Returns
|
||||
|
||||
This function does not return anything
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: rtps
|
||||
description: OpenBB Terminal Function
|
||||
---
|
||||
|
||||
# rtps
|
||||
|
||||
Real-time and historical sector performances calculated from S&P500 incumbents. Pops plot in terminal. [Source: Alpha Vantage]
|
||||
|
||||
### Usage
|
||||
|
||||
```python
|
||||
rtps
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
This command has no parameters
|
||||
|
||||
|
||||

|
||||
|
||||
---
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
title: rsp
|
||||
description: OpenBB Terminal Function
|
||||
---
|
||||
|
||||
# rsp
|
||||
|
||||
IBD Style Relative Strength Percentile Ranking of Stocks (i.e. 0-100 Score). Ranks stocks on the basis of relative strength as calculated by Investor's Business Daily (Yearly performance of stock (most recent quarter is weighted double) divided by yearly performance of reference index (here, we use SPY) Export table to view the entire ranking Data taken from https://github.com/skyte/relative-strength
|
||||
|
||||
### Usage
|
||||
|
||||
```python
|
||||
rsp [-t]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Parameters
|
||||
|
||||
| Name | Description | Default | Optional | Choices |
|
||||
| ---- | ----------- | ------- | -------- | ------- |
|
||||
| disp_tickers | Show other tickers in the industry the stock is part of | False | True | None |
|
||||
|
||||

|
||||
|
||||
---
|
||||
@@ -52,7 +52,6 @@ The block above loads daily QQQ historical prices and volume, then enters the Te
|
||||
| macd | Momentum | Moving Average Convergence/Divergence. |
|
||||
| fisher | Momentum | Fisher Transform. |
|
||||
| rsi | Momentum | Relative Strength Index. |
|
||||
| rsp | Momentum | Relative Strength Percentile. |
|
||||
| stoch | Momentum | Stochastic Oscillator. |
|
||||
| adx | Trend | Average Directional Movement Index. |
|
||||
| aroon | Trend | Aroon Indicator. |
|
||||
|
||||
Reference in New Issue
Block a user