feat: add split-safe fundamentals research protocol
This commit is contained in:
@@ -51,6 +51,45 @@ def test_composites_use_equal_subgroup_weighting():
|
||||
assert scores["3"]["balanced"] == 50.0
|
||||
|
||||
|
||||
def test_split_safe_composites_ignore_eps_and_share_count():
|
||||
def features(unsafe_multiplier: int):
|
||||
return {
|
||||
str(index): {
|
||||
"operating_margin": index,
|
||||
"fcf_margin": index,
|
||||
"net_debt_to_ebitda": 6 - index,
|
||||
"revenue_growth_yoy": index,
|
||||
"eps_growth_yoy": unsafe_multiplier * (6 - index),
|
||||
"share_count_change_yoy": unsafe_multiplier * index,
|
||||
}
|
||||
for index in range(1, 6)
|
||||
}
|
||||
|
||||
baseline = research.cross_section_scores(features(1), split_safe=True)
|
||||
distorted = research.cross_section_scores(features(1_000_000), split_safe=True)
|
||||
|
||||
assert distorted == baseline
|
||||
assert baseline["5"]["quality"] == 100.0
|
||||
assert baseline["5"]["growth"] == 100.0
|
||||
assert baseline["5"]["balanced"] == 100.0
|
||||
assert "eps_growth_yoy" not in baseline["5"]
|
||||
assert "share_count_change_yoy" not in baseline["5"]
|
||||
|
||||
|
||||
def test_split_safe_quality_still_requires_two_comparable_inputs():
|
||||
features = {
|
||||
str(index): {
|
||||
"operating_margin": index,
|
||||
"revenue_growth_yoy": index,
|
||||
}
|
||||
for index in range(1, 6)
|
||||
}
|
||||
scores = research.cross_section_scores(features, split_safe=True)
|
||||
assert all(row["quality"] is None for row in scores.values())
|
||||
assert scores["5"]["growth"] == 100.0
|
||||
assert scores["5"]["balanced"] is None
|
||||
|
||||
|
||||
def test_overlay_uses_neutral_missing_score_and_validates_weight():
|
||||
assert research.overlay_rank(90, None, 0.2) == 82.0
|
||||
assert research.overlay_rank(90, 100, 0.2) == 92.0
|
||||
|
||||
Reference in New Issue
Block a user