yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

Fetch MarketCap historically

Open dvirginz opened this issue 2 years ago • 3 comments

Using the provided code we can fetch one of the following data points

  1. The current MarketCap
  2. Historical data of Open High Low Close and Volume
msft = yf.Ticker("MSFT")
msft.info['marketCap']
msft.history()

Can we somehow can historical information of the marketcap?

Thanks.

dvirginz avatar May 27 '22 07:05 dvirginz

The MarketCap history doesn't seem to be available on yahoo finance and if you wanted to build the MarketCap history from the history of the stock prices, you would also need the history of outstanding shares. You can maybe assume constant number of outstanding shares over a short recent period and multiply it by your stock price history to get your market cap numbers.

ProgrammingDao avatar Jul 03 '22 10:07 ProgrammingDao

Yes, unfortunately, as you know, this is not a fair assumption

On Sun, Jul 3, 2022, 13:22 AntoineV @.***> wrote:

The MarketCap history doesn't seem to be available on yahoo finance and if you wanted to build the MarketCap history from the history of the stock prices, you would also need the history of outstanding shares. You can maybe assume constant number of outstanding shares over a short recent period and multiply it by your stock price history to get your market cap numbers.

— Reply to this email directly, view it on GitHub https://github.com/ranaroussi/yfinance/issues/1008#issuecomment-1173054135, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHM4A75CTVXLO4K6HR2UWC3VSFSWVANCNFSM5XDMUT3A . You are receiving this because you authored the thread.Message ID: @.***>

dvirginz avatar Oct 11 '22 08:10 dvirginz

I'm reopening this because I have a solution: branch feature/share-count will provide you a few years of share count. It's a weird mix of daily, weekly and monthly. Combine with price for MarketCap.

If you want to try now and give feedback, this discussion explains how to download. Use property shares_full

ValueRaider avatar Oct 11 '22 10:10 ValueRaider

Ticker.get_shares_full() is your friend.

ValueRaider avatar Mar 14 '24 21:03 ValueRaider