core.test_solver_edge

Edge Case Tests for Hedge Portfolio Optimization Solver

This module contains edge case tests for the solver functions in src/core/solver.py.

def test_pmin_close_to_spot():

Test when Pmin is very close to the spot price.

def test_no_strikes_between_pmin_and_spot():

Test when no round strikes fall between Pmin and spot.

def test_spot_is_a_strike():

Test when the spot price is a multiple of the strike step.

def test_low_pmin_excludes_negative_strikes():

Test that negative strikes are excluded when Pmin is very low.

def test_extension_below_pmin_zero():

Test with no extension below Pmin (backward compatibility).

def test_custom_extension_below_pmin():

Test with custom extension value (5 strikes below Pmin).

def test_narrow_price_range():

Test with a very narrow Pmin-Pmax range.

def test_pmin_pmax_equal():

Test when Pmin and Pmax are equal.

def test_large_buffer():

Test with a larger buffer.

@pytest.fixture
def sample_edge_case_data():

Fixture to provide sample data for edge case tests.

@pytest.mark.filterwarnings('ignore:delta_grad == 0.0')
@pytest.mark.parametrize('solver', [SolverMethod.LBFGSB, SolverMethod.SLSQP, SolverMethod.TRUST_CONSTR])
def test_all_solvers_edge(solver, sample_edge_case_data):

Test that each solver runs successfully.

@pytest.mark.filterwarnings('ignore:delta_grad == 0.0')
def test_changeable_mask_edge(sample_edge_case_data):

Test with a mask to fix some quantities.

@pytest.mark.filterwarnings('ignore:delta_grad == 0.0')
def test_include_mask_edge(sample_edge_case_data):

Test including only a subset of variations in the objective.

@pytest.mark.filterwarnings('ignore:delta_grad == 0.0')
def test_no_positive_sum_constraint_edge(sample_edge_case_data):

Test without the sum(quantities) >= 0 constraint.

def test_run_hedge_optimization_wrapper():

Test the full workflow wrapper.