NSEPython Documentation

def nse_preopen_movers(key="FO"):
    positions = nsefetch("https://www.nseindia.com/api/market-data-pre-open?key="+key+"")    
    idf = pd.DataFrame(positions['data'])
    df  = pd.json_normalize(idf['metadata'])[['symbol', 'pChange', 'lastPrice', 'totalTurnover']].dropna()
    adv_dec = np.array([[positions['advances'],positions['declines'],positions['unchanged']]])
    return df.loc[df['pChange'] > 1.5], df.loc[df['pChange'] < -1.5],adv_dec

preOpen_gainer, preOpen_loser, adv_dec = nse_preopen_movers()

I’m filtering pre-open gainers and losers with a 1.5% range, with advances and declines.

1 Like


I added the functions to the main library with certain changes. Update the main library.
Two functions added.



key = "NIFTY" (default)
key = "SME"
key = "FO"
key = "OTHERS"
key = "ALL"

type = "raw"
type = "pandas" (default)


print(payload) # It will print raw JSON
payload=nse_preopen("FO","pandas") # It will post Pandas DataFrame
1 Like

Another one is yours. Also added your name there in code. See in Github.


  • key is same like just pasted above.
  • filter is where you can choose how much gap up or down.



PS: I recoded this way because I desperately wanted to avoid adding a new library like numpy. Adding library can cause error in all past installations.

1 Like

anyway to check on delivery of stocks?
also global cues…

It is in the Bhavcopy. Filter it.

How can I get the top 20 most liquid F&O stocks from NSE?

Add the old nse_quote_meta function back.

Refer this discussion -

Also -

print(nse_quote_ltp("BANKNIFTY","latest","Fut")) this used to give error. Now it will automatically chek if it is BN or N and if You’re asking for Fut, then it will take monthly expiry.

This nse_quote_meta will give you all the information along with the LTP.

Here is the sample -



   "instrumentType":"Index Futures",

nse_most_active() Function

There are two ways -

  • Most Active Securities by Volume
  • Most Active Securities by Values

If You want the first type print(nse_most_active())

Make sure You have upgraded NSEPython to the latest version. Now cross-reference that output’s instruments with FNOs. The output is in pandas. It is easy to cross-reference a Pandas Column against a List of FNO Symbols

The full function is -


Here are the types -

type = "securities" (default)
type = "etf"
type = "sme"

sort = "volume"
sort = "value" (default)

I have updated my existing NSEPython but still got this error.

NameError: name ‘nse_most_active’ is not defined

How to import the function from NSEpython?

Update again following - NSEPython

Oh God. Go through - Algorithm Trading Session 1: Basics of Python and Jupyter - Unofficed

Run -

from nsepython import *


Brother, can you add nifty500 key to the preopen movers

It’s working after restarting the system.

But it is giving most active NSE stocks, not most active F&O stocks.

Hire a coder.

NFO is subset of NSE.

Already told how to do it.

Areh… If NSE themselves do not give NIFTY500 as parameter how can I?
Refer - nseindia.com/market-data/pre-open-market-cm-and-emerge-market

Oh…okay thank you for the reply

I can code it myself, in fact, without using this function from the option chain scrapper. Asking if that ready-made function is available because coding is not my primary job but I know how to do that. Thanks for your suggestion anyway.

Before You started replying like oversmart golden assface, acknowledge the fact that coding is not my primary fucking job either.

Despite that, I coded a function because you were seeking something and using that function it can be done. From option chain scrapper You will code most active “stonks”? Where will futures’ data will go? I am sure You’re fucked in coding! Because that needs common sense.

Now code it yourself!

Very nice done (y). I was looking for python libraries and came across yours… Just loved it!

One question though, I am looking for way to fetch Fundamental Data for any Stock and their intrinsic value. Have you built something on that too?

You tell me from where theoretically it can be fetched with proper values. [The Human Path to see it]. I will think of adding it.

One Source that I use : Indian Energy Exchange Ltd financial results and price chart - Screener
Fundamental Data points such as ROE, PE, Share ownership % breakdown, etc.

I’ll look for more examples.