From 534432cf12007640903cfb9fef3cd6850d78fac4 Mon Sep 17 00:00:00 2001 From: Ben Kulbertis Date: Mon, 1 Mar 2021 17:53:13 -0700 Subject: [PATCH] Add try/except --- gamestonk_terminal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gamestonk_terminal.py b/gamestonk_terminal.py index 171d0b3890d..ebcc0e53d05 100644 --- a/gamestonk_terminal.py +++ b/gamestonk_terminal.py @@ -310,8 +310,12 @@ def main(): b_quit = pm.pred_menu(df_stock, s_ticker, s_start, s_interval) # If stock data is intradaily, we need to get data again as prediction techniques work on daily adjusted data else: - ts = TimeSeries(key=cfg.API_KEY_ALPHAVANTAGE, output_format='pandas') - df_stock_pred, _ = ts.get_daily_adjusted(symbol=s_ticker, outputsize='full') + try: + ts = TimeSeries(key=cfg.API_KEY_ALPHAVANTAGE, output_format='pandas') + df_stock_pred, _ = ts.get_daily_adjusted(symbol=s_ticker, outputsize='full') + except: + print("Either the ticker or the API_KEY are invalids. Try again!") + return df_stock_pred = df_stock_pred.sort_index(ascending=True) df_stock_pred = df_stock_pred[s_start:] b_quit = pm.pred_menu(df_stock_pred, s_ticker, s_start, s_interval="1440min")