Skip to content

Commit 09c864f

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

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

yfinance/multi.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,13 @@
3232
from .data import YfData
3333
from . import shared
3434

35+
import warnings
36+
_warned_auto_adjust = False
37+
3538

3639
@utils.log_indent_decorator
3740
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,
41+
group_by='column', auto_adjust=None, back_adjust=False, repair=False, keepna=False,
3942
progress=True, period="max", interval="1d", prepost=False,
4043
proxy=None, rounding=False, timeout=10, session=None):
4144
"""Download yahoo tickers
@@ -88,6 +91,13 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
8891
"""
8992
logger = utils.get_yf_logger()
9093

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

yfinance/scrapers/history.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
from yfinance.const import _BASE_URL_, _PRICE_COLNAMES_
1010
from yfinance.exceptions import YFChartError, YFInvalidPeriodError, YFPricesMissingError, YFTzMissingError
1111

12+
import warnings
13+
_warned_auto_adjust = False
14+
1215
class PriceHistory:
1316
def __init__(self, data, ticker, tz, session=None, proxy=None):
1417
self._data = data
@@ -27,7 +30,7 @@ def __init__(self, data, ticker, tz, session=None, proxy=None):
2730
@utils.log_indent_decorator
2831
def history(self, period="1mo", interval="1d",
2932
start=None, end=None, prepost=False, actions=True,
30-
auto_adjust=True, back_adjust=False, repair=False, keepna=False,
33+
auto_adjust=None, back_adjust=False, repair=False, keepna=False,
3134
proxy=None, rounding=False, timeout=10,
3235
raise_errors=False) -> pd.DataFrame:
3336
"""
@@ -74,6 +77,13 @@ def history(self, period="1mo", interval="1d",
7477
logger = utils.get_yf_logger()
7578
proxy = proxy or self.proxy
7679

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

0 commit comments

Comments
 (0)