Added recom error handling (#2628)

This commit is contained in:
Colin Delahunty
2022-09-26 20:23:50 +02:00
committed by GitHub
parent c777ccb5c2
commit 9e742c0bb6
2 changed files with 9 additions and 1 deletions

View File

@@ -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]

View File

@@ -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__)),