Yahoo Finance API Migration: Align Your Existing Data Before Switching Stock APIs

TickDB Research ·

Summary: For financial product owners evaluating a replacement for a Yahoo Finance or yfinance prototype, a migration decision needs more than a successful request. This guide explains adjustment and date differences, compares old and new records, and connects findings to existing features. It includes an offline Python comparison tool, a browser-readable report, and an acceptance worksheet. A clearly labelled synthetic example demonstrates the decision process; the existing TickDB live sample is presented separately.

The watchlist and daily chart already work. Your team is evaluating another stock API, but the difficult questions begin when the datasets sit next to each other: historical prices differ, or both exports contain 20 rows with different dates. Should you change the adapter, retrieve more data, or keep the existing setup?

Confirm comparability first, align individual records, and then assess the effect on the screen. TickDB snapshots and historical candles can provide candidate inputs. A small adapter can isolate source-specific handling so the product owner can see which existing features have supporting evidence and which need more work.

1. Put each difference in the right place

Use five stages, each with a concrete output.

StageQuestionEvidence to retain
Price meaningDo the fields represent the same treatment of price?Settings, definitions, and reasons a comparison is not yet valid
Record coverageWhich symbols and dates occur on only one side?Missing records, duplicate keys, and expected-date coverage
ValuesWhich fields differ in comparable records?Per-field differences with original values retained
FeaturesWhat does the difference do to the existing screen?A feature-specific fix, deferral, or acceptance action
CutoverWhat must be resolved before moving forward?A decision, owner, and fallback procedure

Configuration differences, misaligned records, and numeric disagreements need different responses. Treating all three as a generic data-quality failure makes the next step harder to identify.

2. Turning off automatic adjustment can still leave split-adjusted OHLC

The current yfinance adjustment documentation distinguishes its two modes: auto_adjust=True adjusts OHLC; with False, Yahoo's OHLC is still split adjusted, with a separate Adj Close that also incorporates dividends.

An old auto_adjust=False setting therefore does not establish equivalence to another provider's “unadjusted” option. The TickDB sample requests adjust="none"; its meaning must be checked against that interface's definition rather than inferred from similar-looking option names.

Corporate actions make this distinction concrete. Apple's 2020 announcement specified a four-for-one split and split-adjusted trading beginning August 31. If a product needs history across that kind of event, include the relevant interval in acceptance testing. A recent sample that never crosses the event does not test the same behavior. No paired historical feed for that event was retrieved for this article.

Preserve what the old export actually contains

Keep the original export and record the installed version and actual settings. The old file may already reflect adjustment, repair, and missing-value handling.

Baseline detailWhy it matters
auto_adjust and field definitionsEstablish what OHLC and adjusted fields represent
repair and subsequent transformationsThe output may contain repaired or reconstructed values
start, end, and observed datesyfinance's end date is exclusive; inspect the returned range
keepna and custom filteringDetermine whether missing records remain visible
prepost, timezone, and date labelsAffect session and date interpretation
Retrieval time, library version, and code versionPreserve the conditions that produced this export

Use your actual script as the baseline. Record the new source's interval, currency, session, adjustment basis, and date convention too. Where these remain unknown, inspect coverage without drawing conclusions about price agreement.

3. Equal row counts can still hide missing data

The tool compares daily OHLC only. Quote checks require separate alignment of price object, event time, and session; asynchronous snapshots should not be treated as a direct price-agreement test.

The following is an executable synthetic software-test example. DEMO_A is not a security. Its dates and values are invented fixtures, not Yahoo or TickDB observations.

The old file contains January 5, 6, and 8; the new file contains January 5, 7, and 8. The test's separately declared expected dates run from January 5 through 9. Both files have three rows.

Test dateComparison resultProduct question
01-05Matching valuesCan this record proceed to feature testing?
01-06Old onlyCheck the new raw record, date label, or missing-value handling
01-07New onlyCheck extraction or filtering on the old side
01-08Value differenceWhich field differs, and can its definition or processing explain it?
01-09Missing in bothIs the expected list correct, and if so, why is this record absent?

For January 8, the synthetic close changes from 11 to 11.05. The program reports close:0.05. It does not label a provider wrong or invent a universal percentage tolerance for acceptance.

Align records before comparing values

Match an identified security and trading date, retaining the union of both datasets. Comparing only the intersection hides one-sided omissions. Resolve duplicate keys before a join accidentally multiplies matches.

A date missing from both sources needs a third input: the expected-record list. Build it from the reviewed market calendar and product scope, with security-specific trading interruptions considered separately. Without that list, the tool records NOT_CHECKED; agreement between two files does not establish complete history.

Stop numeric comparison when meaning is unresolved

The tool checks interval, currency, session, adjustment basis, date convention, and a shared human-reviewed comparability record. Unknown or different conditions produce NOT_COMPARABLE for matched rows, without computing value differences.

A separate synthetic case supplies a split-adjusted basis on one side and an unadjusted basis on the other. It can still report date coverage but requires semantic alignment first. In real work, investigate or transform the data as appropriate; do not relabel settings merely to pass a gate.

4. Turn findings into a decision

The synthetic comparison produces one match, one old-only record, one new-only record, one value difference, and one record missing from both.

The supported decision is to continue validation, without approving cutover. Assign the remaining work explicitly:

FindingNext actionFeature decision for this stage
Different date coverageInspect originals, filtering, and date definitions; retrieve again if neededKeep validating the chart; do not conceal gaps with zero values
Different values in a matched recordRetain the field difference and examine adjustment and source definitionsKeep the discrepancy open; correctness is not yet adjudicated
Expected record absent from bothReview the expected list, then investigate the gapDo not label the historical interval complete
Only offline data checks completedDisplay the output in a test screen and inspect labels and missing statesProceed to feature testing, with UI acceptance still open

Resolve missing data for a required feature before expanding scope. An optional feature can be deferred with a clear decision. Even a sample with no differences still needs ongoing-delivery, intended-use, and rollback checks.

Google SRE's release guidance emphasizes representative evaluation and user-relevant metrics. AWS describes gradual replacement with a retained fallback path. For this stock-data pilot, borrow those principles: test a scoped feature, retain controlled routing, define when to stop, and expand after reviewing the evidence. A small prototype does not need a large migration architecture.

5. A real sample: matching displayed closes and an opening-price precision difference

For a limited check, use AAPL on November 2–6, 2026. The Yahoo side comes from a search tool's readable capture of Yahoo Finance's official historical-prices page. The TickDB side is an actual REST response requested with interval=1d and adjust=none. Direct Yahoo chart requests timed out in the current environment; this is a page-display-to-API check, not a completed yfinance-export migration.

The TickDB request completed at 16:00 UTC on November 11, returning 20 daily bars. Five completed historical dates were selected for this example; the full response was retained. Values below are in USD and retain each source's displayed or returned precision.

DateYahoo displayed openTickDB raw openYahoo displayed closeTickDB raw close
2026-11-02342.67342.67338.32338.32
2026-11-03325.58325.58331.90331.9
2026-11-04341.57341.565349.51349.51
2026-11-05353.89353.89344.17344.17
2026-11-06338.73338.73342.37342.37

Both sides contain the five selected date labels. Their displayed closing numbers match. On November 4, the displayed opening number is 341.57 on Yahoo and the API returns 341.565, a difference of USD 0.005. The differing precision is visible; its underlying cause has not been established as a provider error or a particular rounding rule.

If your application chooses to display two decimal places, make its display policy explicit. For example:

from decimal import Decimal, ROUND_HALF_UP

raw_open = "341.565"
display_open = Decimal(raw_open).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
print(display_open)  # 341.57

This is an application policy demonstration, not a confirmation of Yahoo's internal rounding method. Keep the original input for storage and calculations. Matching display values do not establish equivalent underlying price series.

Why the comparator still stops before a price verdict

Running the original comparator on these real inputs returns:

NOT_COMPARABLE: 5
ALIGN_METADATA_BEFORE_VALUES
HUMAN_REVIEW_REQUIRED

The declarations were not relabelled to force a pass. Yahoo's history page describes a split-adjusted price series, while this TickDB request uses unadjusted prices. A shared session and daily aggregation-date definition has not been confirmed, and the original application's export settings have not been recovered. The tool therefore retains date-label coverage and stops at its comparability gate.

One product decision is already actionable: separate raw and displayed values, specify decimal places and rounding, and retain provenance. Historical-series migration remains on hold for definition checks. No actual production-page cutover was performed.

Use the same procedure on your authorized legacy CSV and its original settings to continue an actual migration. This sample helps distinguish presentation differences from unresolved data definitions; it is not an API-to-API accuracy benchmark.

Use the TickDB Stock API page to check the data and integration conditions for your own feature before selecting a sample.

6. Run the comparison on your own exports

The comparison tool requires Python 3.10 or later and the standard library. It makes no network requests and does not modify input files. Save the complete script below as compare_migration.py and start with the synthetic example:

python3 compare_migration.py --demo --out compare_runs
ArtifactPurpose
row_comparison.csvInspect old and new values, missing records, duplicates, and differences
comparison_report.jsonReview comparability, input hashes, and the next-action conclusion
comparison_view.htmlOpen locally in a browser to inspect results and unresolved settings

The demo also creates its two CSV inputs, metadata, and expected-date list. They are labelled synthetic data.

Supply exports you are entitled to use

Prepare a flat header:

symbol,trade_date,open,high,low,close

trade_date must be a reviewed YYYY-MM-DD trading-date label. Do not derive it by truncating an unexplained UTC timestamp. Keep old and new files separate and preserve the originals. Metadata records source, settings, explicit symbol mappings, and review evidence. Set semantics_reviewed to true only after that review; comparability_id references the shared confirmation of the comparison scope.

Start from this metadata structure, saving separate old.meta.json and new.meta.json files and filling in each source's actual conditions. Unknown values intentionally block numeric comparison:

{
  "source": "record actual source and version",
  "interval": "1d",
  "currency": "unknown",
  "session": "unknown",
  "adjustment_basis": "unknown",
  "date_basis": "unknown",
  "comparability_id": "unknown",
  "semantics_reviewed": false,
  "symbol_map": {
    "AAPL": "AAPL.US"
  }
}

Then run:

python3 compare_migration.py --old old.csv --new new.csv --old-meta old.meta.json --new-meta new.meta.json --expected expected.csv --out compare_runs

The companion package includes templates and the existing TickDB retrieval script. If the old export is not yet available, obtaining it is the next task; downloading unrelated full-market datasets is unnecessary for this pilot.

Keep a final feature acceptance record

FeatureData evidenceOpen workDecision and owner
WatchlistIdentity, price object, source, and timeRequired session, freshness, and unavailable statesRecord explicitly
Historical chartAligned dates, OHLC, and adjustment definitionGaps, discrepancies, and final-bar statusRecord explicitly
Customer displayActual audience, data, and use conditionsApplicable scope confirmationRecord explicitly
Cutover and fallbackTest-environment execution recordTrigger, source labels, and execution ownerRecord explicitly

Complete one feature's inputs, findings, and actions before expanding the migration. A question such as “Which evidence is still missing for this feature?” gives both product and engineering a practical next step.

Real-sample case checked November 12, 2026 (Asia/Shanghai). Method sources checked November 11, 2026: yfinance adjustment, download, and repair documentation; pandas merge validation; Apple's split announcement; NYSE trading information; and Google SRE and AWS migration guidance. Live observations, synthetic tests, and borrowed engineering methods are identified separately.

Complete offline comparison script

Human confirmations come from the supplied metadata; the program cannot verify those definitions on your behalf. Exact equality is a sample comparison result, and a numeric difference is an investigation item. Neither automatically signs off production.

#!/usr/bin/env python3
"""Offline daily-OHLC comparison. Python 3.10+, standard library only.

--demo generates clearly labelled synthetic fixtures, never market observations.
No downloads, orders, automatic adjustment, fill-forward, or production cutover.
"""
import argparse
import csv
import hashlib
import html
import json
from collections import defaultdict
from datetime import date, datetime, timezone
from decimal import Decimal, InvalidOperation
from pathlib import Path

FIELDS = ("open", "high", "low", "close")
GATES = ("interval", "currency", "session", "adjustment_basis", "date_basis", "comparability_id")


def csv_write(path, rows, fields):
    with path.open("w", encoding="utf-8-sig", newline="") as f:
        writer = csv.DictWriter(f, fieldnames=fields)
        writer.writeheader()
        writer.writerows(rows)


def read_rows(path, mapping=None, expected=False):
    groups, issues = defaultdict(list), []
    with path.open(encoding="utf-8-sig", newline="") as f:
        reader = csv.DictReader(f)
        required = {"symbol", "trade_date"} | (set() if expected else set(FIELDS))
        if not required.issubset(reader.fieldnames or []):
            raise ValueError(f"{path.name}: requires {sorted(required)}; flatten multi-level exports first")
        for line, row in enumerate(reader, 2):
            symbol = (row.get("symbol") or "").strip()
            day = (row.get("trade_date") or "").strip()
            try:
                if not symbol or date.fromisoformat(day).isoformat() != day:
                    raise ValueError()
            except ValueError:
                issues.append({"line": line, "reason": "invalid_symbol_or_ISO_date"})
                continue
            symbol = (mapping or {}).get(symbol, symbol)
            if not isinstance(symbol, str) or not symbol.strip():
                issues.append({"line": line, "reason": "invalid_symbol_mapping"})
                continue
            groups[(symbol.strip(), day)].append(row)
    return groups, issues


def prices(row):
    try:
        values = [Decimal(row[k]) for k in FIELDS]
        if any(not n.is_finite() or n <= 0 for n in values):
            return None
        o, h, l, c = values
        return values if h >= max(o, l, c) and l <= min(o, h, c) else None
    except (KeyError, InvalidOperation, TypeError, ValueError):
        return None


def compare(old_path, new_path, old_meta, new_meta, expected_path=None):
    problems = []
    for field in GATES:
        a, b = old_meta.get(field), new_meta.get(field)
        unknown = lambda v: not isinstance(v, str) or v.strip().lower() in ("", "unknown", "unconfirmed")
        if unknown(a) or unknown(b) or a != b:
            problems.append(f"{field}: unknown_or_different")
    if old_meta.get("interval") != "1d" or new_meta.get("interval") != "1d":
        problems.append("interval: this_example_accepts_daily_bars_only")
    if old_meta.get("semantics_reviewed") is not True or new_meta.get("semantics_reviewed") is not True:
        problems.append("semantics_reviewed: human_confirmation_required")
    old, old_issues = read_rows(old_path, old_meta.get("symbol_map"))
    new, new_issues = read_rows(new_path, new_meta.get("symbol_map"))
    expected, expected_issues = read_rows(expected_path, expected=True) if expected_path else ({}, [])
    rows = []
    keys = sorted(set(old) | set(new) | set(expected))
    for key in keys:
        a, b = old.get(key, []), new.get(key, [])
        changes = ""
        if len(a) > 1 or len(b) > 1 or len(expected.get(key, [])) > 1:
            status = "DUPLICATE_KEY"
        elif not a and not b:
            status = "MISSING_BOTH"
        elif not a:
            status = "NEW_ONLY"
        elif not b:
            status = "OLD_ONLY"
        elif problems:
            status = "NOT_COMPARABLE"
        elif prices(a[0]) is None or prices(b[0]) is None:
            status = "INVALID_OHLC"
        else:
            av, bv = prices(a[0]), prices(b[0])
            changes = ";".join(f"{f}:{y-x}" for f, x, y in zip(FIELDS, av, bv) if x != y)
            status = "VALUE_DIFFERENCE" if changes else "EXACT_MATCH"
        rows.append({"symbol": key[0], "trade_date": key[1], "status": status,
                     "old_rows": len(a), "new_rows": len(b), "new_minus_old": changes,
                     "old_close": a[0].get("close", "") if len(a) == 1 else "",
                     "new_close": b[0].get("close", "") if len(b) == 1 else "",
                     "expected_key": key in expected if expected_path else "NOT_CHECKED"})
    counts = {s: sum(r["status"] == s for r in rows) for s in sorted({r["status"] for r in rows})}
    input_errors = {"old": old_issues, "new": new_issues, "expected": expected_issues}
    if any(input_errors.values()) or counts.get("DUPLICATE_KEY"):
        conclusion = "FIX_INPUT_KEYS"
    elif problems:
        conclusion = "ALIGN_METADATA_BEFORE_VALUES"
    elif any(r["status"] != "EXACT_MATCH" for r in rows) or (expected_path and set(old) != set(expected)):
        conclusion = "REVIEW_RECORD_DIFFERENCES"
    elif not rows:
        conclusion = "NO_RECORDS_TO_COMPARE"
    else:
        conclusion = "NO_DIFFERENCES_IN_THIS_SAMPLE"
    return rows, {"comparability_issues": problems, "input_errors": input_errors,
                  "counts": counts, "conclusion": conclusion,
                  "expected_dates_check": "PROVIDED" if expected_path else "NOT_CHECKED",
                  "old_unique_keys": len(old), "new_unique_keys": len(new),
                  "old_source": old_meta.get("source"), "new_source": new_meta.get("source"),
                  "data_kind": "SYNTHETIC_NOT_MARKET_DATA" if any(
                      m.get("data_kind") == "SYNTHETIC_NOT_MARKET_DATA" for m in (old_meta, new_meta)) else "USER_DECLARED_INPUTS",
                  "deployment_signoff": "HUMAN_REVIEW_REQUIRED",
                  "note": "Exact decimal equality is a comparison result, not an accuracy or migration approval."}


def demo_files(folder):
    """All values are invented software-test data for DEMO_A, not a security."""
    base = {"symbol": "DEMO_A", "open": "10", "high": "12", "low": "9", "close": "11"}
    old = [dict(base, trade_date=f"2026-01-{d:02}") for d in (5, 6, 8)]
    new = [dict(base, trade_date=f"2026-01-{d:02}") for d in (5, 7, 8)]
    new[-1]["close"] = "11.05"
    meta = dict(source="SYNTHETIC_DEMO", interval="1d", currency="USD",
                session="regular", adjustment_basis="split_adjusted",
                date_basis="exchange_local_trade_date", semantics_reviewed=True,
                comparability_id="SYNTHETIC_TEST_BASIS_ONLY",
                symbol_map={}, data_kind="SYNTHETIC_NOT_MARKET_DATA")
    for name, data in (("old", old), ("new", new)):
        csv_write(folder / f"{name}.csv", data, ["symbol", "trade_date", *FIELDS])
        (folder / f"{name}.json").write_text(json.dumps(meta, indent=2))
    expected = [{"symbol": "DEMO_A", "trade_date": f"2026-01-{d:02}"} for d in range(5, 10)]
    csv_write(folder / "expected.csv", expected, ["symbol", "trade_date"])


def main():
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--demo", action="store_true")
    for name in ("old", "new", "old-meta", "new-meta", "expected"):
        parser.add_argument("--" + name, type=Path)
    parser.add_argument("--out", type=Path, default=Path("comparison_runs"))
    args = parser.parse_args()
    folder = args.out / datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S%fZ")
    folder.mkdir(parents=True, exist_ok=False)
    if args.demo:
        demo_files(folder)
        args.old, args.new = folder / "old.csv", folder / "new.csv"
        args.old_meta, args.new_meta = folder / "old.json", folder / "new.json"
        args.expected = folder / "expected.csv"
    if not all((args.old, args.new, args.old_meta, args.new_meta)):
        parser.error("Use --demo or supply --old, --new, --old-meta and --new-meta")
    old_meta = json.loads(args.old_meta.read_text(encoding="utf-8"))
    new_meta = json.loads(args.new_meta.read_text(encoding="utf-8"))
    rows, summary = compare(args.old, args.new, old_meta, new_meta, args.expected)
    summary["mode"] = "SYNTHETIC_DEMO" if args.demo else "USER_SUPPLIED_FILES"
    summary["created_at_utc"] = datetime.now(timezone.utc).isoformat()
    summary["inputs"] = {n: str(getattr(args, n)) for n in ("old", "new", "old_meta", "new_meta", "expected")}
    summary["declared_metadata"] = {"old": old_meta, "new": new_meta}
    summary["input_sha256"] = {n: hashlib.sha256(getattr(args, n).read_bytes()).hexdigest()
                               for n in ("old", "new", "old_meta", "new_meta", "expected") if getattr(args, n)}
    csv_write(folder / "row_comparison.csv", rows,
              ["symbol", "trade_date", "status", "old_rows", "new_rows", "old_close", "new_close", "new_minus_old", "expected_key"])
    (folder / "comparison_report.json").write_text(json.dumps(summary, ensure_ascii=False, indent=2), encoding="utf-8")
    columns = ("symbol", "trade_date", "old_close", "new_close", "status", "new_minus_old")
    header = "".join(f"<th>{html.escape(c)}</th>" for c in columns)
    body = "".join("<tr>" + "".join(f"<td>{html.escape(str(r[c]))}</td>" for c in columns) + "</tr>" for r in rows)
    view = ("<!doctype html><html lang='en'><meta charset='utf-8'><meta name='viewport' content='width=device-width'>"
            "<title>Migration comparison</title><style>body{max-width:1000px;margin:40px auto;padding:0 20px;"
            "font:17px system-ui;background:#f8f4eb;color:#123349}table{border-collapse:collapse;width:100%}"
            "th,td{padding:12px;border-bottom:1px solid #ccd3d6;text-align:left}pre{white-space:pre-wrap}"
            ".label{padding:14px;background:#fae2b9;border-radius:8px}</style>"
            "<h1>迁移对齐结果 / Migration comparison</h1><p class='label'>"
            + html.escape(summary["data_kind"]) + " — demonstration or user-supplied input; not a production approval.</p>"
            + "<p>" + html.escape(summary["conclusion"]) + "</p><table><thead><tr>" + header
            + "</tr></thead><tbody>" + body + "</tbody></table><h2>Settings requiring review</h2><pre>"
            + html.escape(json.dumps(summary["comparability_issues"], ensure_ascii=False, indent=2))
            + "</pre><p>HUMAN_REVIEW_REQUIRED. Missing values stay missing. Differences require investigation.</p></html>")
    (folder / "comparison_view.html").write_text(view, encoding="utf-8")
    print(json.dumps({"output": str(folder), "mode": summary["mode"], "counts": summary["counts"],
                      "conclusion": summary["conclusion"], "deployment_signoff": summary["deployment_signoff"]}))


if __name__ == "__main__":
    main()

Related articles

Choosing a Stock Price API: What Your Quote Dashboard Actually Needs

For financial app product leads, choosing a stock price API starts with the features a dashboard must deliver. This guide separates launch requirements from optional history, order-book and trade-data features, then turns them into a practical requirements sheet. A recorded TickDB MCP sample shows how to inspect the returned structure and timestamps. The article includes acceptance criteria and a reusable sample-checking script, so product and engineering teams can work from the same definition of done.

TickDB Research ·

Free Stock APIs: What to Check Before Moving From Research to an App

For product leads turning a research prototype into a market dashboard, choosing a free stock API takes more than getting a successful response. Using a 20-stock watchlist refreshed every ten seconds, this guide separates data access, request budgets, streaming limits and permitted use. It draws on official documentation for AKShare, Alpha Vantage, Twelve Data and TickDB, adds a recorded TickDB MCP query, and provides a practical decision worksheet and runnable Python quota calculator.

TickDB Research ·

The Complete Stock API Guide: 44 Global and China-Market Options

Bloomberg, LSEG, FactSet, Massive, Alpha Vantage, Databento, Wind, Tushare, and AKShare address very different data needs. This guide organizes 44 providers, platforms, and tools into ten categories, then maps them to investment research, backtesting, alerts, financial apps, AI workflows, and trading integrations. Use it to build a shortlist, understand access requirements, and test a realistic sample. It includes a complete Python example, downloadable-data workflows, and reusable requirements and acceptance checklists.

TickDB Research ·

Using a Stock API: Why Quote Displays and Research Exports Need Different Rules

For financial product managers building a stock page with a quote display and historical export, connecting the API is only part of the task. This guide explains how snapshots, price bars, and CSV files differ, why a record's timestamp does not establish when its final value was available, and how to turn saved TickDB responses into a timestamped static quote card and a date-filtered research CSV. A runnable Python example makes the output rules inspectable.

TickDB Research ·

Forex WebSocket API Tutorial: Stream EUR/USD and Check Quotes After Reconnecting

For developers building an FX dashboard or price alert, a reopened connection is only part of recovery. The application also needs a valid quote for the right currency pair, a usable data timestamp, and a visible record of the interruption. This tutorial uses a real TickDB EURUSD stream to show the first subscription, a controlled disconnect, resubscription, and quote checks. The download includes the bounded Node.js runner, original messages, event logs, and an offline checker.

TickDB Research ·