admin管理员组

文章数量:1332383

In finance as I am learning we have Sectors and within the Sectors we have Industries.

I am trying to get the Market Cap through the yfinance API through the following code:

import yfinance as yf
tech = yf.Sector('technology')
software = yf.Industry('software-infrastructure')
print(tech.overview)

But the answer is:

AttributeError: module 'yfinance' has no attribute 'Sector'`

May it be related with yfinance API instead of my usage?

I am applying what's written in the documentation.

In finance as I am learning we have Sectors and within the Sectors we have Industries.

I am trying to get the Market Cap through the yfinance API through the following code:

import yfinance as yf
tech = yf.Sector('technology')
software = yf.Industry('software-infrastructure')
print(tech.overview)

But the answer is:

AttributeError: module 'yfinance' has no attribute 'Sector'`

May it be related with yfinance API instead of my usage?

I am applying what's written in the documentation.

Share edited Nov 22, 2024 at 18:18 SinonCuriosus asked Nov 22, 2024 at 5:11 SinonCuriosusSinonCuriosus 11 bronze badge 2
  • 1 Where did you get yfinance? What version is it? What version of Python? It has been a fairly dynamic package as Yahoo changes its rules periodically. – Tim Roberts Commented Nov 22, 2024 at 6:16
  • The yfinance version I had was "0.2.40" I've just upgraded it to the newest that is "0.2.50" and it worked! Lesson: When the documentation says something, just checkout if your package is the most updated, just passed by me. Much appreciated your time Tim! – SinonCuriosus Commented Nov 22, 2024 at 11:04
Add a comment  | 

1 Answer 1

Reset to default 0

It seems that I was working with a deprecated yfinance version.

I've solved it by upgrading the package through the command "pip install --upgrade yfinance" as Tim raised under the comments.

本文标签: yfinanceProblem when trying to get Sector Market CapStack Overflow