Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences…

Follow publication

How to get Indian stock data using pandas_datareader?

Tushar Tiwari
Nerd For Tech
Published in
1 min readJul 17, 2021

--

In this blog post, I will guide you through how to get stock data of #NSE (National Stock Exchange data).

Data collection is often the most overlooked part by the beginner Data Scientist.

Let’s get Started

  1. Get a list of stock tickers. Link for Most liquid and F & O stock.

2. Install pandas_datareader: using

pip install pandas_datareader

3. Some required imports:

import pandas as pd
import pandas_datareader as pdr
import time

4. Extracting the stock symbol names.

Stock Selection

5. Defining a function named fetch_data which takes input as the symbol name and saves the stock prices in the specified directory here it is ‘stock_data/’.

Extracting stock data function

6. Running the fetch_data function for the selected stocks.

Fetching stock data for selected stocks

Here I have used time.sleep(10) as Yahoo API is stopping form making many requests in short time.

Note: This does not work in google colab so try this on your computer.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Nerd For Tech
Nerd For Tech

Published in Nerd For Tech

NFT is an Educational Media House. Our mission is to bring the invaluable knowledge and experiences of experts from all over the world to the novice. To know more about us, visit https://www.nerdfortech.org/.

Tushar Tiwari
Tushar Tiwari

Written by Tushar Tiwari

Finding insights from data | Fascinated by how Markets works.

No responses yet

Write a response