0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

API忘備録: yfinanceのエラーYFTzMissingError (“No timezone found”) の対処方法

Last updated at Posted at 2025-04-07

はじめに

株価等のデータ取得にyfinanceを実施していますが、最近 2025/2月から以下のエラーが報告されています。

yfinance.exceptions.YFTzMissingError: $%ticker%: possibly delisted; no timezone found

原因

どうやら今年の2月頃から、Yahooが既存のUser-Agentヘッダをブロックし始めたようで、リクエストにエラーが出ていました。幸い、yfinance 0.2.54以降のバージョン(現在は0.2.55)でこのエラーに対応しているのでアップデートすることをお勧めします。

対処

以下のアップデートコマンドを利用します。

pip install --upgrade yfinance
pip show yfinance

私はMambaを利用しているので、以下を利用しました。

 mamba install -c conda-forge --force-reinstall yfinance
 mamba list yfinance

パイソンを利用している場合は、以下のコマンドで実際のyfinanceの利用バージョンを確認できます。

import yfinance as yf
print("yfinance version:", yf.__version__)

仮想環境やIPythonのインタラクティブ環境を利用している場合は、その環境でバージョンが利用されているか確認していみてください。

Ctr+Shift+Pでパイソン環境を選択できます。

私の場合は、IPythonの環境を利用している為、以下のPython環境も変更するがありました。

image.png

終わりに

今回は完全な忘備録ですが、ChatGPTのDeepSearchで助けてもらえました。この機能でも30分ぐらいネット検索して、考えていたので、あまり多く知られていないFixなのでしょうね。

ではまた。

Happy Hacking!!!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?