Giter VIP home page Giter VIP logo

kunalk3 / nse_livedata_from_excel_extraction Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 12.0 18 KB

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: MIT License

Python 100.00%
python3 nse-stock-data excel-automation exe-app pandas requests api live-data nse-markets finance

nse_livedata_from_excel_extraction's Introduction

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

nse_livedata_from_excel_extraction's People

Contributors

kunalk3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nse_livedata_from_excel_extraction's Issues

Issue while trying to increase sleep interval and feature request

Hi, @kunalk3.

Issue : Application crashing while trying to increase interval

Before compilation of the EXE file, I edited line number 50 of the app.py file to increase time interval

I edited it to time.sleep(180) because I wanted to fetch data from the NSE site every 3 minutes.
By the default code, I think it fetches data every 2 seconds. Actually, I faced issues analyzing the data as the data changed rapidly so I wanted to customize app.py file to make it fetch data every 3 minutes.

After making the above mentioned change, the compilation of the EXE was successful but the EXE crashed after I pressed the start button.

Feature Request : Pause Button

Pause Button : It will be awesome if you add a pause button in the application which will allow the user to pause automated fetching. It will help in the analysis of the fetched data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.