jesvin1 / Python-NSE-Option-Chain-Analyzer

For doing technical analysis for option traders, the Option Chain is the most important tool for deciding entry and exit strategies. The National Stock Exchange (NSE) has a website which displays the option chain for traders in near real-time. This program scrapes this data from the NSE site and then generates useful analysis of the Option Chain for the specified Security or Index from the NSE website. It also continuously refreshes the Option Chain and visually displays the trend in various indicators and useful for Technical Analysis. Calculations are based on Mr. Sameer Dharaskar's Course.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python NSE-Option-Chain-Analyzer

Latest: v4.1 Download-Count License: GPL v3

For doing technical analysis for option traders, the Option Chain is the most important tool for deciding entry and exit strategies. The National Stock Exchange (NSE) has a website which displays the option chain for traders in near real-time. This program scrapes this data from the NSE site and then generates useful analysis of the Option Chain for the specified Security or Index from the NSE website. It also continuously refreshes the Option Chain and visually displays the trend in various indicators and useful for Technical Analysis. Calculations are based on Mr. Sameer Dharaskar's Course.

Installation:

Types of variants available:

  1. .exe (Windows Executable)

  2. .py (Python Source Code)

  • Does not support Linux

  • Requirements for 1:

    • Windows OS
  • Requirements for 2:

    • Python 3.6+

    • For Windows https://www.python.org/downloads/ is recommended

    • Add Python to PATH/Environment Variables during installation in Windows (recommended)

    • Required modules: requirements.txt

    • Install missing modules using pip install -r requirements.txt

Usage:

  1. Select your Index or Security option and it's Expiry Date

  2. Enter your preferred Strike Price

  3. Enter the interval you want the program to refresh (Optional : Defaults to 1 minute)

  4. Click Start

Note:

  • If there is an error in fetching dates then try refreshing

  • If you face any issue or have a suggestion then feel free to open an issue.

  • It is recommended to enable logging and then send the NSE-OCA.log file or the console output for reporting issues

  • In case of network or connection errors the program doesn't crash and will keep retrying until manually stopped

  • If a ZeroDivisionError occurs or some data doesn't exist the value of the variable will be defaulted to 0

  • All data is retrieved from https://www.nseindia.com/api/option-chain-indices?symbol={index_name}

Dependencies:

  • auto-py-to-exe is used for compiling the program to a .exe file

  • numpy is used for data types

  • pandas is used for storing and manipulating the data

  • requests is used for accessing and retrieving data from the NSE website

  • stream-to-logger is used for debug logging

  • tksheet is used for the table containing the data

  • win10toast is used for Windows Toast notifications

Features:

  • The program continuously retrieves and refreshes the option chain giving near real-time analysis to the traders

  • New data rows are added only if the NSE server updates its time or data (To prevent displaying duplicate data)

  • Supported Indices :

    • NIFTY
    • BANKNIFTY
    • FINNIFTY
  • Supports multiple instances with different indices and strike prices selected

  • Red and Green colour indication for data based on trends

  • Toast Notifications for notifying when trend changes. Notified changes:

    • Open Interest: Bullish/Bearish
    • Open Interest Upper Boundary Strike Prices: Change in Value
    • Open Interest Lower Boundary Strike Prices: Change in Value
    • Call Exits: Yes/No
    • Put Exits: Yes/No
    • Call ITM: Yes/No
    • Put ITM: Yes/No
  • Program title format: NSE-Option-Chain-Analyzer - {index} - {expiry_date} - {strike_price}

  • Stop and Start manually

  • You can select all table data using Ctrl+A or select individual cells, rows and columns

  • Then you can copy it using Ctrl+C or right click menu

  • You can then paste it in any spreadsheet application (Tested with MS Excel and Google Sheets)

  • Export table data to .csv file

  • Real time exporting data rows to .csv file

  • Dumping entire Option Chain data to a .csv file

  • Auto stop the program at 3:30pm when the market closes

  • Auto Checking for updates

  • Debug Logging

  • Saves certain settings in a configuration file for subsequent runs. Saved Settings:

    • Selected Index
    • Refresh Interval
    • Live Export
    • Notifications
    • Dump entire Option Chain
    • Auto stop at 3:30pm
    • Auto Check for Updates
    • Debug Logging
  • Keyboard shortcuts for all options

Data Displayed

Table Data:

Data Description
Server Time Web Scraped. Indicates last data update time by NSE server
Value Web Scraped. Underlying Instrument Value indicates the value of the underlying Security or Index
Call Sum Calculated. Sum of the Changes in Call Open Interest contracts of the given Strike Price and the next immediate two Strike Prices (In Thousands)
Put Sum Calculated. Sum of the Change in Put Open Interest contracts of the given Strike Price and the next two Strike Prices (In Thousands)
Difference Calculated. Difference between the Call Sum and Put Sum. If its very -ve its bullish, if its very +ve then its bearish else its a sideways session.
Call Boundary Change in Call Open Interest contracts for 2 Strike Prices above the given Strike Price. This is used to determine if Call writers are taking new positions (Bearish) or exiting their positions (Bullish). (In Thousands)
Put Boundary Change in Put Open Interest for the given Strike Price. This is used to determine if Put writers are taking new positions (Bullish) or exiting their positions(Bearish). (In Thousands)
Call In The Money(ITM) This indicates that bullish trend could continue and Value could cross 4 Strike Prices above given Strike Price. It's calculated as the ratio of Put writing and Call writing at the 4th Strike Price above the given Strike price. If the absolute ratio > 1.5 then its bullish sign.
Put In The Money(ITM) This indicates that bearish trend could continue and Value could cross 2 Strike Prices below given Strike Price. It's calculated as the ratio of Call writing and Put writing at the 2nd Strike Price below the given Strike price. If the absolute ratio > 1.5 then its bearish sign.

Label Data:

Data Description
Open Interest Upper Boundary Highest and 2nd Highest(highest in OI boundary range) Call Open Interest contracts (in thousands) and their corresponding Strike Prices
Open Interest Lower Boundary Highest and 2nd Highest(highest in OI boundary range) Put Open Interest contracts (in thousands) and their corresponding Strike Prices
Open Interest This indicates if the latest OI data record indicates Bearish or Bullish signs near Indicated Strike Price. If the Call Sum is more than the Put Sum then the OI is considered Bearish as there is more Call writing than Puts. If the Put Sum is more than the Call sum then the OI Is considered Bullish as the Put writing exceeds the Call writing.
Put Call Ratio(PCR) Sum Total of Put Open Interest contracts divided by Sum Total of Call Open Interest contracts
Call Exits This indicates if the Call writers are exiting near given Strike Price in the latest OI data record. If the Call sum is < 0 or if the change in Call OI at the Call boundary (2 Strike Prices above the given Strike Price) is < 0, then Call writers are exiting their positions and the Bulls have a clear path.
Put Exits This indicates if the Put writers are exiting near given Strike Price in the latest OI data record. If the Put sum is < 0 or if the change in Put OI at the Put boundary (the given Strike Price) is < 0, then Put writers are exiting their positions and the Bears have a clear path.
Call In The Money(ITM) This indicates if the Call writers are also exiting far OTM strike prices (4 Strike Prices above the given Strike Price) showing extreme bullishness. Conditions are if the Call writers are exiting their far OTM positions and the Put writers are writing at the same Strike Price & if the absolute ratio > 1.5 then its bullish sign. This signal also changes to Yes if the change in Call OI at the far OTM is < 0.
Put In The Money(ITM) This indicates if the Put writers are also exiting far OTM strike prices (2 Strike Prices below the given Strike Price) showing extreme bearishness. Conditions are if the Put writers are exiting their far OTM positions and the Call writers are writing at the same Strike Price & if the absolute ratio > 1.5 then its a bearish sign. . This signal also changes to Yes if the change in Put OI at the far OTM is < 0.

Screenshots:

  • Login Page:


    Login_Window

  • Main Window:


    Main_Window

  • Selecting Data:


    Selecting_Data

  • Option Menu


    Option_Menu

About

For doing technical analysis for option traders, the Option Chain is the most important tool for deciding entry and exit strategies. The National Stock Exchange (NSE) has a website which displays the option chain for traders in near real-time. This program scrapes this data from the NSE site and then generates useful analysis of the Option Chain for the specified Security or Index from the NSE website. It also continuously refreshes the Option Chain and visually displays the trend in various indicators and useful for Technical Analysis. Calculations are based on Mr. Sameer Dharaskar's Course.

License:GNU General Public License v3.0


Languages

Language:Python 100.0%