mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 15:32:04 +00:00
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 <piiq@tinag.ru> Co-authored-by: jmaslek <jmaslek11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
059888b6a8
commit
cbed180ba7
@@ -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()
|
||||
|
||||
1
scripts/test_stocks_disc.openbb
vendored
1
scripts/test_stocks_disc.openbb
vendored
@@ -22,6 +22,7 @@ asc
|
||||
ford
|
||||
arkord
|
||||
upcoming
|
||||
divcal
|
||||
trending
|
||||
cnews
|
||||
lowfloat
|
||||
|
||||
Reference in New Issue
Block a user