core.test_hedge_edge

def test_calc_apr_zero_days():

Test APR calculation with zero days to expiry (Edge Case).

Background: APR = (1 + ROI)^(365/days) - 1. If days = 0, we have division by zero in the exponent.

Reasoning: Verify that the function handles 0 days gracefully (e.g., returns 0) instead of crashing.

def test_calc_apr_bankruptcy():

Test APR calculation with -100% ROI (Edge Case).

Background: If ROI is -1 (total loss), the base (1+ROI) is 0. 0^exponent is 0. APR should be -1 (-100%).

Reasoning: Verify power function handles base 0 correctly.

def test_calc_option_quantities_strike_above_ref():

Test Option Quantities for Strike > Reference Strike (Edge Case).

Background: The strategy usually buys puts for strikes below the reference (current/min) price to hedge downside. If Strike > Reference, the formula might imply selling calls or puts? The code logic: if strike <= reference_strike: ... else: qty = 0.

Reasoning: Verify that strikes above the reference explicitly return 0 quantity, ensuring we don't accidentally hedge upside or enter undefined behavior regions.

def test_calc_days_to_expiry_past_date():

Test Days to Expiry with a past date (Edge Case).

Background: If the user inputs an expiry date in the past, days will be negative.

Reasoning: Verify the calculation returns a negative integer, which other functions should handle (e.g. APR returns 0).

def test_put_payoff_deep_otm():

Test Put Payoff when Spot ends far above Strike (Edge Case).

Background: If Spot > Strike at expiry, Put is worthless.

Reasoning: Verify payoff is exactly 0.