How to get Indian stock data using pandas_datareader?
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
- 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.
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/’.
6. Running the fetch_data function for the 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.