Algo Trading
Fetching PE, PB Ratios, and Dividend Yields from NSE Using Python

FabTrader
For algo traders and investors, keeping track of fundamental index metrics like Price-to-Earnings (PE) Ratio, Price-to-Book (PB) Ratio, and Dividend Yield is crucial for making informed decisions. If you're looking for a way to automate the retrieval of these metrics for all indices listed on the National Stock Exchange (NSE) of India, this Python utility will come in handy.

Why Track PE, PB, and Dividend Yield?
- PE Ratio: Indicates how expensive or cheap an index is compared to its earnings.
- PB Ratio: Helps assess whether an index is overvalued or undervalued based on book value.
- Dividend Yield: A key metric for income-seeking investors to evaluate returns from dividends.
Automating Data Retrieval
Rather than manually checking the NSE website for these values, I have developed a Python utility that fetches and structures the data into a pandas DataFrame. This makes it easier to integrate into trading algorithms, financial dashboards, and custom analysis tools.
How It Works
The utility uses NseUtility, a Python module that I have built earlier, to pull the latest data for all indices. With just a few lines of code, you can fetch and display the PE, PB, and Dividend Yield for all indices on the NSE.
Here's how you can use it:
Copy the main NseUtility Python Class from my main blog article >> HERE and include / import it into your code as explained the video.
import NseUtility
# Create an instance of NseUtility
nse = NseUtility.NseUtils()
# Fetch PE, PB, and Dividend Yield data
print(nse.get_index_pe_ratio().head())
print(nse.get_index_pb_ratio().head())
print(nse.get_index_div_yield().head())More from Algo Trading
Algo Trading Cost in India: How I Built a Reliable Setup for ₹150/Month
Wondering how much algo trading costs in India? In this article, I break down the real expenses involved in running an algorithmic...
When Your Job Feels Shaky: Can Trading Become an Alternate Income Stream?
Can trading become a stable source of income in India? While many consider it during times of job uncertainty, the reality is...
How Much Capital Do You Really Need for Sustainable Trading Income in India?
How much capital is needed for sustainable trading income in India? This in-depth guide explores the realistic returns traders can expect, the...
