from fxhnt.application.paper_book import adaptive_target_vol

def test_bootstrap_below_min_obs_returns_base():
    assert adaptive_target_vol([0.01] * 5) == 0.30          # <20 obs -> base

def test_strong_sharpe_hits_vol_max():
    strong = [0.012, 0.010] * 40                            # positive mean, tiny vol -> huge Sharpe
    assert adaptive_target_vol(strong) == 0.35              # capped at vol_max

def test_negative_mean_floors_vol_min():
    weak = [0.010, -0.012] * 40                             # negative-ish mean -> Sharpe<=0 -> floor
    assert adaptive_target_vol(weak) == 0.25                # vol_min

def test_zero_vol_window_no_nan_floors_min():
    assert adaptive_target_vol([0.0] * 60) == 0.25          # sd=0 -> ts 0 -> frac 0 -> vol_min, no NaN

def test_monotone_and_bounded():
    lo = adaptive_target_vol([0.001, -0.0005] * 40)         # weak positive
    hi = adaptive_target_vol([0.012, 0.010] * 40)           # strong
    assert 0.25 <= lo <= hi <= 0.35
