mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-03 16:02:04 +00:00
Added recom error handling (#2628)
This commit is contained in:
@@ -52,7 +52,10 @@ def get_tradingview_recommendation(
|
||||
if not exchange:
|
||||
s_req = f"https://www.alphavantage.co/query?function=OVERVIEW&symbol={symbol}&apikey={cfg.API_KEY_ALPHAVANTAGE}"
|
||||
result = requests.get(s_req, stream=True)
|
||||
exchange = result.json()["Exchange"]
|
||||
data = result.json()
|
||||
if not data:
|
||||
return pd.DataFrame()
|
||||
exchange = data["Exchange"]
|
||||
|
||||
if interval:
|
||||
intervals = [interval]
|
||||
|
||||
@@ -7,6 +7,7 @@ import os
|
||||
from openbb_terminal.decorators import log_start_end
|
||||
from openbb_terminal.helper_funcs import export_data, print_rich_table
|
||||
from openbb_terminal.stocks.technical_analysis import tradingview_model
|
||||
from openbb_terminal.rich_config import console
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -39,6 +40,10 @@ def print_recommendation(
|
||||
symbol, screener, exchange, interval
|
||||
)
|
||||
|
||||
if recom.empty:
|
||||
console.print("[red]The API did not return any recommendations.[/red]\n")
|
||||
return
|
||||
|
||||
export_data(
|
||||
export,
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
|
||||
Reference in New Issue
Block a user