I am using NSEPY API and I would like to list out the stocks which are included in nifty 50 indice.
I am getting history data for the individual stocks but not getting nifty 50 stocks (totally 50 stocks). I want to retrieve it .
import nsepy
from nsepy import get_history
from datetime import date
data = get_history(symbol="IOC", start=date(2017,1,1), end=date(2019,2,15))
data[['Close']].plot()
I want the results for 50 stocks but I am getting results for specific stick which I have given in symbol
According to the NSEpy documentation, you don't have any method to list the companies from the index using the API.
However, you can download a csv that contains the 50 companies list here.
To read the file in Python and list the companies, using Pandas, the code is: