A python command line tool to calculate options max pain for a given company symbol and options expiry date.

Overview

Options-Max-Pain-Calculator

A python command line tool to calculate options max pain for a given company symbol and options expiry date.

Overview - Max Pain Theory

The Maximum Pain theory states that an option's price will gravitate towards a max pain price, in some cases equal to the strike price for an option, that causes the maximum number of options to expire worthless.

Calculating the Max Pain Point

For each in-the-money strike price for both puts and calls:

  1. Find the difference between stock price and strike price
  2. Multiply the result by open interest at that strike
  3. Add together the dollar value for the put and call at that strike
  4. Repeat for each strike price
  5. Find the highest value strike price. This price is equivalent to max pain price.

Source: Investopedia

How to run:

pip install -r requirements.txt
python3 OptionsMaxPainCalc.py

Sample Output:

Enter the Symbol: msft
Expiry dates:
2022-01-14, 2022-01-21, 2022-01-28, 2022-02-04, 2022-02-11, 2022-02-18, 2022-02-25, 2022-03-18, 2022-04-14, 2022-05-20, 2022-06-17, 2022-07-15, 2022-09-16, 2023-01-20, 2023-03-17, 2023-06-16, 2024-01-19, 
Enter the Expiry data [format: YYYY-MM-DD]: 2022-01-21
Maximum Pain: 291.0 < 300.0 < 309.0
Put to call ratio: 0.48

Using Max Pain

Traders use max pain level to identity the strikes which they can write. In the sample run above: 300 is the expected expiry level, one can choose to write call options above 300 or put options below 300 and collect all the premiums.

You might also like...
gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases.
gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases.

gget is a free and open-source command-line tool and Python package that enables efficient querying of genomic databases. gget consists of a collection of separate but interoperable modules, each designed to facilitate one type of database querying in a single line of code.

A command line tool (and Python library) for archiving Twitter JSON

A command line tool (and Python library) for archiving Twitter JSON

MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future
MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future

MsfMania MsfMania is a command line tool developed in Python that is designed to bypass antivirus software on Windows and Linux/Mac in the future. Sum

Python library and command line tool for interacting with Bugzilla

python-bugzilla This package provides two bits: bugzilla python module for talking to a Bugzilla instance over XMLRPC or REST /usr/bin/bugzilla comman

A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)
A command line tool to hide and reveal information inside images (works for both PNGs and JPGs)

Imgrerite A command line tool to hide and reveal information inside images (works for both PNGs and JPGs) Dependencies Python 3 Git Most of the Linux

PwnWiki command line searching tool & bindings written in Python
PwnWiki command line searching tool & bindings written in Python

pwsearch PwnWiki 数据库搜索命令行工具。 安装 您可以直接用 pip 命令从 PyPI 安装 pwsearch: pip3 install -U pwsearch 您也可以 clone 该仓库并直接从源码启动

PyArmor is a command line tool used to obfuscate python scripts

PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

Unofficial Open Corporates CLI: OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unofficial open corporates python command line tool.
Unofficial Open Corporates CLI: OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unofficial open corporates python command line tool.

Unofficial Open Corporates CLI OpenCorporates is a website that shares data on corporations under the copyleft Open Database License. This is an unoff

Professor Wordlist is a free open source command line tool written in python

Professor Wordlist is a free open source command line tool written in python, With the aim of generating custom wordlists with a variety of unique parameters and functions providing many possibilities.

Comments
  • Suggest to loosen the dependency on yfinance

    Suggest to loosen the dependency on yfinance

    Hi, your project Options-Max-Pain-Calculator requires "yfinance==0.1.68" in its dependency. After analyzing the source code, we found that some other versions of yfinance can also be suitable without affecting your project, i.e., yfinance 0.1.69. Therefore, we suggest to loosen the dependency on yfinance from "yfinance==0.1.68" to "yfinance>=0.1.68,<=0.1.69" to avoid any possible conflict for importing more packages or for downstream projects that may use Options-Max-Pain-Calculator.

    May I pull a request to loosen the dependency on yfinance?

    By the way, could you please tell us whether such dependency analysis may be potentially helpful for maintaining dependencies easier during your development?



    For your reference, here are details in our analysis.

    Your project Options-Max-Pain-Calculator(commit id: e67bd57021542ffc09d604d1fc4c79fa70168d5f) directly uses 2 APIs from package yfinance.

    yfinance.ticker.Ticker.__init__, yfinance.ticker.Ticker.option_chain
    
    

    From which, 13 functions are then indirectly called, including 7 yfinance's internal APIs and 6 outsider APIs, as follows (neglecting some repeated function occurrences).

    [/asad70/Options-Max-Pain-Calculator]
    +--yfinance.ticker.Ticker.__init__
    |      +--yfinance.base.TickerBase.__init__
    |      |      +--yfinance.utils.empty_df
    |      |      |      +--pandas.DataFrame
    |      |      +--yfinance.utils.is_isin
    |      |      |      +--re.match
    |      |      +--yfinance.utils.get_ticker_by_isin
    |      |      |      +--yfinance.utils.get_all_by_isin
    |      |      |      |      +--yfinance.utils.is_isin
    +--yfinance.ticker.Ticker.option_chain
    |      +--yfinance.ticker.Ticker._download_options
    |      |      +--requests.get
    |      |      +--datetime.datetime.utcfromtimestamp
    |      +--collections.namedtuple
    |      +--yfinance.ticker.Ticker._options2df
    |      |      +--pandas.DataFrame
    |      |      +--pandas.to_datetime
    

    We scan yfinance's versions among [0.1.69] and 0.1.68, the changing functions (diffs being listed below) have none intersection with any function or API we mentioned above (either directly or indirectly called by this project).

    diff: 0.1.68(original) 0.1.69
    ['yfinance.base.TickerBase.history', 'yfinance.base.TickerBase']
    
    

    As for other packages, the APIs of @outside_package_name are called by yfinance in the call graph and the dependencies on these packages also stay the same in our suggested versions, thus avoiding any outside conflict.

    Therefore, we believe that it is quite safe to loose your dependency on yfinance from "yfinance==0.1.68" to "yfinance>=0.1.68,<=0.1.69". This will improve the applicability of Options-Max-Pain-Calculator and reduce the possibility of any further dependency conflict with other projects/packages.

    opened by Agnes-U 3
  • Not an issue - Volume instead of OpenInterest

    Not an issue - Volume instead of OpenInterest

    Hi Asad, Thanks for writing this tool, its a great code. Checking in to see, if we can use the Volume instead of OpenInterest, if so can you please suggest what changes has to be done in the code.

    opened by macieman 1
Owner
null
A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Stream your favorite shows straight from the command line.

A command-line based, minimal torrent streaming client made using Python and Webtorrent-cli. Installation pip install -r requirements.txt It use

Jonardon Hazarika 17 Dec 11, 2022
GetRepo-py is a command line client that queries GitHub API and searches repositories by given arguments

GetRepo-py is a command line client that queries GitHub API and searches repositories by given arguments

Davidcin 3 Feb 14, 2022
Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash.

SHAZAM - Check the file's integrity Shazam is a Command Line Application that checks the integrity of the file by comparing it with a given hash. Crea

Anaxímeno Brito 1 Aug 21, 2022
A command-line utility that, given a markdown file, checks whether all its links work.

A command-line utility written in Python that checks validity of links in a markdown file.

Teclado 2 Dec 8, 2021
AML Command Transfer. A lightweight tool to transfer any command line to Azure Machine Learning Services

AML Command Transfer (ACT) ACT is a lightweight tool to transfer any command from the local machine to AML or ITP, both of which are Azure Machine Lea

Microsoft 11 Aug 10, 2022
A cd command that learns - easily navigate directories from the command line

NAME autojump - a faster way to navigate your filesystem DESCRIPTION autojump is a faster way to navigate your filesystem. It works by maintaining a d

William Ting 14.5k Jan 3, 2023
Ros command - Unifying the ROS command line tools

Unifying the ROS command line tools One impairment to ROS 2 adoption is that all

null 37 Dec 15, 2022
Python command line tool and python engine to label table fields and fields in data files.

Python command line tool and python engine to label table fields and fields in data files. It could help to find meaningful data in your tables and data files or to find Personal identifable information (PII).

APICrafter 22 Dec 5, 2022
A lightweight Python module and command-line tool for generating NATO APP-6(D) compliant military symbols from both ID codes and natural language names

Python military symbols This is a lightweight Python module, including a command-line script, to generate NATO APP-6(D) compliant military symbol icon

Nick Royer 5 Dec 27, 2022