Member-only story

Coding Heatmap Opening Range Breakout Strategy in Python — Part 2

Amit Kumar Ghosh
8 min readAug 29, 2023

--

Prerequisite:

Getting the Top Gainers and Top Losers

In our last part of Opening Range, we used the nsefetch() function to fetch some NSE URLs directly. Although You can write functions using the broker’s API We will stick with NSE APIs for now.

In the last upgrade of NSEPython, We got a function named nse_get_top_gainers(). So, Let's replace our previous methodology using this function.

Now if You do –

gainers = nse_get_top_gainers()
gainers.drop(gainers.columns.difference(["symbol","high_price","low_price","ltp"]), 1, inplace=True)
gainers=gainers.head(5)
print(gainers)

You will get –

symbol
0 IBULHSGFIN
1 ADANIENT
2 BHARATFORG
3 LICHSGFIN
4 UBL

It is because the name of the columns changes in the data we get from this function.

So, just inspect the output of gainers. You may need to set the max_columns attribute to see all the table names as it will be hidden ... as it is a long output.

Check here – aeron7.github.io/nsepython/documentation/nsefetch.html#parsing-the-data-with-pandas

pd.set_option('display.max_columns', None) # or 1000

--

--

Amit Kumar Ghosh
Amit Kumar Ghosh

Written by Amit Kumar Ghosh

Aloha, I’m Amit Ghosh, a web entrepreneur and avid blogger. Bitten by entrepreneurial bug, I got kicked out from college and ended up being millionaire!

No responses yet