Skip to content

We can fetch the NSE live data using API from the excel itself, built python exe based application which is responsible to fetch live market data from NSE India such as LiveMarket, PreMarket, NseHolidays, NseFNO, Symboldata, and so on... Here, we automate excel itself for live data extraction.

License

Notifications You must be signed in to change notification settings

kunalk3/NSE_Livedata_from_excel_extraction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NSE Livedata from excel

We can fetch the NSE live data using API from the excel itself, built python exe based application which is responsible to fetch live market data from NSE India such as LiveMarket, PreMarket, NseHolidays, NseFNO, Symboldata, and so on... Here, we automate excel itself for live data extraction using xlwings. Here demonstrated with python tk interface and built exe based application NSEApplication.exe.

Currenly script/ application collect NSE data as Live Market Data, Pre Market Data, Symbol List, FNO Matket Data and Market Holiday Data from excel itself in opened excel file.

Windows Visual Studio Code Jupyter Pycharm Colab Spyder


πŸ“š Introduction NSE Market segments

  • Pre-market -->

    ['NIFTY 50': 'NIFTY', 'NIFTY BANK': 'BANKNIFTY', 'EMERGE': 'SME', 'SECURITIES IN F&O': 'FO', 'OTHERS': 'OTHERS', 'ALL': 'ALL']
    
  • Live Market -->

    'Broad Market Indices': ['NIFTY 50', 'NIFTY NEXT 50', 'NIFTY MIDCAP 50', 'NIFTY MIDCAP 100', 'NIFTY MIDCAP 150', 'NIFTY SMALLCAP 50', 'NIFTY SMALLCAP 100', 'NIFTY SMALLCAP 250', 
                            'NIFTY MIDSMALLCAP 400', 'NIFTY 100', 'NIFTY 200', 'NIFTY500 MULTICAP 50:25:25', 'NIFTY LARGEMIDCAP 250'],
    'Sectorial Indices': ['NIFTY AUTO','NIFTY BANK', 'NIFTY ENERGY', 'NIFTY FINANCIAL SERVICES', 'NIFTY FINANCIAL SERVICES 25/50', 'NIFTY FMCG', 'NIFTY IT', 'NIFTY MEDIA', 'NIFTY METAL', 
                         'NIFTY PHARMA', 'NIFTY PSU BANK', 'NIFTY REALTY', 'NIFTY PRIVATE BANK'], 
    'Others': ['Securities in F&O', 'Permitted to Trade'], 
    'Strategy Indices': ['NIFTY DIVIDEND OPPORTUNITIES 50', 'NIFTY50 VALUE 20', 'NIFTY100 QUALITY 30', 'NIFTY50 EQUAL WEIGHT', 'NIFTY100 EQUAL WEIGHT', 'NIFTY100 LOW VOLATILITY 30', 
                        'NIFTY ALPHA 50', 'NIFTY200 QUALITY 30', 'NIFTY ALPHA LOW-VOLATILITY 30', 'NIFTY200 MOMENTUM 30'],
    'Thematic Indices': ['NIFTY COMMODITIES', 'NIFTY INDIA CONSUMPTION', 'NIFTY CPSE', 'NIFTY INFRASTRUCTURE', 'NIFTY MNC', 'NIFTY GROWTH SECTORS 15', 'NIFTY PSE', 'NIFTY SERVICES SECTOR', 
                        'NIFTY100 LIQUID 15', 'NIFTY MIDCAP LIQUID 15']}
    
  • Market Holidays -->

    ['Trading', 'Clearing']
    

πŸ’‘ Demo

  • Below is the demonstrated sample at my local environments/ system with platform as Visual Studio Code (V1.61.2) on OS Windows 10.
Demo_Excel_NSE_data.mp4

✏️ Input -

  • Run python code app.py and excel will open with naming conventition as NSE_data_DDMMYYYY. (Pre-requesite microsoft excel is installed on OS system)
  • You are able to write Keys as mentioned in excel first sheet. If Key name is matched, then only you are able to fetch the data, else no data is captured in real time from NSE website https://www.nseindia.com/

πŸ”– Output -

  • Data keys

    MainScreen

  • NSE Live-market data

    LiveMarket

  • NSE Pre-market data

    PreMarket

  • NSE FnO market data

    FnO


πŸ”§ Installation

  • Create virtual environment python -m venv VIRTUAL_ENV_NAME and activate it .\VIRTUAL_ENV_NAME\Scripts\activate.

  • Install necessary library for this project from the file requirements.txt or manually install by pip.

    pip install -r requirements.txt
    

    To create project library requirements, use below command,

    pip freeze > requirements.txt
    
  • In code, write your browser user-agent in headers before proceeding the script.

    import requests
    
    def __init__(self):
          self.headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36'}
          self.session = requests.Session()
          self.session.get('http://nseindia.com', headers=self.headers)

    How to capture the user-agent and API from NSE? Refers below steps/ tutorial.

    1. Open NSE website https://www.nseindia.com/ and inspect (Right click -> Inspect).
    2. Go to Network and select www.nseindia.com under Name.
    3. Go to Headers and copy the user-agent value from bottom.
  • Now run python file.

    python app.py
    
  • Read more about xlwings package and usages Excel automation

πŸ’» py-to-exe conversion -

  • Need to install library pyinstaller pip install pyinstaller.
  • Run below command (VS Code terminal) for python file to exe conversion. (Recommended: merge api.py code to app.py / make single python file)
    pyinstaller -i .\icon.ico -n NseAppication -w -F --log DEBUG .\app.py
    
    -i icon , -n application name , -w windows based , --log DEBUG logging if error occures , app.py python file
  • For py to exe conversion, refers pyinstaller documentation

πŸ”– Directory Structure

    .                                   # Root directory
    β”œβ”€β”€ app.py                          # Python code
    β”œβ”€β”€ api.py                          # Python code
    β”œβ”€β”€ icon.ico                        # Icon file
    β”œβ”€β”€ build                           # build folder generated due to py-to-exe conversion
    β”œβ”€β”€ dist                            # dist folder generated due to py-to-exe conversion
    β”‚   β”œβ”€β”€ NSE_data_0102021.xlsx       # Outout excel working live file created after launching exe application 
    β”‚   └── NSEApplication.exe          # Output exe application created after py-to-exe conversion (Not uploaded exe file due to application size  )
    β”œβ”€β”€ NseApplicaiton.spec             # Specification file generated due to py-to-exe conversion
    β”œβ”€β”€ requirements.txt                # Project requirements library with versions
    β”œβ”€β”€ README.md                       # Project README file
    └── LICENSE                         # Project LICENSE file

πŸ“± Connect with me

You say freak, I say unique. Don't wait for an opportunity, create it.

Let’s connect, share the ideas and feel free to ping me...

kunalkolhe3 kunalkolhe3 kunalkolhe333 kunalkolhe333 kunal.kolhe.98 kkunalkkolhe

About

We can fetch the NSE live data using API from the excel itself, built python exe based application which is responsible to fetch live market data from NSE India such as LiveMarket, PreMarket, NseHolidays, NseFNO, Symboldata, and so on... Here, we automate excel itself for live data extraction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages