core.test_black_scholes_edge

def test_bs_put_expiry_time_zero():

Test Black-Scholes Put at Expiry (Time = 0) (Edge Case).

Background: At expiration, the option has no time value. Its price is purely intrinsic: Max(Strike - Spot, 0).

Reasoning: Verify the formula handles T=0 correctly (avoiding division by zero in d1/d2) and returns the exact intrinsic value (normalized by spot as per function contract).

def test_bs_put_zero_volatility():

Test Black-Scholes Put with Zero Volatility (Edge Case).

Background: With zero volatility, the asset price is deterministic. The option value converges to the intrinsic value discounted at the risk-free rate. Standard BS formula involves division by volatility (sigma), so this usually requires a limit handling or checking for 0.

Reasoning: Our implementation might calculate d1/d2 which has volatility in denominator. We test if it handles this (raises error or returns intrinsic). If the current implementation doesn't handle vol=0 explicitly, it might raise DivisionByZero. Ideally, it should handle it or we expect the error. Checking code: It divides by volatility * sqrt_t. So we expect ZeroDivisionError or similar if not handled. Let's check if we should fix code or expect error. For this test, we'll assume the model requires Vol > 0 and expect an error or if the requirement is to support it, we'd verify the fix. Given "safe_sqrt" etc, let's see. Actually, usually BS models require vol > 0. We'll test that it raises an error or handles it. If the code doesn't check if volatility == 0, it will crash. We'll write the test to EXPECT the crash or correct behavior if we see fit. Let's assume we expect a crash (ZeroDivision) for now as standard BS behavior without limits.

def test_bs_call_deep_otm():

Test Black-Scholes Call Deep OTM (Edge Case).

Background: If Spot << Strike, the call option is deeply out of the money. With moderate time/volatility, the probability of exercise is near 0.

Reasoning: The price should be effectively zero. This tests the numerical stability of the cumulative distribution function and the formula when d1/d2 are large negative.

def test_bs_call_deep_itm():

Test Black-Scholes Call Deep ITM (Edge Case).

Background: If Spot >> Strike, the call option is deeply in the money (delta ~ 1). The price should be roughly Spot - Strike * e^(-rT).

Reasoning: Verifies that for high probability of exercise, the formula converges to the forward intrinsic value.

def test_bs_put_invalid_spot_strike():

Test that black_scholes_put raises ValueError for non-positive spot or strike.

def test_bs_call_invalid_spot_strike():

Test that black_scholes_call raises ValueError for non-positive spot or strike.