How to find yfinance ticker symbols for Indian stocks?

Trick to find the Ticker Symbol of NSE listed stocks to download financial data using yfinance.

By

You can use Yahoo Finance Python package to get lots of financial information about a given stock.

But people often wonder how to find the ticker symbols for a listed NSE companies. 

For example, you want to find the stock prices for HDFC Bank. So, you write -

import yfinance as yahoo_finance


def get_ticker_daily_price(symbol, period="1mo"):
    tickerBase = yahoo_finance.Ticker(symbol)
    data = tickerBase.history(period)
    print(data)


if __name__ == '__main__':
    get_ticker_daily_price('HDFCBANK')  # incorrect symbol

And you get the below error -

- HDFCBANK: No data found, symbol may be delisted
Empty DataFrame
Columns: [Open, High, Low, Close, Adj Close, Volume]
Index: []

So, you wonder how to find the proper "symbol" for HDFC bank.

Well, it's easy.

  1. Check the name of the ticker in Official NSE's list. For a direct link, use this.
  2. Add .NS at the end of the ticker.

So, for HDFCBANK, it will be HDFCBANK.NS and so on.

 

Terms Privacy Feed