File size: 4,559 Bytes
aabd2be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | """
bsm_engine.py
Subagent 3: Derivatives & Executive Compensation Pricing Engine
Implements Black-Scholes-Merton (BSM) formula, Greeks (Delta, Vega, Gamma),
and dividend protection simulation under leverage-induced volatility expansion.
"""
import numpy as np
from scipy.stats import norm
import pandas as pd
def black_scholes_call(S, K, T, r, sigma, q=0.0):
"""
Standard Black-Scholes-Merton Call Option Pricing with Greeks
"""
if T <= 0:
return max(0.0, S - K), 0.0, 0.0
d1 = (np.log(S / K) + (r - q + 0.5 * sigma ** 2) * T) / (sigma * np.sqrt(T))
d2 = d1 - sigma * np.sqrt(T)
call_price = S * np.exp(-q * T) * norm.cdf(d1) - K * np.exp(-r * T) * norm.cdf(d2)
delta = np.exp(-q * T) * norm.cdf(d1)
vega = S * np.exp(-q * T) * norm.pdf(d1) * np.sqrt(T)
gamma = (norm.pdf(d1) * np.exp(-q * T)) / (S * sigma * np.sqrt(T))
return call_price, delta, vega, gamma
def simulate_dividend_impact(S_0, K_0, T, r, sigma_0, dividend, sigma_increase=0.10):
"""
Compares:
1. Baseline (T0): Value prior to distribution.
2. Scenario A (Unprotected): S -> S - D, K unchanged.
3. Scenario B (Protected + Volatility Expansion): K -> K - D, S -> S - D, sigma -> sigma + sigma_increase.
"""
val_pre, delta_pre, vega_pre, gamma_pre = black_scholes_call(S_0, K_0, T, r, sigma_0)
# Scenario A: Unprotected (Stock drops by dividend, Strike unchanged)
S_post = max(0.01, S_0 - dividend)
val_unprotected, delta_unprot, vega_unprot, _ = black_scholes_call(S_post, K_0, T, r, sigma_0)
# Protected baseline (Strike adjusted to K - D, but volatility unchanged)
K_post = max(0.01, K_0 - dividend)
val_protected_same_vol, _, _, _ = black_scholes_call(S_post, K_post, T, r, sigma_0)
# Scenario B: Protected + Leverage-Induced Volatility Jump
sigma_post = sigma_0 + sigma_increase
val_protected_higher_vol, delta_prot, vega_prot, gamma_prot = black_scholes_call(
S=S_post,
K=K_post,
T=T,
r=r,
sigma=sigma_post
)
net_benefit_vs_unprotected = val_protected_higher_vol - val_unprotected
net_benefit_vs_pre = val_protected_higher_vol - val_pre
return {
"S_0": S_0,
"K_0": K_0,
"Dividend": dividend,
"S_Post": S_post,
"K_Post": K_post,
"T": T,
"Risk_Free_Rate": r,
"Sigma_0": sigma_0,
"Sigma_Post": sigma_post,
"Sigma_Increase": sigma_increase,
"Value_Pre_Div": val_pre,
"Value_Unprotected": val_unprotected,
"Value_Protected_Same_Vol": val_protected_same_vol,
"Value_Protected_Higher_Vol": val_protected_higher_vol,
"Loss_If_Unprotected": val_unprotected - val_pre,
"Gain_From_Protection_Clause": val_protected_same_vol - val_unprotected,
"Gain_From_Leverage_Volatility": val_protected_higher_vol - val_protected_same_vol,
"Net_Benefit_To_Executive": net_benefit_vs_unprotected,
"Total_Value_Change_Post_Event": net_benefit_vs_pre,
"Delta_Pre": delta_pre,
"Delta_Post": delta_prot,
"Vega_Pre": vega_pre,
"Vega_Post": vega_prot
}
def run_sensitivity_grid(S_0, K_0, T, r, sigma_0, dividend):
"""
Runs multi-parameter grid across strike moneyness and volatility shocks (0.02 to 0.16).
"""
moneyness_factors = [0.8, 0.9, 1.0, 1.1, 1.2]
vol_shocks = [0.02, 0.05, 0.08, 0.10, 0.12, 0.15]
records = []
for m in moneyness_factors:
curr_k = S_0 * m
for v_shock in vol_shocks:
res = simulate_dividend_impact(S_0, curr_k, T, r, sigma_0, dividend, sigma_increase=v_shock)
records.append({
"Moneyness_K_over_S": m,
"Strike_K": curr_k,
"Vol_Shock": v_shock,
"Val_Pre": res["Value_Pre_Div"],
"Val_Unprot": res["Value_Unprotected"],
"Val_Prot_Vol": res["Value_Protected_Higher_Vol"],
"Net_Gain_NIS": res["Net_Benefit_To_Executive"],
"Pct_Gain": (res["Value_Protected_Higher_Vol"] / res["Value_Unprotected"] - 1) * 100,
"Vega": res["Vega_Post"]
})
return pd.DataFrame(records)
if __name__ == "__main__":
test_sim = simulate_dividend_impact(S_0=100.0, K_0=100.0, T=3.0, r=0.04, sigma_0=0.30, dividend=15.0, sigma_increase=0.10)
print("BSM Simulation Test:")
for k, v in test_sim.items():
print(f" {k}: {v:.4f}" if isinstance(v, float) else f" {k}: {v}")
|