How to Calculate PE ratio for ETFs via Python in Colab - 00878.TW
Previously on the How to Calculate PE ratio for ETFs via Python in Colab — QQQ, we discussed how to calculate PE ratio for Invesco QQQ. In this article, we are discussing how to calculate the PE for an ETF in Taiwan Market 00878.
Step 0: Install all required packages.
!pip install openpyxl
!pip install yahoo_fin
Step 1: You can find out the link to download the Excel. Let’s retrieve and name it as data.xlsx.
import urllib
from openpyxl import load_workbook
dls = "https://cwapi.cathaysite.com.tw/api/ETF/DownloadETFWeightExcel?FundCode=CN&SearchDate=2023-07-18"
urllib.request.urlretrieve(dls, "data.xlsx")
wb = load_workbook(filename='data.xlsx', read_only=True)
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.