Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: price auto adjust confusion #1984

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion yfinance/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@
from .data import YfData
from . import shared

import warnings
_warned_auto_adjust = False


@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 +91,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("You have not set argument 'auto_adjust'. This defaults to False, but you should be setting it (Yahoo sets to True).", 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
12 changes: 11 additions & 1 deletion yfinance/scrapers/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from yfinance.const import _BASE_URL_, _PRICE_COLNAMES_
from yfinance.exceptions import YFChartError, YFInvalidPeriodError, YFPricesMissingError, YFTzMissingError

import warnings
_warned_auto_adjust = False

class PriceHistory:
def __init__(self, data, ticker, tz, session=None, proxy=None):
self._data = data
Expand All @@ -27,7 +30,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 +77,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("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)
_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
Loading