"""Sign guard for candidate edge #4 (turnover-pump short) in build_honest_report.

`_pump_weights` pairs each pump-short signal with the RAW next-day price return (the repo convention
(weight, raw_price_return)), so honest_sleeve_returns books gross = w*r. A short (weight -1) on a coin that
CRASHES must book a POSITIVE gross; a further PUMP must book a NEGATIVE gross. A prior double-negation (pairing
-1.0 with a pre-negated return) inverted this and booked crashes as losses."""
from __future__ import annotations

from fxhnt.application.honest_report import _pump_weights


def test_pump_short_books_positive_on_crash_negative_on_further_pump():
    sig = {5: {"CRASH": -1.0, "PUMP": -1.0}}
    close_panel = {
        "CRASH": {5: 100.0, 6: 80.0},    # -20% next day -> short should WIN
        "PUMP":  {5: 100.0, 6: 120.0},   # +20% next day -> short should LOSE
    }
    wbd = _pump_weights(sig, close_panel)

    w_crash, r_crash = wbd[5]["CRASH"]
    w_pump, r_pump = wbd[5]["PUMP"]

    assert w_crash == -1.0 and abs(r_crash - (-0.20)) < 1e-12   # RAW return, not pre-negated
    assert w_pump == -1.0 and abs(r_pump - 0.20) < 1e-12

    # honest_sleeve_returns books gross = w * r:
    assert w_crash * r_crash > 0.0        # short on a crash -> POSITIVE gross (+0.20)
    assert w_pump * r_pump < 0.0          # short on a further pump -> NEGATIVE gross (-0.20)
