Detroits : niveau de perturbation vs dynamique, reference pre-crise, et Brent quotidien prioritaire
Le garde-fou absolu sur le volume PortWatch est supprime : un effondrement mesure est un signal, pas une donnee impossible. Chaque detroit expose desormais deux dimensions separees, calculees avec la meme metrique que la valeur du jour (petroliers avec petroliers) : le niveau par rapport a une reference pre-crise (mediane de 1000 jours 2022-2025, job mensuel chokepoint_reference) et la dynamique recente face a la moyenne 10 jours, J-7 puis J-1, sans interpreter des variations trop faibles en valeur absolue. La confiance de la donnee combine qualite de mesure et corroboration par les articles suivis : un effondrement corrobore conserve le signal avec une confiance reduite et AIS explique. Le facteur brut n accepte plus qu une cotation quotidienne fraiche ; la moyenne mensuelle DGEC devient un contexte historique affiche a part, jamais un cours du jour.
This commit is contained in:
@@ -28,85 +28,6 @@ def test_factors_report_unknown_without_data(store):
|
||||
assert "pas encore" in built["plain"] and "prévision" in built["disclaimer"]
|
||||
|
||||
|
||||
def test_brut_factor_detects_a_rise_and_a_fall(store):
|
||||
seed(
|
||||
"brent_eur_daily",
|
||||
"EUR/baril",
|
||||
[
|
||||
dict(day=days_ago(9), value=80.0),
|
||||
dict(day=days_ago(3), value=84.0),
|
||||
dict(day=days_ago(1), value=88.0),
|
||||
],
|
||||
)
|
||||
factor = synthesis.factor_brut()
|
||||
assert factor["direction"] == synthesis.UP
|
||||
assert factor["arrow"] == "↑"
|
||||
assert factor["change_pct"] == pytest.approx(10.0)
|
||||
assert factor["fresh"] is True
|
||||
assert factor["observed_at"] == days_ago(1)
|
||||
seed(
|
||||
"brent_eur_daily", "EUR/baril", [dict(day=days_ago(8), value=88.0), dict(day=days_ago(1), value=72.0)]
|
||||
)
|
||||
fall = synthesis.factor_brut()
|
||||
assert fall["direction"] == synthesis.DOWN and fall["arrow"] == "↓"
|
||||
|
||||
|
||||
def test_brut_factor_marks_stale_data_and_flat_move(store):
|
||||
# Le brut tolère une donnée mensuelle (DGEC) : l'ancienneté se juge donc à ~45 jours.
|
||||
seed(
|
||||
"brent_eur_daily",
|
||||
"EUR/baril",
|
||||
[dict(day=days_ago(60), value=80.0), dict(day=days_ago(50), value=80.4)],
|
||||
)
|
||||
factor = synthesis.factor_brut()
|
||||
assert factor["direction"] == synthesis.FLAT, "variation sous le seuil : peu d’effet"
|
||||
assert factor["fresh"] is False and factor["age_days"] >= 45
|
||||
|
||||
|
||||
def test_change_factor_inverts_direction(store):
|
||||
# Le taux BCE est « dollars par euro » : un euro plus fort allège la facture en euros.
|
||||
# Les deux signes sont verrouillés dans tests/test_factor_signs.py.
|
||||
seed("usd_per_eur", "USD/EUR", [dict(day=days_ago(6), value=1.10), dict(day=days_ago(1), value=1.16)])
|
||||
factor = synthesis.factor_change()
|
||||
assert factor["direction"] == synthesis.DOWN
|
||||
assert factor["change_pct"] > 0
|
||||
assert factor["effect"] == "↓ pression sur les prix"
|
||||
|
||||
|
||||
def test_logistique_factor_reads_chokepoint_traffic(store):
|
||||
rows = []
|
||||
for index in range(6):
|
||||
rows.append(
|
||||
(
|
||||
"Strait of Hormuz",
|
||||
dict(
|
||||
day=days_ago(25 - index * 4),
|
||||
transit_tankers=40,
|
||||
transit_total=90,
|
||||
capacity_tankers=1000,
|
||||
capacity_total=2000,
|
||||
),
|
||||
)
|
||||
)
|
||||
rows.append(
|
||||
(
|
||||
"Strait of Hormuz",
|
||||
dict(
|
||||
day=days_ago(1),
|
||||
transit_tankers=22,
|
||||
transit_total=60,
|
||||
capacity_tankers=600,
|
||||
capacity_total=1200,
|
||||
),
|
||||
)
|
||||
)
|
||||
storage.save_chokepoints(rows, "IMF PortWatch")
|
||||
factor = synthesis.factor_logistique()
|
||||
assert factor["direction"] == synthesis.UP, "moins de pétroliers : approvisionnement tendu"
|
||||
assert "Hormuz" in factor["evidence_text"]
|
||||
assert "PortWatch" in factor["source"]
|
||||
|
||||
|
||||
def test_evenements_factor_weighs_confidence_and_expiry(store):
|
||||
base = dict(
|
||||
topic="ormuz",
|
||||
@@ -158,8 +79,11 @@ def test_evenements_factor_weighs_confidence_and_expiry(store):
|
||||
|
||||
|
||||
def test_pressure_aggregates_weights_and_confidence(store):
|
||||
# Cotation quotidienne fraîche : le brut n'accepte plus une série mensuelle comme cours du jour.
|
||||
seed(
|
||||
"brent_eur_daily", "EUR/baril", [dict(day=days_ago(9), value=80.0), dict(day=days_ago(1), value=92.0)]
|
||||
"brent_eur_daily",
|
||||
"EUR/baril",
|
||||
[dict(day=days_ago(off), value=80.0 + (5 - off) * 2.4) for off in range(5, 0, -1)],
|
||||
)
|
||||
seed(
|
||||
"dgec_margin_eur_per_tonne",
|
||||
@@ -170,7 +94,7 @@ def test_pressure_aggregates_weights_and_confidence(store):
|
||||
assert built["pressure"] == "HAUSSE"
|
||||
assert built["confidence"] is not None and 0 < built["confidence"] <= 0.8
|
||||
assert built["known_factors"] >= 2
|
||||
up = [f["label"] for f in built["factors"] if f["direction"] == "up"]
|
||||
up = [factor["label"] for factor in built["factors"] if factor["direction"] == "up"]
|
||||
assert "Pétrole brut" in up
|
||||
assert "montent" in built["plain"] and "pèse le plus" in built["plain"]
|
||||
assert "jamais comme une prévision validée" in built["plain"]
|
||||
|
||||
Reference in New Issue
Block a user