FabTrader_Logo_Main
  • Home
  • Courses
    • Build Algo Trading Platform using Python Course
  • Store
  • Tools
  • Stories
  • About Me
Edit Content
FabTrader_Logo_Main
Welcome to FabTrader Community!

Course Dashboard
Store Account
Cart
Algo Trading Course
Other Courses
About Me
Store
Stories

Get in touch with me

hello@fabtrader.in

blog banner background shape images
  • FabTrader
  • March 18, 2025

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

  • 3 min read
  • 300 Views

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())


Applications for Algo Traders
  1. Market Valuation Checks: Use PE and PB ratios to determine market conditions before executing trades.
  2. Index Comparison: Compare fundamental metrics of different indices to spot investment opportunities.
  3. Portfolio Rebalancing: Incorporate dividend yield data to optimize a dividend-focused strategy.
Where to Get the Utility?

This utility is part of a broader Python package that I created to fetch live data from NSE India. You can read more about it and how to set it up in my previous article: A Python Utility to Fetch Live Data from NSE India.

Final Thoughts

If you’re an algo trader, financial analyst, or investor, automating the retrieval of fundamental index data can significantly enhance your decision-making process. Feel free to integrate this utility into your workflows and let me know how it helps!

For more trading tools, insights, and Python-based finance utilities, stay tuned to FabTrader!


Support this community : FabTrader.in is a one-person initiative dedicated to helping individuals on their F.I.R.E. journey. Running and maintaining this community takes time, effort, and resources. If you’ve found value in the content, consider making a donation to support this mission.

Donate

Disclaimer: The information provided in this article is for educational and informational purposes only and should not be construed as financial, investment, or legal advice. The content is based on publicly available information and personal opinions and may not be suitable for all investors. Investing involves risks, including the loss of principal. Always conduct your own research and consult a qualified financial advisor before making any investment decisions. The author and website assume no liability for any financial losses or decisions made based on the information presented.

FabTrader

Vivek is an algorithmic trader, Python programmer, and a passionate advocate of the F.I.R.E. (Financial Independence, Retire Early) movement. He achieved his financial independence at the age of 45 and is dedicated to helping others embark on their own journeys toward financial freedom.

Home
Store
Stories
Algo Trading Platform Using Python Course
About Me

©2024 Fabtrader.in - An unit of Rough Sketch Company. All Rights Reserved

Terms & Conditions
Privacy Policy