From 583d1632e6f06afbe7f56fcd3656eb2f96cf8b17 Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Thu, 7 Jul 2022 13:30:51 +0100 Subject: [PATCH] added verification for windows. if start is prior to 1970, convert it to 1970-01-02 (1 day buffer in case of timezone adjustments) (#2056) reference_1 : https://stackoverflow.com/questions/2518706/python-mktime-overflow-error reference_2 : https://discuss.python.org/t/please-help-getting-try-except-working-for-yfinance-download/11682/6 Co-authored-by: Chavithra --- openbb_terminal/stocks/stocks_helper.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openbb_terminal/stocks/stocks_helper.py b/openbb_terminal/stocks/stocks_helper.py index 613efc27fb1..57775cbb3e3 100644 --- a/openbb_terminal/stocks/stocks_helper.py +++ b/openbb_terminal/stocks/stocks_helper.py @@ -356,6 +356,12 @@ def load( int_ = "1mo" int_string = "Monthly" + # Win10 version of mktime cannot cope with dates before 1970 + if os.name == "nt" and start < datetime(1970, 1, 1): + start = datetime( + 1970, 1, 2 + ) # 1 day buffer in case of timezone adjustments + # Adding a dropna for weekly and monthly because these include weird NaN columns. df_stock_candidate = yf.download( ticker, start=start, end=end, progress=False, interval=int_