Trade Calc
Join the discord for support with any of this: https://discord.gg/krdByJHuHc
Quick Start
Python file and library requirements are in "trade calculator" directory I built and tested it on Python version 3.10.11 Instructions to install and run python scripts: https://docs.google.com/document/d/1BrC7OrSTBqFs5Q-ZlYTMBJYDaS5r5nrE0070sa0qmaA/edit?tab=t.0#heading=h.tfjao7msc0g8 If these instructions aren't enough there are a lot of youtube videos concerning this. Or come to discord and ask.
Scripts Overview
All scripts are located in the scripts/ directory. Run them using uv run python scripts/<script_name>.
Analysis Scripts
calculator.py - Single Stock Analysis
Purpose: Analyze a single stock ticker for calendar spread trading opportunities
Output: - Pass/Fail recommendation based on strategy criteria - Current stock price and volume metrics - IV/RV ratio (Implied Volatility vs Realized Volatility) - Term structure slope analysis - Expected move calculations - Detailed options metrics for available expirations
Usage:
Then enter a stock symbol when prompted (e.g., AAPL, NVDA)calculator_with_strat.py - Complete Strategy Analysis
Purpose: Enhanced calculator with directional bias and exit strategy - all-in-one analysis
Output (3-Step Analysis):
Step 1: Options Strategy Analysis
- All features from calculator.py
- Expected move from straddle pricing
Step 2: Directional Bias Analysis - Put/Call IV Skew (options pricing signals) - Put/Call Volume & Open Interest ratios - Recent price trend analysis - Overall directional bias (bullish/bearish/neutral) with confidence - Strike recommendation adjusted for directional bias - Rationale for strike selection
Step 3: Exit Strategy & Risk Management - Position Greeks (theta, delta, gamma, vega) - Exit rules with triggers and urgency levels - Daily monitoring checklist - Tools and resources for exit analysis
Final Output: - Complete trading plan summary - Entry strike recommendation - Profit target and stop loss levels - Exit timing guidelines - Risk management rules
Usage:
Example Output:
NVDA Trading Plan:
Expected Move: ±3.44%
Directional Bias: NEUTRAL (Confidence: 50%)
Suggested Strike: $185.00
Recommended Actions:
1. Enter calendar spread at $185.00 strike
2. Set profit target at 25% of max profit
3. Set stop loss at 75% of position cost
4. Monitor theta daily - exit if turns negative
5. Exit if front expiration ≤ 3 days
6. Consider exiting after 40%+ IV crush
When to use: - Pre-trade analysis: Get complete setup before entering position - Quick reference: All key information in one place - Learning: See how all components (expected move, direction, exits) work together
See also: - Directional Bias Guide for directional methodology - Dynamic Exit Guide for exit strategy details
compare.py - Compare Two Stocks
Purpose: Side-by-side comparison of two stock tickers with composite scoring
Output: - Comparative metrics for both stocks - Composite score for each ticker - Score breakdown by category (volume, IV/RV, term structure, expected move) - Winner determination
Usage:
Then enter two stock symbols when promptedrank_tickers.py - Rank Multiple Stocks
Purpose: Analyze and rank multiple tickers from database or file
Output: - Ranked list of tickers by composite score - Pass/Fail status for each ticker - Key metrics (volume, IV/RV, term structure, expected move) - Sorted table from best to worst candidates
Usage:
# Rank from database (requires cached data)
uv run python scripts/rank_tickers.py --db
# Rank from file
uv run python scripts/rank_tickers.py --file tickers.txt
# Show all tickers (including those that failed screening)
uv run python scripts/rank_tickers.py --db --show-all
next_friday_calc.py - Earnings-Based Analysis
Purpose: Find and analyze stocks with earnings between the next Friday and the Friday after
Output: - List of stocks with upcoming earnings - Earnings report dates - Full strategy recommendation for each ticker - Filtered for actionable trading opportunities
Usage:
# Summary view
uv run python scripts/next_friday_calc.py
# Detailed view with all metrics
uv run python scripts/next_friday_calc.py --verbose
directional_analysis.py - Predict Move Direction
Purpose: Determine if a stock is more likely to move up or down after earnings using market signals
Output: - Put/Call IV Skew (puts vs calls pricing) - Put/Call Volume Ratio (trading activity) - Put/Call Open Interest Ratio (positioning) - Recent Price Trend (momentum) - Overall Directional Bias (bullish/bearish/neutral) - Confidence Level (0-100%) - Strike Recommendation (adjusted for directional bias) - Trading Implications (specific guidance)
Usage:
# Analyze directional bias
uv run python scripts/directional_analysis.py NVDA
# Analyze specific expiration
uv run python scripts/directional_analysis.py NVDA --expiration 2026-01-23
Why use this: - Expected move shows magnitude (8.5%), this shows direction (+8.5% or -8.5%) - Combines 4 market indicators with weighted scoring - Suggests optimal strike placement (ATM, slightly OTM up/down) - Integrates with Monte Carlo simulation for directional positioning
See: Directional Bias Guide for detailed methodology and usage
Simulation Scripts
monte_carlo.py - Monte Carlo Simulation (Single Trade Example)
Purpose: Run Monte Carlo simulations to evaluate calendar spread strategy with market-calibrated expected moves
Output: - Distribution of P&L outcomes - Win rate and profit statistics - Daily P&L evolution charts - Exit day distribution - Risk metrics (percentiles, max loss/gain) - Exit reason breakdown (profit target, expiration, large move, stop loss)
Usage:
Features:
- Market calibration: Uses expected move from straddle pricing (from calculator.py)
- Strategy execution rules:
- Exit at profit target (default 25% of max profit)
- Early exit on large moves (>1.5x expected move)
- Stop loss on positions down 75%+
- Hold to expiration if no other rule triggers
- Black-Scholes option pricing with IV crush modeling
- Earnings jump calibrated from market expectations
- Comprehensive visualization with matplotlib
- Date constraints: Automatically adjusts option expirations to Fridays and generates earnings dates only on weekdays
Advanced Features:
- Dynamic exits: Use Greeks (theta, delta, gamma, vega) to optimize exit timing
- Set use_dynamic_exit=True for intelligent exit decisions based on:
- Theta decay efficiency (earning vs losing time value)
- Greeks risk exposure (delta, gamma, vega thresholds)
- P&L velocity and drawdown from peak
- IV change impact
- Time acceleration near expiration
See: - Monte Carlo Guide for expected move calibration - Dynamic Exit Guide for Greeks-based exit optimization
run_yearly_analysis.py - Full Year Monte Carlo Analysis
Purpose: Simulate 1 year of continuous calendar spread trading (5000 simulation paths) with market-calibrated expected moves
Output: - Main visualization: All 5000 cumulative P&L paths over 365 days - Color-coded: green = profitable years, red = losing years - Median, 10th, and 90th percentile paths highlighted - Yearly P&L distribution histogram - Number of trades per year distribution - Cumulative P&L percentiles over time - P&L per trade distribution - Exit reason analysis (profit target, large move, stop loss, expiration) - Comprehensive statistics (avg trades/year, win rate, risk metrics)
Usage:
Configuration:
- Edit the expected_move_pct parameter to match your ticker's expected move
- Get expected move from calculator.py (e.g., NVDA: 8.5%, TSLA: 12%)
- Simulation auto-calibrates earnings jumps from market data
- Strategy execution rules apply (profit targets, stop losses, early exits)
Typical Results: - ~40 trades per year (one trade every 9 days) - Shows full spectrum of outcomes across 5000 scenarios - Identifies best-case and worst-case yearly returns - Exit reason breakdown (e.g., 55% profit target, 31% large move, 14% expiration) - Helps visualize strategy consistency and risk
Note: Full 5000-simulation analysis takes 10-20 minutes
See: Monte Carlo Guide for detailed documentation
go_hunting.py - Automated Screening
Purpose: Scan for trading opportunities, filter by strategy criteria, and save valid recommendations to the online Supabase project.
Output:
- Symbols with earnings in the next 8 days
- Per-strategy analysis (Forward Factor, Sell Earnings Volatility)
- Quality metrics filtering via Supabase quality_metrics table
- Saves passing recommendations to recommendations and recommended_positions tables
Usage:
# Run both strategies (Forward Factor + Sell Earnings Volatility)
uv run python scripts/go_hunting.py --with-earnings
# Run only Forward Factor (default: strategies that do not cross earnings dates)
uv run python scripts/go_hunting.py
Strategies: - Forward Factor: Screens for favorable forward volatility (FF ratio) without earnings-specific timing - Sell Earnings Volatility: Screens for calendar spread opportunities around earnings (IV/RV, term structure, volume)
What it does:
1. Queries the earnings_calendar table for symbols with earnings between tomorrow and 8 days out
2. Runs each enabled strategy's analysis on each symbol
3. Filters using quality metrics from Supabase (configurable thresholds)
4. Saves passing symbols to tickers, recommendations, and (for SEV) recommended_positions
Runs automatically daily at 16:00 Zurich time via GitHub Actions (.github/workflows/go_hunting.yml). See Automated Screening (Go Hunting) for full documentation.
Data Management Scripts
cache_options.py - Cache Options Data to Database
Purpose: Pre-fetch and cache options data for high-volume stocks to enable fast bulk analysis
Output:
- Progress bar showing caching status
- Success/failure messages for each ticker
- Database storage of options metrics
- Creates options_metrics table if needed
Usage:
# Cache top 100 stocks by volume
uv run python scripts/cache_options.py
# Cache specific number of stocks
uv run python scripts/cache_options.py --limit 50
# Use custom volume threshold
uv run python scripts/cache_options.py --min-volume 2000000
Why use this:
- Speeds up rank_tickers.py --db significantly
- Reduces API calls to yfinance
- Enables historical analysis with cached daily snapshots
- Required for database-based ranking operations
GUI Scripts
gui_calculator.py - Graphical User Interface
Purpose: Desktop GUI version of the calculator with visual charts
Output: - Interactive window with stock analysis - Volatility term structure graph - Visual representation of strategy metrics - User-friendly interface for non-command-line users
Usage:
Configuration
See Configuration Guide for detailed information on configuring strategy parameters.
Key configuration file: configs/strategy_config.toml
Adjustable parameters: - Minimum volume thresholds - IV/RV ratio requirements - Term structure slope criteria - Expiration date filters - Volatility calculation windows - Scoring weights for ticker ranking
Additional Resources
Monte Carlo / Backtest Results: https://docs.google.com/document/d/1_7UoFIqrTftoz-PJ0rxkttMc24inrAbWuZSbbOV-Jwk/edit?tab=t.0#heading=h.kc4shq41bugz
Trade Tracker Template: https://docs.google.com/spreadsheets/d/1z_PMFqmV_2XqlCcCAdA4wgxqDg0Ym7iSeygNRpsnpO8/edit?gid=0#gid=0 Go to file and make a copy or download it for excel (only tested in google sheets)
Typical Workflow
-
Cache Data (once per day):
-
Find Candidates (for upcoming week):
-
Rank Options (from cached data):
-
Deep Dive Analysis (on specific tickers):
Option A: Complete Analysis (Recommended for most users)
# All-in-one analysis with directional bias and exit strategy
uv run python scripts/calculator_with_strat.py
# → Shows: Expected move, directional bias, strike recommendation, exit rules
Option B: Individual Components
# Get expected move and metrics
uv run python scripts/calculator.py
# → Note: Expected Move: 8.5%
# Determine directional bias
uv run python scripts/directional_analysis.py NVDA
# → Note: Bias: Bullish, Confidence: 65%, Suggested Strike: $190
# Or compare two candidates
uv run python scripts/compare.py
- Backtest Strategy (periodically):