Informula

Informula

Share this post

Informula
Informula
How to Calculate PE ratio for ETFs via Python in Colab - QCLN

How to Calculate PE ratio for ETFs via Python in Colab - QCLN

Informula's avatar
Informula
Sep 22, 2023
∙ Paid

Share this post

Informula
Informula
How to Calculate PE ratio for ETFs via Python in Colab - QCLN
Share

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 QCLN.

The Nasdaq Clean Edge Green Energy Index (CELS) is a modified market capitalization-weighted index designed to track the performance of companies that are manufacturers, developers, distributors, and/or installers of clean-energy technologies.

Fund Top Holdings

Step 0

  • We first need to know the definition of PE ratio.

The price-to-earnings (P/E) ratio relates a company’s share price to its earnings per share. A high P/E ratio could mean that a company’s stock is overvalued, or that investors are expecting high growth rates in the future.

  • Install all required packages.

!pip install pandas
!pip install yahoo_fin
!pip install requests

Step 1: Get the shares held by holdings. Unlike the previous articles we were downloading Excel or csv and parse the file to locate the information. We are using pandas to parse the html to locate the table hold the shares/ market value information.

import pandas as pd
import requests

res = requests.get('https://www.ftportfolios.com/Retail/Etf/EtfHoldings.aspx?Ticker=QCLN')
res.encoding = 'big5'
html_df = pd.read_html(res.text)

df_QCLN = html_df[10]

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.

Already a paid subscriber? Sign in
© 2025 Informula
Privacy ∙ Terms ∙ Collection notice
Start writingGet the app
Substack is the home for great culture

Share