A Python command-line tool for analyzing profit/loss scenarios for different options strategies.
- Fetch options chains for any ticker symbol using Yahoo Finance API
- Support for multiple strategies:
- Long Calls
- Long Puts
- Covered Calls
- Cash-Secured Puts
- Interactive selection of expiration dates and strikes
- Filter options by investment amount and expected price
- Calculate annualized returns based on target prices
- Tabular display of options data and analysis results
Clone this repository using one of the following methods:
Using HTTPS:
git clone https://github.com/finnjclancy/options-analyzer.git
cd options-analyzerUsing SSH (if you have SSH keys set up):
git clone git@github.com:finnjclancy/options-analyzer.git
cd options-analyzerUsing GitHub CLI:
gh repo clone finnjclancy/options-analyzer
cd options-analyzerCreate and activate a virtual environment:
# Using venv (Python built-in)
python -m venv venv
source venv/bin/activate # On Windows, use: venv\Scripts\activate
# Or using conda
conda create -n options-env python=3.9
conda activate options-envInstall the required Python packages:
pip install -r requirements.txtRun the script:
python options_analyzer.py
Follow the interactive prompts to:
- Enter a ticker symbol
- Select an expiration date
- Choose a strategy
- Enter investment amount and expected price
- View filtered options and analysis
══════════════════════════════════════════════════════════════════════
OPTIONS STRATEGY ANALYZER
══════════════════════════════════════════════════════════════════════
📱 This tool helps you analyze options strategies and find contracts
that match your investment criteria.
📊 Supported strategies:
c: Call - Buy call options
p: Put - Buy put options
cc: Covered Call - Own stock and sell call options
csp: Cash Secured Put - Sell put options with cash as collateral
🔍 The tool will guide you through the following steps:
1. Enter a stock ticker symbol
2. Select an options expiration date
3. Choose a strategy
4. Enter investment amount
5. Optionally filter by specific strike price
6. View matching options and analysis
🚀 Let's get started!
──────────────────────────────────────────────────────────────────────
📈 Enter ticker symbol: AAPL
📊 Fetching data for AAPL...
💲 Current price for AAPL: $188.38
📅 Retrieving available options expiration dates...
✅ Found 21 expiration dates.
📅 Available expiration dates:
┌─────┬────────────┐
│ Num │ Date │
├─────┼────────────┤
│ 1 │ 2025-04-04 │
│ 2 │ 2025-04-11 │
│ 3 │ 2025-04-17 │
│ 4 │ 2025-04-25 │
│ 5 │ 2025-05-02 │
│ 6 │ 2025-05-09 │
│ 7 │ 2025-05-16 │
│ 8 │ 2025-05-23 │
│ 9 │ 2025-06-20 │
│ 10 │ 2025-07-18 │
│ 11 │ 2025-08-15 │
│ 12 │ 2025-09-19 │
│ 13 │ 2025-10-17 │
│ 14 │ 2025-12-19 │
│ 15 │ 2026-01-16 │
│ 16 │ 2026-03-20 │
│ 17 │ 2026-06-18 │
│ 18 │ 2026-12-18 │
│ 19 │ 2027-01-15 │
│ 20 │ 2027-06-17 │
│ 21 │ 2027-12-17 │
└─────┴────────────┘
You can either:
1️⃣ Enter a number to select from the list above
2️⃣ Enter a date in YYYY-MM-DD format to find the closest expiration date
➡️ Enter selection (number or date): 2027-01-01
✅ Closest expiration to 2027-01-01 is 2026-12-18 (14 days difference)
📅 Selected expiration: 2026-12-18
🔍 Fetching options chain for 2026-12-18...
✅ Found 62 call options and 56 put options.
📊 Available strategies:
┏━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Code ┃ Description ┃
┣━━━━━━╋━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ c ┃ Buy a call option to profit from stock price in... ┃
┃ p ┃ Buy a put option to profit from stock price dec... ┃
┃ cc ┃ Own stock and sell a call option for income ┃
┃ csp ┃ Sell a put option with cash as collateral ┃
┗━━━━━━┻━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
➡️ Select strategy (c/p/cc/csp): c
✅ Selected strategy: call
💵 Enter the maximum amount you're willing to invest per contract ($): 10000
🔮 Enter your expected price for AAPL at expiration: $230
📊 Options sorted by highest annualized return if $230.00 is reached:
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| Num | Strike | Premium | Breakeven | Profit | Return % | Annual Return | Volume | Open Int |
+=======+==========+===========+=============+==========+============+=================+==========+============+
| 1 | $150.00 | $59.77 | $209.77 | $20.23 | 33.85% | 18.62% | 34 | 753 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 2 | $110.00 | $90.00 | $200.00 | $30.00 | 33.33% | 18.36% | 1 | 591 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 3 | $145.00 | $63.80 | $208.80 | $21.20 | 33.23% | 18.30% | 22 | 211 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 4 | $135.00 | $71.72 | $206.72 | $23.28 | 32.46% | 17.90% | 3 | 664 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 5 | $100.00 | $98.18 | $198.18 | $31.82 | 32.41% | 17.88% | 3 | 1756 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 6 | $140.00 | $68.07 | $208.07 | $21.93 | 32.22% | 17.78% | 8 | 673 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 7 | $165.00 | $50.00 | $215.00 | $15.00 | 30.00% | 16.62% | 3 | 390 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 8 | $160.00 | $54.71 | $214.71 | $15.29 | 27.95% | 15.53% | 1 | 928 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 9 | $155.00 | $59.11 | $214.11 | $15.89 | 26.88% | 14.97% | 5 | 298 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 10 | $175.00 | $43.74 | $218.74 | $11.26 | 25.74% | 14.36% | 44 | 891 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 11 | $180.00 | $40.84 | $220.84 | $9.16 | 22.43% | 12.59% | 160 | 1138 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 12 | $120.00 | $90.00 | $210.00 | $20.00 | 22.22% | 12.48% | 1 | 1269 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 13 | $185.00 | $38.34 | $223.34 | $6.66 | 17.37% | 9.84% | 8 | 1210 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 14 | $125.00 | $89.53 | $214.53 | $15.47 | 17.28% | 9.79% | 160 | 353 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 15 | $115.00 | $98.50 | $213.50 | $16.50 | 16.75% | 9.50% | 4 | 150 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 16 | $170.00 | $51.70 | $221.70 | $8.30 | 16.05% | 9.11% | 3 | 1088 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 17 | $190.00 | $36.00 | $226.00 | $4.00 | 11.11% | 6.37% | 39 | 1099 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 18 | $195.00 | $32.60 | $227.60 | $2.40 | 7.36% | 4.25% | 56 | 1018 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 19 | $130.00 | $96.55 | $226.55 | $3.45 | 3.57% | 2.08% | 13 | 1421 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 20 | $200.00 | $30.73 | $230.73 | $-0.73 | -2.38% | -1.40% | 473 | 4926 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 21 | $210.00 | $28.02 | $238.02 | $-8.02 | -28.62% | -17.93% | 219 | 2927 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 22 | $220.00 | $23.70 | $243.70 | $-13.70 | -57.81% | -39.68% | 185 | 2917 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 23 | $230.00 | $19.17 | $249.17 | $-19.17 | -100.00% | -100.00% | 284 | 3579 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 24 | $240.00 | $16.14 | $256.14 | $-16.14 | -100.00% | -100.00% | 32 | 4790 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 25 | $250.00 | $13.30 | $263.30 | $-13.30 | -100.00% | -100.00% | 1835 | 12005 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 26 | $260.00 | $11.20 | $271.20 | $-11.20 | -100.00% | -100.00% | 245 | 3139 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 27 | $270.00 | $9.40 | $279.40 | $-9.40 | -100.00% | -100.00% | 792 | 3179 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 28 | $280.00 | $7.72 | $287.72 | $-7.72 | -100.00% | -100.00% | 42 | 3180 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 29 | $290.00 | $6.30 | $296.30 | $-6.30 | -100.00% | -100.00% | 208 | 3239 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 30 | $300.00 | $5.20 | $305.20 | $-5.20 | -100.00% | -100.00% | 206 | 4046 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 31 | $310.00 | $4.40 | $314.40 | $-4.40 | -100.00% | -100.00% | 22 | 441 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 32 | $320.00 | $3.60 | $323.60 | $-3.60 | -100.00% | -100.00% | 32 | 2286 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 33 | $330.00 | $3.25 | $333.25 | $-3.25 | -100.00% | -100.00% | 118 | 827 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 34 | $340.00 | $2.70 | $342.70 | $-2.70 | -100.00% | -100.00% | 1 | 652 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 35 | $350.00 | $2.00 | $352.00 | $-2.00 | -100.00% | -100.00% | 35 | 4171 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 36 | $360.00 | $1.81 | $361.81 | $-1.81 | -100.00% | -100.00% | 7 | 224 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 37 | $370.00 | $1.96 | $371.96 | $-1.96 | -100.00% | -100.00% | 2 | 177 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 38 | $380.00 | $1.34 | $381.34 | $-1.34 | -100.00% | -100.00% | 5 | 80 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 39 | $390.00 | $1.00 | $391.00 | $-1.00 | -100.00% | -100.00% | 6 | 114 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 40 | $400.00 | $1.06 | $401.06 | $-1.06 | -100.00% | -100.00% | 2 | 270 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 41 | $410.00 | $0.90 | $410.90 | $-0.90 | -100.00% | -100.00% | 4 | 262 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 42 | $420.00 | $0.75 | $420.75 | $-0.75 | -100.00% | -100.00% | 44 | 360 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 43 | $430.00 | $0.67 | $430.67 | $-0.67 | -100.00% | -100.00% | 2 | 236 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 44 | $440.00 | $0.60 | $440.60 | $-0.60 | -100.00% | -100.00% | 4 | 34 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
| 45 | $450.00 | $0.58 | $450.58 | $-0.58 | -100.00% | -100.00% | 282 | 1615 |
+-------+----------+-----------+-------------+----------+------------+-----------------+----------+------------+
📝 These options are sorted by annualized return if the stock reaches
$230.00 by expiration. Higher returns may involve higher risks.
➡️ Select an option by number (1 to 45) or 'q' to quit: 1
📊 Strategy Analysis
═══════════════════
📈 Strategy Summary - Long Call:
Strike Price: $150.0
Premium Paid: $59.77
Breakeven Price: $209.77
Maximum Loss: $59.77 (if stock price is below $150.0 at expiration)
Maximum Profit: Unlimited (increases as stock price rises above breakeven)
══════════════════════════════════════════════════════════════════════
📊 ANALYSIS RESULTS FOR EXPECTED FUTURE PRICE: $230.00
══════════════════════════════════════════════════════════════════════
Strategy: Long Call
Days until expiration: 623
Call Strike: $150.0
Premium Paid: $59.77
At your expected price of $230.00:
Option Value at Expiration: $80.00
Profit/Loss: $20.23
Percentage Return: 33.85%
Annualized Return: 18.62%
Note: These calculations assume holding until expiration.
══════════════════════════════════════════════════════════════════════
After selecting the options, you'll see a detailed analysis of the selected strategy with profit/loss metrics for your expected price target.
If you encounter issues:
-
Yahoo Finance API limitations: The API may occasionally have rate limits or data availability issues. Try again later or check if the ticker symbol is correct.
-
Python version compatibility: This tool has been tested with Python 3.8+. If you're using an older version, you might encounter compatibility issues.
-
Package conflicts: If you're having dependency issues, try creating a fresh virtual environment before installation.
- Python
- yfinance
- pandas
- tabulate
MIT