Installation
To install using pip, use
nsescraper requires Python 3 and Pandas to execute.
Features:
nsescraper package contains different functions such as:
- intraday_index: Scrapes intra day data for any index from NSE
- intraday_stock: Scrapes intra day data for any listed stock from NSE
Usage
1
| from nsescraper import *
|
1
| intraday_index("nifty 50")
|
Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| +-----+---------------------+---------+---------+---------+---------+
| | DATETIME | open | high | low | close |
+=====+=====================+=========+=========+=========+=========+
| 0 | 2024-08-02 09:00:00 | 25010.9 | 25085.6 | 24777 | 24945.8 |
+-----+---------------------+---------+---------+---------+---------+
| 1 | 2024-08-02 09:01:00 | 24946 | 24950 | 24826.8 | 24830 |
+-----+---------------------+---------+---------+---------+---------+
| 2 | 2024-08-02 09:02:00 | 24816.5 | 24816.5 | 24784 | 24792.3 |
+-----+---------------------+---------+---------+---------+---------+
| 3 | 2024-08-02 09:03:00 | 24791.5 | 24791.5 | 24777.6 | 24789.8 |
+-----+---------------------+---------+---------+---------+---------+
...
| 392 | 2024-08-02 15:32:00 | 24699.5 | 24717.7 | 24699.5 | 24717.7 |
+-----+---------------------+---------+---------+---------+---------+
| 393 | 2024-08-02 15:33:00 | 24717.7 | 24717.7 | 24717.7 | 24717.7 |
+-----+---------------------+---------+---------+---------+---------+
|
1
| intraday_stock("britannia")
|
Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| +-----+---------------------+---------+---------+---------+---------+
| | DATETIME | open | high | low | close |
+=====+=====================+=========+=========+=========+=========+
| 0 | 2024-08-02 09:15:00 | 5645.9 | 5695.8 | 5645.9 | 5695.8 |
+-----+---------------------+---------+---------+---------+---------+
| 1 | 2024-08-02 09:16:00 | 5707.8 | 5732.95 | 5706.7 | 5729.85 |
+-----+---------------------+---------+---------+---------+---------+
| 2 | 2024-08-02 09:17:00 | 5715 | 5737.9 | 5709.15 | 5729.85 |
+-----+---------------------+---------+---------+---------+---------+
| 3 | 2024-08-02 09:18:00 | 5732 | 5732.85 | 5689.95 | 5697.3 |
+-----+---------------------+---------+---------+---------+---------+
...
| 400 | 2024-08-02 15:55:00 | 5720.35 | 5720.35 | 5720.35 | 5720.35 |
+-----+---------------------+---------+---------+---------+---------+
| 401 | 2024-08-02 15:56:00 | 5720.35 | 5720.35 | 5720.35 | 5720.35 |
+-----+---------------------+---------+---------+---------+---------+
|
1
| intraday_index("nifty midcap 100", tick= True)
|
Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| +-------+---------------------+---------+-----+
| | DATETIME | Tick | 2 |
+=======+=====================+=========+=====+
| 0 | 2024-08-02 09:00:00 | 58490.4 | PO |
+-------+---------------------+---------+-----+
| 1 | 2024-08-02 09:00:01 | 58490.4 | PO |
+-------+---------------------+---------+-----+
| 2 | 2024-08-02 09:00:02 | 58490.4 | PO |
+-------+---------------------+---------+-----+
| 3 | 2024-08-02 09:00:03 | 58490.4 | PO |
+-------+---------------------+---------+-----+
...
| 15319 | 2024-08-02 15:32:59 | 57913.7 | NM |
+-------+---------------------+---------+-----+
| 15320 | 2024-08-02 15:33:00 | 57913.7 | NM |
+-------+---------------------+---------+-----+
|
1
| intraday_stock("dr reddy", tick= True)
|
Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| +------+---------------------+---------+
| | DATETIME | Tick |
+======+=====================+=========+
| 0 | 2024-08-02 09:15:24 | 6891.2 |
+------+---------------------+---------+
| 1 | 2024-08-02 09:15:30 | 6886.1 |
+------+---------------------+---------+
| 2 | 2024-08-02 09:15:37 | 6900.05 |
+------+---------------------+---------+
| 3 | 2024-08-02 09:15:44 | 6900.6 |
+------+---------------------+---------+
...
| 7931 | 2024-08-02 15:58:49 | 6964.15 |
+------+---------------------+---------+
| 7932 | 2024-08-02 15:59:39 | 6964.15 |
+------+---------------------+---------+
|
To scrap current days nse index/stock data as required length minute candle
1
| intraday_index("nifty energy", candlestick= 10)
|
Output :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| +----+---------------------+---------+---------+---------+---------+
| | DATETIME | open | high | low | close |
+====+=====================+=========+=========+=========+=========+
| 0 | 2024-08-02 09:00:00 | 44954.4 | 44954.4 | 44481.8 | 44481.8 |
+----+---------------------+---------+---------+---------+---------+
| 1 | 2024-08-02 09:10:00 | 44481.8 | 44627.7 | 44258.1 | 44625.6 |
+----+---------------------+---------+---------+---------+---------+
| 2 | 2024-08-02 09:20:00 | 44618.6 | 44684.2 | 44537.8 | 44551.7 |
+----+---------------------+---------+---------+---------+---------+
| 3 | 2024-08-02 09:30:00 | 44524.2 | 44558.8 | 44375.6 | 44404.2 |
+----+---------------------+---------+---------+---------+---------+
...
| 38 | 2024-08-02 15:20:00 | 44378.4 | 44399.4 | 44286.2 | 44297.5 |
+----+---------------------+---------+---------+---------+---------+
| 39 | 2024-08-02 15:30:00 | 44299.1 | 44334.2 | 44299.1 | 44334.2 |
+----+---------------------+---------+---------+---------+---------+
|
1
| intraday_stock("Zomato", candlestick= 69)
|
To scrap historical nse index/stock data
1
| historical_index('NIFTY 50')
|
1
| historical_stock('ABB')
|