How to Calculate PE ratio for ETFs via Python in Colab - QQQ
ETFs are becoming more and more popular options for investors recently to not only participate the markets but enjoy some level of diversification compared to owning an individual ticket (especially for passive ETFs and indexing funds).
Some large ETFs passively track stock market indices enable investors to invest a basket of equities. However, does it mean that we don’t need to evaluate an equity ETF is expensive?
PE ratio plays crucial role when we gauge if a stock symbol is at a proper price. This information is quite common for individual stocks across the platforms and brokers, but I only see few places report this number for ETFs.
In this series of articles, we are going to show you how to calculate PE ratio for ETFs so that you can evaluate the values by yourself and rebalance your portfolio independently and agilely.
Let’s first put everything together for Invesco QQQ.
Step 0
We first need to know the definition of PE ratio.
Install all required packages.
!pip install pandas
!pip install yfinance
Step 1
Get the previous close price for QQQ.
import yfinance as yf
tickers = yf.Tickers('QQQ')
previousClose_QQQ = tickers.tickers['QQQ'].info.get('previousClose')
previousClose_QQQ
Keep reading with a 7-day free trial
Subscribe to Informula to keep reading this post and get 7 days of free access to the full post archives.