Add YoY edge case tests for 5 and 4 quarter scenarios
Co-authored-by: aguzererler <6199053+aguzererler@users.noreply.github.com> Agent-Logs-Url: https://github.com/aguzererler/TradingAgents/sessions/b594017b-ed84-4786-9b81-200a78eb5d76
This commit is contained in:
parent
3d76acf17d
commit
a8ccff31a0
|
|
@ -174,6 +174,25 @@ class TestComputeTTMMetrics:
|
|||
expected_yoy = ((1.05 ** 4) - 1) * 100
|
||||
assert abs(yoy - expected_yoy) < 0.5
|
||||
|
||||
def test_revenue_yoy_with_exactly_5_quarters(self):
|
||||
"""YoY is available when exactly 5 quarters exist (minimum for 4-quarter lookback)."""
|
||||
result = self.compute(
|
||||
_make_income_csv(5), _make_balance_csv(5), _make_cashflow_csv(5)
|
||||
)
|
||||
yoy = result["trends"]["revenue_yoy_pct"]
|
||||
assert yoy is not None
|
||||
# quarterly[-5] vs quarterly[-1] with 5% QoQ → 1.05^4 - 1 ≈ 21.55%
|
||||
expected_yoy = ((1.05 ** 4) - 1) * 100
|
||||
assert abs(yoy - expected_yoy) < 0.5
|
||||
|
||||
def test_revenue_yoy_none_with_4_quarters(self):
|
||||
"""YoY should be None when fewer than 5 quarters are available."""
|
||||
result = self.compute(
|
||||
_make_income_csv(4), _make_balance_csv(4), _make_cashflow_csv(4)
|
||||
)
|
||||
yoy = result["trends"]["revenue_yoy_pct"]
|
||||
assert yoy is None
|
||||
|
||||
def test_margin_trend_expanding(self):
|
||||
"""Expanding margin should be detected."""
|
||||
# Create data where net margin expands over time
|
||||
|
|
|
|||
Loading…
Reference in New Issue