Skip to content

Commit 776e378

Browse files
committed
Fix user confusion about 'auto_adjust' by telling them to set it
1 parent 9c89308 commit 776e378

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

yfinance/multi.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import logging
2525
import time as _time
2626
import traceback
27+
import warnings
28+
_warned_auto_adjust = False
2729

2830
import multitasking as _multitasking
2931
import pandas as _pd
@@ -35,7 +37,7 @@
3537

3638
@utils.log_indent_decorator
3739
def download(tickers, start=None, end=None, actions=False, threads=True, ignore_tz=None,
38-
group_by='column', auto_adjust=False, back_adjust=False, repair=False, keepna=False,
40+
group_by='column', auto_adjust=None, back_adjust=False, repair=False, keepna=False,
3941
progress=True, period="max", interval="1d", prepost=False,
4042
proxy=None, rounding=False, timeout=10, session=None):
4143
"""Download yahoo tickers
@@ -88,6 +90,13 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
8890
"""
8991
logger = utils.get_yf_logger()
9092

93+
if auto_adjust is None:
94+
global _warned_auto_adjust
95+
if not _warned_auto_adjust:
96+
warnings.warn(f"You have not set argument 'auto_adjust'. This defaults to False, but you should be setting it.", UserWarning)
97+
_warned_auto_adjust = True
98+
auto_adjust = False
99+
91100
if logger.isEnabledFor(logging.DEBUG):
92101
if threads:
93102
# With DEBUG, each thread generates a lot of log messages.

yfinance/scrapers/history.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import numpy as np
55
import pandas as pd
66
import time as _time
7+
import warnings
8+
_warned_auto_adjust = False
79

810
from yfinance import shared, utils
911
from yfinance.const import _BASE_URL_, _PRICE_COLNAMES_
@@ -27,7 +29,7 @@ def __init__(self, data, ticker, tz, session=None, proxy=None):
2729
@utils.log_indent_decorator
2830
def history(self, period="1mo", interval="1d",
2931
start=None, end=None, prepost=False, actions=True,
30-
auto_adjust=True, back_adjust=False, repair=False, keepna=False,
32+
auto_adjust=None, back_adjust=False, repair=False, keepna=False,
3133
proxy=None, rounding=False, timeout=10,
3234
raise_errors=False) -> pd.DataFrame:
3335
"""
@@ -74,6 +76,13 @@ def history(self, period="1mo", interval="1d",
7476
logger = utils.get_yf_logger()
7577
proxy = proxy or self.proxy
7678

79+
if auto_adjust is None:
80+
global _warned_auto_adjust
81+
if not _warned_auto_adjust:
82+
warnings.warn(f"You have not set argument 'auto_adjust'. This defaults to True = adjust for dividends, but you should be setting it.", UserWarning)
83+
_warned_auto_adjust = True
84+
auto_adjust = True
85+
7786
start_user = start
7887
end_user = end
7988
if start or period is None or period.lower() == "max":

0 commit comments

Comments
 (0)