ranaroussi / yfinance

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

stock.info.get("preMarketPrice") returning None, even tho the pre-market price exist on the website #1393

Open xxredxoctoberxx opened 1 year ago

xxredxoctoberxx commented 1 year ago

hey, ive encountaered problem in scraping pre-market price of stocks, since the last API update. many tickers returning None during pre-market, even tho i can see the price is there on the website. Here's an example:

image

now im running this code: ticker = yf.Ticker("OPBK") price = ticker.info.get("preMarketPrice") print(f"pre market price = {price}") resulted out put: pre market price = None

mention: it used to work before the last API update. Any ideas?

ValueRaider commented 1 year ago

My fast_info update didn't interfere with this particular key, so something must have changed in the data Yahoo returns.

robertluisw commented 1 year ago

I have the same issue. A lot of the fields are returning "None". I'm working with version

import yfinance as yf import pandas as pd ticker = 'APPL' yf.Ticker(ticker).info {'quoteType': 'MUTUALFUND', 'gmtOffSetMilliseconds': '-18000000', 'market': 'us_market', 'isEsgPopulated': False, 'quoteSourceName': 'Delayed Quote', 'averageDailyVolume3Month': None, 'regularMarketTime': 1561759658, 'volume24Hr': None, 'shortName': None, 'longName': None, 'regularMarketChange': None, 'preMarketPrice': None, 'exchangeDataDelayedBy': 0, 'toCurrency': None, 'postMarketChange': None, 'postMarketPrice': None, 'exchangeName': 'YHD', 'preMarketChange': None, 'circulatingSupply': None, 'priceHint': 2, 'lastMarket': None, 'regularMarketSource': 'DELAYED', 'openInterest': None, 'marketState': 'REGULAR', 'underlyingSymbol': None, 'volumeAllCurrencies': None, 'strikePrice': None, 'maxAge': 1, 'fromCurrency': None, 'logo_url': '', 'trailingPegRatio': None}

ValueRaider commented 1 year ago

@robertluisw Wrong, that ticker doesn't exist.

laatus commented 6 months ago

I do have the same problem here, I can not get the preMarketPrice

ValueRaider commented 6 months ago

Note sure why I closed this.

To be precise - yfinance isn't returning None, Python is, that's the behaviour of get() when key not present.

The old yfinance simply scraped the Yahoo quote webpage , but new version is querying API, so solution is figuring out how Yahoo webpage gets pre-market price from API.