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 <chavithra@gmail.com>
This commit is contained in:
hjoaquim
2022-07-07 13:30:51 +01:00
committed by GitHub
parent 0276784b35
commit 583d1632e6

View File

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