Skip to content

fix(yahoo): use adjclose for $change calculation#2161

Open
Bortlesboat wants to merge 1 commit intomicrosoft:mainfrom
Bortlesboat:fix/yahoo-adj-close-and-nan-comparison
Open

fix(yahoo): use adjclose for $change calculation#2161
Bortlesboat wants to merge 1 commit intomicrosoft:mainfrom
Bortlesboat:fix/yahoo-adj-close-and-nan-comparison

Conversation

@Bortlesboat
Copy link
Copy Markdown

Summary

Fixes #1563. The Yahoo data collector's calc_change() computes daily returns using raw close prices, which produces incorrect values for stocks with splits or dividends (the raw close has discontinuities at those dates).

  • Uses adjclose column when available, falls back to close for data sources without adjusted prices
  • This is a 2-line change in YahooNormalize.calc_change()

Test plan

  • Verified adjclose column exists in Yahoo Finance data
  • Confirmed fallback to close when adjclose is missing
  • Compared $change output before/after for a stock with a known split (e.g., AAPL 4:1 split Aug 2020)

calc_change used df["close"] to compute daily returns, producing
incorrect values for stocks with splits or dividends. Switch to
df["adjclose"] when available, falling back to "close" for data
sources that do not provide an adjusted close column.

Fixes microsoft#1563

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$CHANGE is calculated based on close instead of adj_close in the YahooCollector

1 participant