Skip to content

Commit

Permalink
Fix user confusion about 'auto_adjust' by telling them to set it
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider committed Jul 14, 2024
1 parent 9c89308 commit 776e378
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion yfinance/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import logging
import time as _time
import traceback
import warnings
_warned_auto_adjust = False

import multitasking as _multitasking
import pandas as _pd
Expand All @@ -35,7 +37,7 @@

@utils.log_indent_decorator
def download(tickers, start=None, end=None, actions=False, threads=True, ignore_tz=None,
group_by='column', auto_adjust=False, back_adjust=False, repair=False, keepna=False,
group_by='column', auto_adjust=None, back_adjust=False, repair=False, keepna=False,
progress=True, period="max", interval="1d", prepost=False,
proxy=None, rounding=False, timeout=10, session=None):
"""Download yahoo tickers
Expand Down Expand Up @@ -88,6 +90,13 @@ def download(tickers, start=None, end=None, actions=False, threads=True, ignore_
"""
logger = utils.get_yf_logger()

if auto_adjust is None:
global _warned_auto_adjust
if not _warned_auto_adjust:
warnings.warn(f"You have not set argument 'auto_adjust'. This defaults to False, but you should be setting it.", UserWarning)
_warned_auto_adjust = True
auto_adjust = False

if logger.isEnabledFor(logging.DEBUG):
if threads:
# With DEBUG, each thread generates a lot of log messages.
Expand Down
11 changes: 10 additions & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import numpy as np
import pandas as pd
import time as _time
import warnings
_warned_auto_adjust = False

from yfinance import shared, utils
from yfinance.const import _BASE_URL_, _PRICE_COLNAMES_
Expand All @@ -27,7 +29,7 @@ def __init__(self, data, ticker, tz, session=None, proxy=None):
@utils.log_indent_decorator
def history(self, period="1mo", interval="1d",
start=None, end=None, prepost=False, actions=True,
auto_adjust=True, back_adjust=False, repair=False, keepna=False,
auto_adjust=None, back_adjust=False, repair=False, keepna=False,
proxy=None, rounding=False, timeout=10,
raise_errors=False) -> pd.DataFrame:
"""
Expand Down Expand Up @@ -74,6 +76,13 @@ def history(self, period="1mo", interval="1d",
logger = utils.get_yf_logger()
proxy = proxy or self.proxy

if auto_adjust is None:
global _warned_auto_adjust
if not _warned_auto_adjust:
warnings.warn(f"You have not set argument 'auto_adjust'. This defaults to True = adjust for dividends, but you should be setting it.", UserWarning)
_warned_auto_adjust = True
auto_adjust = True

start_user = start
end_user = end
if start or period is None or period.lower() == "max":
Expand Down

0 comments on commit 776e378

Please sign in to comment.