Skip to content

Dynamic Exit Strategy - Feature Summary

Problem Solved

Question: "When should I take profits or cut losses?"

Old Answer: Fixed rules - Exit at 25% profit - Stop loss at 75% loss - Hold to expiration otherwise

New Answer: Greeks-based optimization - Exit when theta turns negative (losing time value) - Exit when Greeks risk too high (delta, gamma, vega exposure) - Exit after IV crush complete (profit captured) - Exit near expiration (time acceleration risk) - Dynamic scoring of 8 signals with confidence levels

What Was Built

1. Exit Strategy Optimizer (trade_calc/exit_strategy.py)

Core Components: - ExitStrategyOptimizer - Main analysis engine - PositionMetrics - Position data container - ExitSignal - Exit recommendation output - calculate_position_greeks() - Greeks calculator

8 Analysis Signals: 1. Profit Target (20%) - Target achievement 2. Stop Loss (25%) - Risk management 3. Theta Decay (15%) - Time value efficiency 4. Greeks Risk (15%) - Multi-dimensional exposure 5. Time Acceleration (10%) - Expiration proximity 6. P&L Velocity (5%) - Drawdown analysis 7. IV Change (5%) - Volatility impact 8. Position Health (5%) - Overall status

2. Monte Carlo Integration

New Parameters:

SimulationParams(
    use_dynamic_exit=True,        # Enable Greeks-based exits
    exit_on_theta_decay=True,     # Monitor theta
    exit_on_greeks_risk=True,     # Monitor Greeks
)

New Exit Reasons: - dynamic_theta - Theta optimization - dynamic_greeks - Greeks risk management - dynamic_iv - IV change response - dynamic_other - Other signal triggers

3. Demo Script (scripts/test_exit_strategy.py)

Shows 5 Scenarios: 1. ✅ Profitable trade near target 2. ❌ Losing trade approaching stop 3. ⚠️ Near expiration high gamma risk 4. ✅ IV crush complete 5. ✅ Healthy position to hold

Usage:

uv run python scripts/test_exit_strategy.py

4. Comprehensive Documentation

  • DYNAMIC_EXIT_GUIDE.md - Complete methodology (25+ pages)
  • DYNAMIC_EXIT_SUMMARY.md - This document
  • README.md - Updated with exit strategy integration

How It Works

Greeks Explained Simply

Theta (Time Decay)

What: Money made/lost per day - Positive: Earning money daily ✅ - Negative: Losing money daily ❌ - Calendar spreads need positive theta

Example:

Day 1: Theta = +$8/day  → Earning $8/day
Day 5: Theta = +$5/day  → Still earning, but less
Day 8: Theta = -$2/day  → LOSING $2/day → EXIT!

Delta (Directional Risk)

What: Position change per $1 stock move - Low (<0.20): Minimal directional risk ✅ - High (>0.30): Significant exposure ❌ - Calendar spreads should be near delta-neutral

Gamma (Delta Sensitivity)

What: How fast delta changes - Low: Stable, predictable ✅ - High: Volatile, risky (especially near expiration) ❌

Vega (IV Sensitivity)

What: Position change per 1% IV move - Moderate: Normal ✅ - High (>$20): Very sensitive to IV changes ❌

Exit Decision Process

graph TD
    A[Analyze Position] --> B{Theta Positive?}
    B -->|No| C[EXIT - Theta Negative]
    B -->|Yes| D{Days to Expiration?}
    D -->|≤2| E[EXIT - Gamma Risk]
    D -->|3-5| F{Greeks Risk High?}
    D -->|>5| G{Profit Target Hit?}
    F -->|Yes| H[EXIT - Risk Too High]
    F -->|No| I{IV Crushed >40%?}
    G -->|Yes| J[EXIT - Target Achieved]
    G -->|No| K{At Stop Loss?}
    I -->|Yes| L[CONSIDER EXIT - Profit Captured]
    I -->|No| M[HOLD - Position Healthy]
    K -->|Yes| N[EXIT - Cut Losses]
    K -->|No| O[HOLD - Monitor]

Usage Examples

Example 1: Basic Analysis

from trade_calc.exit_strategy import ExitStrategyOptimizer, PositionMetrics

# Current position state
metrics = PositionMetrics(
    current_pnl=45.0,              # Up $45
    max_pnl=48.0,                  # Peak was $48
    initial_cost=200.0,             # Cost $200 to enter
    max_profit_potential=185.0,     # Max profit is $185
    days_in_trade=5,                # Been in 5 days
    days_to_front_expiration=7,     # 7 days until front expires
    days_to_back_expiration=37,     # 37 days until back expires
    position_theta=8.5,             # Earning $8.50/day
    position_delta=0.12,            # Low directional exposure
    position_gamma=0.03,            # Moderate gamma
    position_vega=12.0,             # $12 per 1% IV change
    current_price=186.5,
    entry_price=185.0,
    strike_price=185.0,
    current_front_iv=0.35,          # IV now
    current_back_iv=0.38,
    entry_front_iv=0.60,            # IV at entry (42% crush!)
    entry_back_iv=0.40,
)

# Analyze
optimizer = ExitStrategyOptimizer()
signal = optimizer.analyze_exit(metrics)

# Results
print(f"Should Exit: {signal.should_exit}")
# Output: False (HOLD)
print(f"Confidence: {signal.confidence * 100:.0f}%")
# Output: 18% (low confidence to exit)
print(f"Reason: {signal.exit_reason}")
# Output: "Near profit target | IV crushed 42%"

Example 2: Monte Carlo with Dynamic Exits

from scripts.monte_carlo import SimulationParams, CalendarSpreadSimulator

params = SimulationParams(
    spot_price=185,
    strike_price=185,
    front_dte=7,
    back_dte=37,
    pre_earnings_iv=0.60,
    post_earnings_iv=0.30,
    back_month_pre_iv=0.40,
    back_month_post_iv=0.35,
    earnings_jump_mean=0.0,
    earnings_jump_std=0.05,
    drift_rate=0.0,
    risk_free_rate=0.05,
    num_simulations=5000,
    profit_target=0.25,
    expected_move_pct=8.5,
    # Enable dynamic exits
    use_dynamic_exit=True,
    exit_on_theta_decay=True,
    exit_on_greeks_risk=True,
)

simulator = CalendarSpreadSimulator(params)
results = simulator.run()
stats = simulator.analyze_results(results)

# See exit reason breakdown
print(stats['exit_reasons'])
# Output:
# {
#   'profit_target': 0.45,    # 45% hit profit target
#   'dynamic_theta': 0.25,    # 25% exited on theta
#   'dynamic_greeks': 0.15,   # 15% exited on Greeks risk
#   'expiration': 0.12,       # 12% held to expiration
#   'dynamic_iv': 0.03,       # 3% exited on IV change
# }

Example 3: Calculate Greeks

from trade_calc.exit_strategy import calculate_position_greeks

greeks = calculate_position_greeks(
    spot_price=185.0,
    strike_price=185.0,
    front_dte=7,
    back_dte=37,
    front_iv=0.35,
    back_iv=0.40,
    risk_free_rate=0.05,
)

print(f"Theta: ${greeks['theta']:.2f}/day")
print(f"Delta: {greeks['delta']:.4f}")
print(f"Gamma: {greeks['gamma']:.5f}")
print(f"Vega: ${greeks['vega']:.2f} per 1% IV")

Real-World Scenario Analysis

Scenario A: Losing Position with Negative Theta

Position: -$140 (down 70%)
Theta: -$2.50/day (LOSING money daily)
Days to Expiration: 4
Delta: -0.45 (high directional risk)

Signals:
  ❌ Negative theta (0.80 score)
  ❌ Approaching stop loss (0.50 score)
  ❌ High delta exposure (0.60 score)
  ❌ Near expiration (0.60 score)

Decision: EXIT RECOMMENDED (48% confidence, HIGH urgency)
Reason: "Negative theta - losing time value"
Action: Close position immediately - can't recover

Scenario B: Profitable Position Near Expiration

Position: +$25 (up 12.5%)
Theta: +$15.50/day (HIGH theta)
Days to Expiration: 2 (VERY SHORT!)
Gamma: 0.150 (VERY HIGH)

Signals:
  ⚠️ Extreme time acceleration (0.90 score)
  ⚠️ High gamma risk (0.70 score)
  ⚠️ Large drawdown from peak (0.80 score)

Decision: EXIT RECOMMENDED (37% confidence, HIGH urgency)
Reason: "Extreme theta acceleration (2 days)"
Action: Exit before gamma risk materializes

Scenario C: Healthy Position to Hold

Position: +$20 (up 10%)
Theta: +$7.50/day (earning daily)
Days to Expiration: 10 (plenty of time)
Delta: 0.05 (minimal risk)
IV: Only 17% crushed (more to come)

Signals:
  ✅ Positive theta (0.00 score)
  ✅ Low Greeks risk (0.00 score)
  ✅ Good time remaining (0.00 score)

Decision: HOLD POSITION (0% confidence, LOW urgency)
Reason: "Hold position - no strong exit signals"
Action: Continue holding - theta working favorably

Benefits

1. Intelligent Exits

  • Not arbitrary: Based on Greeks and position health
  • Not emotional: Systematic analysis
  • Not one-size-fits-all: Adapts to position specifics

2. Better Risk Management

  • Theta monitoring: Exit when losing time value
  • Greeks exposure: Manage delta, gamma, vega risk
  • Time-aware: Adjust for expiration proximity

3. Profit Optimization

  • Exit timing: When theta becomes less favorable
  • IV capture: Exit after significant IV crush
  • Peak P&L tracking: Avoid large drawdowns

4. Backtest-able

  • Monte Carlo integration: Test different exit strategies
  • Historical analysis: See which signals work best
  • Strategy refinement: Optimize for your style

Configuration Tips

Conservative (Lower Risk)

ExitStrategyOptimizer(
    profit_target_pct=0.20,    # Exit at lower profit
    stop_loss_pct=0.60,        # Tighter stop loss
    theta_exit_threshold=0.15,  # Exit on small theta drop
)

Aggressive (Higher Risk/Reward)

ExitStrategyOptimizer(
    profit_target_pct=0.40,    # Hold for more profit
    stop_loss_pct=0.90,        # Wider stop loss
    theta_exit_threshold=0.05,  # Only exit on large theta drop
)
ExitStrategyOptimizer(
    profit_target_pct=0.25,    # Standard profit target
    stop_loss_pct=0.75,        # Standard stop
    theta_exit_threshold=0.10,  # Moderate theta threshold
)

Integration with Existing Features

Complete Trading Workflow

1. Screen Candidates
   scripts/rank_tickers.py

2. Analyze Opportunity
   scripts/calculator.py
   → Expected Move: 8.5%

3. Determine Direction
   scripts/directional_analysis.py
   → Bias: Bullish, +3.5%

4. Backtest Strategy
   scripts/monte_carlo.py
   → With dynamic exits enabled
   → See exit reason distribution

5. Enter Trade
   Use suggested strike from directional analysis

6. Monitor Position (NEW!)
   Calculate Greeks daily
   Run exit analysis
   Check if exit signal triggered

7. Exit Trade
   Based on dynamic exit recommendation

Key Metrics to Monitor

Daily Checklist

  • Calculate current theta
  • Check days to expiration
  • Monitor delta exposure
  • Track P&L vs peak
  • Check IV changes
  • Run exit analysis

Red Flags (Consider Exit)

  • ❌ Theta turns negative
  • ❌ Delta > 0.30
  • ❌ Days to expiration ≤ 3
  • ❌ Drawdown > 30% from peak
  • ❌ IV increased 20%+

Green Lights (Continue Holding)

  • ✅ Theta positive and stable
  • ✅ Low delta (<0.20)
  • ✅ Good time remaining (>5 days)
  • ✅ P&L stable or improving
  • ✅ IV crushed as expected

Files Created/Modified

New Files:

  1. trade_calc/exit_strategy.py - Core optimizer
  2. scripts/test_exit_strategy.py - Demo script
  3. DYNAMIC_EXIT_GUIDE.md - Full documentation
  4. DYNAMIC_EXIT_SUMMARY.md - This summary

Modified Files:

  1. scripts/monte_carlo.py - Integrated dynamic exits
  2. scripts/run_yearly_analysis.py - Added exit parameters
  3. README.md - Updated with exit strategy info

Testing

# Test exit scenarios
uv run python scripts/test_exit_strategy.py

# Test with Monte Carlo (50 simulations for speed)
uv run python scripts/monte_carlo.py
# (Edit to set num_simulations=50 and use_dynamic_exit=True)

# Full yearly simulation
uv run python scripts/run_yearly_analysis.py
# (Edit to set use_dynamic_exit=True)

Limitations

1. Not a Crystal Ball

  • Exit signals are probabilistic
  • Markets can behave unexpectedly
  • Greeks don't capture all risks

2. Requires Monitoring

  • Need to calculate Greeks regularly
  • Must track position metrics
  • Time-intensive for many positions

3. May Exit Too Early

  • Conservative settings exit quickly
  • Might miss additional profits
  • Tune thresholds to your style

4. Greeks Assumptions

  • Based on Black-Scholes model
  • Assumes efficient markets
  • Doesn't account for skew/kurtosis

Best Practices

1. Start Conservative

  • Use default settings first
  • Monitor results vs your intuition
  • Adjust gradually based on experience

2. Combine Signals

  • Don't rely on one signal
  • Consider overall confidence level
  • Use urgency as priority guide

3. Paper Trade First

  • Test in simulation
  • Track hypothetical exits
  • Compare with actual exits
  • Build confidence in system

4. Document Decisions

  • Record why you exited
  • Compare with optimizer recommendation
  • Learn from differences
  • Refine your approach

FAQ

Q: Do I need to use dynamic exits? A: No - it's optional. Set use_dynamic_exit=False for simple rules.

Q: How do I calculate Greeks for my live position? A: Use calculate_position_greeks() with current market data.

Q: Should I always follow the exit signal? A: No - use as one input among fundamentals, market conditions, risk tolerance.

Q: What if optimizer says exit but I disagree? A: Check which signal triggered. Adjust weights or override if you have good reason.

Q: How often should I run exit analysis? A: Daily minimum. More frequently near expiration (intraday).

Q: Can I customize the signals? A: Yes - modify ExitStrategyOptimizer weights and thresholds.

Conclusion

The Dynamic Exit Strategy Optimizer provides:

Theta-based exits - Exit when time decay becomes unfavorable ✅ Greeks risk management - Monitor delta, gamma, vega exposure ✅ Multi-signal analysis - 8 weighted signals with confidence scoring ✅ Monte Carlo integration - Backtest exit strategies ✅ Configurable rules - Adjust to your trading style ✅ Real-time analysis - Monitor positions continuously

Key Insight: Calendar spreads profit from positive theta. Exit when theta turns negative or Greeks risk becomes too high, not just based on arbitrary P&L levels.

For complete methodology and examples, see DYNAMIC_EXIT_GUIDE.md.