The NSE Bhavcopy contains daily information about all securities traded on the NSE, including the list of stocks and their trading data. You can use the Bhavcopy to compile historical lists of the top 200 stocks. Here’s how you can do it:
Steps to Access NSE Bhavcopy:
- Visit the NSE Website: Go to the NSE Historical Data.
- Download Bhavcopy:
- Navigate to “Equity” → “Historical Data” → “Bhavcopy.”
- Select the date range you are interested in.
- Download the Bhavcopy files for the desired dates.
Compiling Historical Lists:
- Extract Data: Extract the downloaded Bhavcopy files (usually in CSV format).
- Filter Top 200 Stocks: Use criteria like trading volume, market capitalization, or other metrics to filter the top 200 stocks for each date.
- Automate with Python: Write a Python script to automate the extraction and filtering process.
Example Python Script to Process Bhavcopy:
import pandas as pd
import glob
# Path to the folder containing the downloaded Bhavcopy files
path = "path/to/bhavcopy/files"
# Load all CSV files
all_files = glob.glob(path + "/*.csv")
# Initialize an empty DataFrame to store top 200 stocks
top_200_stocks = pd.DataFrame()
# Process each Bhavcopy file
for file in all_files:
df = pd.read_csv(file)
df['Date'] = pd.to_datetime(file.split('/')[-1].split('.')[0], format='%d%m%Y')
# Sort by desired metric, e.g., market capitalization
df = df.sort_values(by='MARKET_CAPITALIZATION', ascending=False)
# Select top 200 stocks
top_200 = df.head(200)
# Append to the main DataFrame
top_200_stocks = pd.concat([top_200_stocks, top_200])
# Save the result to a CSV file
top_200_stocks.to_csv('top_200_stocks_historical.csv', index=False)
Key Points:
- Regular Downloads: Ensure you download Bhavcopy files regularly to maintain an updated historical dataset.
- Filter Criteria: Choose consistent criteria for filtering top stocks, like market cap or trading volume.
By using the NSE Bhavcopy and processing it with a script, you can compile a historical list of the top 200 stocks over the desired period.
Subscribe To Our Free Newsletter |