ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
12.52k stars 2.25k forks source link

Is it possible that `ticker.info` is reporting fewer keys than before? (since circa Aug 1 2023) #1649

Closed init-js closed 4 months ago

init-js commented 11 months ago

Simple code that reproduces your problem

I was banking on Ticker.info giving me the company address, the name of the CEO, etc. It used to, but no longer seems to be doing that since... maybe two days ago (Aug 1st?)

Maybe this is a recurring event -- yahoo data model changing under our feet?

I'm new to yfinance. I read elsewhere that it can return bad data when makeing too many requests. I doubt I'm being throttled, but it's not impossible. (I've made 100 request tops in one week).

>>> import yfinance as yf
>>> yf.__version__
'0.2.26'
>>> t = yf.Ticker("MSFT")
>>> t.info
{'maxAge': 86400, 'priceHint': 2, 'previousClose': 336.34, 'open': 333.63, 'dayLow': 326.3551, 'dayHigh': 333.4,
'regularMarketPreviousClose': 336.34, 'regularMarketOpen': 333.63, 'regularMarketDayLow': 326.3551, 
'regularMarketDayHigh': 333.4, 'trailingPE': 35.482124, 'forwardPE': 25.992064, 'volume': 27456267,
 'regularMarketVolume': 27456267, 'averageVolume': 28889145, 'averageVolume10days': 36943900,
 'averageDailyVolume10Day': 36943900, 'bid': 0.0, 'ask': 0.0, 'bidSize': 800, 'askSize': 1000,
 'marketCap': 2435122987008, 'fiftyTwoWeekLow': 213.43, 'fiftyTwoWeekHigh': 366.78, 
'fiftyDayAverage': 335.8854, 'twoHundredDayAverage': 278.6426,
 'trailingAnnualDividendRate': 2.72, 'trailingAnnualDividendYield': 0.008087055, 'currency': 'USD',
 'exchange': 'NMS', 'quoteType': 'EQUITY', 'symbol': 'MSFT', 'underlyingSymbol': 'MSFT', 
'shortName': 'Microsoft Corporation', 'longName': 'Microsoft Corporation',
 'firstTradeDateEpochUtc': 511108200, 'timeZoneFullName': 'America/New_York',
 'timeZoneShortName': 'EDT', 'uuid': 'b004b3ec-de24-385e-b2c1-923f10d3fb62', 
'messageBoardId': 'finmb_21835', 'gmtOffSetMilliseconds': -14400000, 'currentPrice': 327.5,
 'targetHighPrice': 433.4, 'targetLowPrice': 232.0, 'targetMeanPrice': 384.85, 'targetMedianPrice': 400.0,
 'recommendationMean': 1.8, 'recommendationKey': 'buy', 'numberOfAnalystOpinions': 43, 'financialCurrency': 'USD', 'trailingPegRatio': 2.4704}

I unfortunately don't have a snapshot of what the old info used to look like, but from memory, it seems to match what this tutorial is giving as example output: https://analyzingalpha.com/yfinance-python

dhr = yf.Ticker('DHR')
info = dhr.info
info.keys()
dict_keys(['zip', 'sector', 'fullTimeEmployees', 'longBusinessSummary',
 'city', 'phone', 'state', 'country', 'companyOfficers', 'website',
'maxAge', 'address1', 'fax', 'industry', 'address2', 'ebitdaMargins',
'profitMargins', 'grossMargins', 'operatingCashflow', 'revenueGrowth',
'operatingMargins', 'ebitda', 'targetLowPrice', 'recommendationKey',
'grossProfits', 'freeCashflow', 'targetMedianPrice', 'currentPrice',
'earningsGrowth', 'currentRatio', 'returnOnAssets', 'numberOfAnalystOpinions',
'targetMeanPrice', 'debtToEquity', '...'])

Notice that keys fullTimeEmployees, city, phone, fax etc All of those are gone in the current info.

Debug log

import logging
import yfinance as yf
import sys

loglevel=logging.DEBUG
root = logging.getLogger(__package__)
root.setLevel(loglevel)
ch = logging.StreamHandler(sys.stderr)
ch.setLevel(loglevel)
formatter = logging.Formatter('[%(asctime)s] %(name)s %(levelname)s %(message)s')
ch.setFormatter(formatter)
root.addHandler(ch)

t = yf.Ticker("DHR")
print(t.info)
[2023-08-03 01:47:58,701] urllib3.connectionpool DEBUG Starting new HTTPS connection (1): query2.finance.yahoo.com:443
[2023-08-03 01:47:58,763] urllib3.connectionpool DEBUG https://query2.finance.yahoo.com:443 "GET /v6/finance/quoteSummary/DHR?modules=financialData&modules=quoteType&modules=defaultKeyStatistics&modules=assetProfile&modules=summaryDetail&ssl=true HTTP/1.1" 200 1266
[2023-08-03 01:47:58,769] urllib3.connectionpool DEBUG Starting new HTTPS connection (1): query1.finance.yahoo.com:443
[2023-08-03 01:47:58,823] urllib3.connectionpool DEBUG https://query1.finance.yahoo.com:443 "GET /ws/fundamentals-timeseries/v1/finance/timeseries/DHR?symbol=DHR&type=trailingPegRatio&period1=1675296000&period2=1691107200 HTTP/1.1" 200 361
{'maxAge': 86400, 'priceHint': 2, 'previousClose': 255.0, 'open': 254.21, 'dayLow': 253.0, 'dayHigh': 258.755, 'regularMarketPreviousClose': 255.0, 'regularMarketOpen': 254.21, 'regularMarketDayLow': 253.0, 
'regularMarketDayHigh': 258.755, 'trailingPE': 30.23095, 'forwardPE': 26.584536, 'volume': 2545214,
 'regularMarketVolume': 2545214, 'averageVolume': 3288670, 'averageVolume10days': 4479960, 
'averageDailyVolume10Day': 4479960, 'bid': 0.0, 'ask': 259.85, 'bidSize': 800, 'askSize': 800, 'marketCap': 190398824448, 'fiftyTwoWeekLow': 221.22, 'fiftyTwoWeekHigh': 303.82, 'fiftyDayAverage': 240.0756, 
'twoHundredDayAverage': 251.0096, 'trailingAnnualDividendRate': 1.04, 
'trailingAnnualDividendYield': 0.004078431, 'currency': 'USD', 'exchange': 'NYQ', 'quoteType': 'EQUITY', 
'symbol': 'DHR', 'underlyingSymbol': 'DHR', 'shortName': 'Danaher Corporation', 
'longName': 'Danaher Corporation', 'firstTradeDateEpochUtc': 283789800,
 'timeZoneFullName': 'America/New_York', 'timeZoneShortName': 'EDT', 'uuid': '295d410e-b8c1-3fcf-8a32-c618d752812e', 'messageBoardId': 'finmb_265621', 'gmtOffSetMilliseconds': -14400000,
 'currentPrice': 257.87, 'targetHighPrice': 325.0, 'targetLowPrice': 230.0, 'targetMeanPrice': 282.52, 
'targetMedianPrice': 280.9, 'recommendationMean': 2.0, 'recommendationKey': 'buy', 
'numberOfAnalystOpinions': 21, 'grossProfits': 18949000000, 'financialCurrency': 'USD',
 'trailingPegRatio': 5.8785}

Bad data proof

I'm not saying that it's returning bad data, but it definitely has a different shape than I expected.

Based on my previous experience a few days ago, and this online tutorial:

https://analyzingalpha.com/yfinance-python

(search for "dhr.info")

yfinance version

0.2.26

Python version

3.10+

Operating system

WSL2

ValueRaider commented 11 months ago

Others have seen change #1645. Info was returning ~150 entries

init-js commented 11 months ago

Looks like it's back to normal today...

>>> t = yf.Ticker("MSFT")
>>> x = t.info
>>> print(json.dumps(x, indent=2))
{
  "address1": "One Microsoft Way",
  "city": "Redmond",
  "state": "WA",
  "zip": "98052-6399",
  "country": "United States",
  "phone": "425 882 8080",
  "website": "https://www.microsoft.com",
  "industry": "Software\u2014Infrastructure",
  "industryDisp": "Software\u2014Infrastructure",
  "sector": "Technology",
  "sectorDisp": "Technology",
  "longBusinessSummary": "Microsoft Corporation develops and supports software, services, devices and solutions worldwide. The Productivity and Business Processes segment offers office, exchange, SharePoint, Microsoft Teams, office 365 Security and Compliance, Microsoft viva, and Microsoft 365 copilot; and office consumer services, such as Microsoft 365 consumer subscriptions, Office licensed on-premises, and other office services. This segment also provides LinkedIn; and dynamics business solutions, including Dynamics 365, a set of intelligent, cloud-based applications across ERP, CRM, power apps, and power automate; and on-premises ERP and CRM applications. The Intelligent Cloud segment provides server products and cloud services, such as azure and other cloud services; SQL and windows server, visual studio, system center, and related client access licenses, as well as nuance and GitHub; and enterprise services including enterprise support services, industry solutions, and nuance professional services. The More Personal Computing segment offers Windows, including windows OEM licensing and other non-volume licensing of the Windows operating system; Windows commercial comprising volume licensing of the Windows operating system, windows cloud services, and other Windows commercial offerings; patent licensing; and windows Internet of Things; and devices, such as surface, HoloLens, and PC accessories. Additionally, this segment provides gaming, which includes Xbox hardware and content, and first- and third-party content; Xbox game pass and other subscriptions, cloud gaming, advertising, third-party disc royalties, and other cloud services; and search and news advertising, which includes Bing, Microsoft News and Edge, and third-party affiliates. The company sells its products through OEMs, distributors, and resellers; and directly through digital marketplaces, online, and retail stores. The company was founded in 1975 and is headquartered in Redmond, Washington.",
  "fullTimeEmployees": 221000,
  "companyOfficers": [
    {
      "maxAge": 1,
      "name": "Mr. Satya  Nadella",
      "age": 55,
      "title": "Chairman & CEO",
      "yearBorn": 1967,
      "fiscalYear": 2022,
      "totalPay": 12676750,
      "exercisedValue": 0,
      "unexercisedValue": 0
    },
    {
      "maxAge": 1,
      "name": "Mr. Bradford L. Smith LCA",
      "age": 63,
      "title": "Pres & Vice Chairman",
      "yearBorn": 1959,
      "fiscalYear": 2022,
      "totalPay": 4655274,
      "exercisedValue": 0,
      "unexercisedValue": 0
    },
    {
      "maxAge": 1,
      "name": "Ms. Amy E. Hood",
      "age": 50,
      "title": "Exec. VP & CFO",
  "twoHundredDayAverage": 278.6426,
  "trailingAnnualDividendRate": 2.72,
  "trailingAnnualDividendYield": 0.008305344,
  "currency": "USD",
  "enterpriseValue": 2467111632896,
  "profitMargins": 0.34146,
  "floatShares": 7423671316,
  "sharesOutstanding": 7435489792,
  "sharesShort": 42497800,
  "sharesShortPriorMonth": 44270818,
  "sharesShortPreviousMonthDate": 1686787200,
  "dateShortInterest": 1689292800,
  "sharesPercentSharesOut": 0.0057,
  "heldPercentInsiders": 0.00052,
  "heldPercentInstitutions": 0.73212,
  "shortRatio": 1.66,
  "shortPercentOfFloat": 0.0057,
  "impliedSharesOutstanding": 0,
  "bookValue": 27.748,
  "priceToBook": 11.816709,
  "lastFiscalYearEnd": 1688083200,
  "nextFiscalYearEnd": 1719705600,
  "mostRecentQuarter": 1688083200,
  "earningsQuarterlyGrowth": 0.2,
  "netIncomeToCommon": 72361000960,
  "trailingEps": 9.23,
  "forwardEps": 11.44,
  "pegRatio": 2.51,
  "lastSplitFactor": "2:1",
  "lastSplitDate": 1045526400,
  "enterpriseToRevenue": 11.642,
  "enterpriseToEbitda": 24.182,
  "52WeekChange": 15.459192,
  "SandP52WeekChange": 8.705568,
  "lastDividendValue": 0.68,
  "lastDividendDate": 1684281600,
  "exchange": "NMS",
  "quoteType": "EQUITY",
  "symbol": "MSFT",
  "underlyingSymbol": "MSFT",
  "shortName": "Microsoft Corporation",
  "longName": "Microsoft Corporation",
  "firstTradeDateEpochUtc": 511108200,
  "timeZoneFullName": "America/New_York",
  "timeZoneShortName": "EDT",
  "uuid": "b004b3ec-de24-385e-b2c1-923f10d3fb62",
  "messageBoardId": "finmb_21835",
  "gmtOffSetMilliseconds": -14400000,
  "currentPrice": 327.89,
  "targetHighPrice": 393.72,
  "targetLowPrice": 210.76,
  "targetMeanPrice": 350.67,
  "targetMedianPrice": 363.38,
  "recommendationMean": 1.8,
  "recommendationKey": "buy",
  "numberOfAnalystOpinions": 43,
  "totalCash": 111256002560,
  "totalCashPerShare": 14.974,
  "ebitda": 102022995968,
  "totalDebt": 79441002496,
  "quickRatio": 1.536,
  "currentRatio": 1.769,
  "totalRevenue": 211914997760,
  "debtToEquity": 38.522,
  "revenuePerShare": 28.46,
  "returnOnAssets": 0.14245,
  "returnOnEquity": 0.38824,
  "freeCashflow": 47268999168,
  "operatingCashflow": 87581999104,
  "earningsGrowth": 0.202,
  "revenueGrowth": 0.083,
  "grossMargins": 0.6892,
  "ebitdaMargins": 0.48143002,
  "operatingMargins": 0.41772997,
  "financialCurrency": "USD",
  "trailingPegRatio": 2.4704
}

>>> datetime.utcnow().isoformat()
'2023-08-03T18:49:51.237383'
ValueRaider commented 11 months ago

Spooky. Leave issue open in case happens again.

jkoestner commented 11 months ago

I had an issue yesterday as well, but since all yfinance is doing is giving us a nice format I'm also keeping tabs on the query to yahoo shown below. #1592 also discusses how to get the crumb.

https://query1.finance.yahoo.com/v10/finance/quoteSummary/AMD?modules=summaryProfile%2CupgradeDowngradeHistory%2Cpageviews%2Cquotetype&ssl=true&crumb=

vismoh2010 commented 11 months ago

Same issue here, any solution available?

vismoh2010 commented 11 months ago

For the past 1 week, my app has not been working because of this, please rectify this soon, or at least give some update.

ValueRaider commented 11 months ago

Does #1657 help?

vismoh2010 commented 11 months ago

1657 fixes all my issues @ValueRaider. Please merge ASAP.

Doshinkyo commented 10 months ago

I've been having trouble with missing keys in the dictionary returned by info()

I believe that in Jan 2023 the following were all returned but are not returned right now (Sep 2023)

algorithm annualHoldingsTurnover annualReportExpenseRatio beta3Year category circulatingSupply coinMarketCapLink exchangeTimezoneName exchangeTimezoneShortName expireDate fiveYearAverageReturn fromCurrency fundFamily fundInceptionDate isEsgPopulated lastCapGain lastMarket legalType logo_url market maxSupply morningStarOverallRating morningStarRiskRating navPrice openInterest preMarketPrice regularMarketPrice revenueQuarterlyGrowth startDate strikePrice threeYearAverageReturn toCurrency totalAssets tradeable volume24Hr volumeAllCurrencies yield ytdReturn

vdahmane commented 8 months ago

Hello, Same problem. After migrating to v10 api version, I notice that some key is missing like sector, company information, etc...

ValueRaider commented 8 months ago

I think I stumbled upon root problem and fixed it in #1657 (commit https://github.com/ranaroussi/yfinance/pull/1657/commits/2f241e60306436ab76c2d14f0627c19f59795aeb). Fix doesn't have to be in same PR, but (i) info broken anyway and (ii) I need more competent people to test #1657 and feedback/improve so using fix as bait.

nikso91640 commented 6 months ago

Hi guys,

I'm still having this problem, because there's a lot of information missing.

I've tried to figure out how to proceed, but I need your help.

Thank you and have a great holiday season!

ValueRaider commented 4 months ago

Because code has changed significantly, and not clear what versions y'all were running, I'm closing this. Create new bug report if issue still happens with details.