From cbed180ba7b2291912ba2d42c2df7f104b6d8d65 Mon Sep 17 00:00:00 2001 From: Theodore Aptekarev Date: Thu, 7 Apr 2022 20:29:07 +0300 Subject: [PATCH] Fix divcal timeout (#1649) * Add request timeout time for nasdaq divcal request * Add a todo banner * Add divcal back to the integration tests Co-authored-by: piiq Co-authored-by: jmaslek --- openbb_terminal/stocks/discovery/nasdaq_model.py | 7 +++++++ scripts/test_stocks_disc.openbb | 1 + 2 files changed, 8 insertions(+) diff --git a/openbb_terminal/stocks/discovery/nasdaq_model.py b/openbb_terminal/stocks/discovery/nasdaq_model.py index 7ff14898836..f2a8f6eafd3 100644 --- a/openbb_terminal/stocks/discovery/nasdaq_model.py +++ b/openbb_terminal/stocks/discovery/nasdaq_model.py @@ -63,6 +63,12 @@ def get_dividend_cal(date: str) -> pd.DataFrame: pd.DataFrame: Dataframe of dividend calendar """ + # TODO: HELP WANTED: + # Nasdaq API doesn't like a lot of stuff. Your ISP or VPN, the specific user agent + # that you might be using, etc. More exploration is required to make this feature + # equally usable for all. In the time being we patch selection of the user agent and + # add a timeout for cases when the URL doesn't respond. + ag = get_user_agent() # Nasdaq API doesn't like this user agent, thus we always get other than this particular one while ( @@ -74,6 +80,7 @@ def get_dividend_cal(date: str) -> pd.DataFrame: r = requests.get( f"https://api.nasdaq.com/api/calendar/dividends?date={date}", headers={"User-Agent": ag}, + timeout=5, ) df = pd.DataFrame() diff --git a/scripts/test_stocks_disc.openbb b/scripts/test_stocks_disc.openbb index 45aa81bd6ff..8af98fb302e 100644 --- a/scripts/test_stocks_disc.openbb +++ b/scripts/test_stocks_disc.openbb @@ -22,6 +22,7 @@ asc ford arkord upcoming +divcal trending cnews lowfloat