| self = <test_sector_momentum_filter.TestTrendStatsIntegration object at 0x124fd6390>
|
|
|
| def test_weak_sector_eis_override_blocks_low_eis(self):
|
| """
|
| When sector is WEAK and EIS <= 0.2, still filter out.
|
| """
|
| from datetime import date
|
| from rtrader.services.sector_trend_stats_service import SectorState, BuySafety
|
|
|
| apply_filter = self._get_filter_function()
|
|
|
| mock_caution_stats = self._make_mock_trend_stats(SectorState.ACCELERATION, BuySafety.CAUTION)
|
|
|
| with patch(
|
| "rtrader.config.settings",
|
| self._mock_settings_with_trend_state_enabled()
|
| ), patch(
|
| "rtrader.cli.trader_eod_core.services.log_formatting_service.settings",
|
| self._mock_settings_with_trend_state_enabled()
|
| ), patch(
|
| "rtrader.services.sector_trend_stats_service.calculate_all_sector_trend_stats_objects"
|
| ) as mock_batch:
|
| mock_batch.return_value = {"XLK": mock_caution_stats}
|
|
|
| picks = [
|
| {"symbol": "AVPT", "momentum_final_score": -0.014, "sector": "Technology", "eis_value": 0.10},
|
| ]
|
|
|
| result = apply_filter(
|
| picks=picks,
|
| weak_sectors={"XLK"},
|
| symbol_sectors={"AVPT": "Technology"},
|
| trading_day=date(2026, 1, 13),
|
| )
|
|
|
| # AVPT should be FILTERED — EIS 0.10 < 0.20 threshold
|
| > assert len(result.filtered_picks) == 0
|
| E AssertionError: assert 1 == 0
|
| E + where 1 = len([{'eis_value': 0.1, 'filter_reason': 'OK', 'filter_sector_etf': 'IGV', 'momentum_final_score': -0.014, ...}])
|
| E + where [{'eis_value': 0.1, 'filter_reason': 'OK', 'filter_sector_etf': 'IGV', 'momentum_final_score': -0.014, ...}] = SectorMomentumFilterResult(filtered_picks=[{'symbol': 'AVPT', 'momentum_final_score': -0.014, 'sector': 'Technology', 'eis_value': 0.1, 'sector_assignment_confidence': 1.0, 'sector_assignment_pass': 0, 'filter_sector_etf': 'IGV', 'filter_reason': 'OK'}], filtered_out_by_sector={}, saved_by_individual_momentum=[], filtered_out_negative_momentum=[], filtered_out_sector_etfs=[], filtered_out_negative_score=[], saved_by_breakout_exception=[], filtered_out_by_overheated_sector={}, filtered_out_ok_worsening={}, filtered_out_by_trend_state={}, saved_by_momentum_from_trend_state=[], filtered_out_by_family_breadth={}).filtered_picks
|
|
|
| BuySafety = <enum 'BuySafety'>
|
| SectorState = <enum 'SectorState'>
|
| apply_filter = <function apply_sector_momentum_filter at 0x124e97f60>
|
| date = <class 'datetime.date'>
|
| mock_batch = <MagicMock name='calculate_all_sector_trend_stats_objects' id='4988774560'>
|
| mock_caution_stats = <MagicMock id='4984629456'>
|
| picks = [{'eis_value': 0.1, 'filter_reason': 'OK', 'filter_sector_etf': 'IGV', 'momentum_final_score': -0.014, ...}]
|
| result = SectorMomentumFilterResult(filtered_picks=[{'symbol': 'AVPT', 'momentum_final_score': -0.014, 'sector': 'Technology', ...worsening={}, filtered_out_by_trend_state={}, saved_by_momentum_from_trend_state=[], filtered_out_by_family_breadth={})
|
| self = <test_sector_momentum_filter.TestTrendStatsIntegration object at 0x124fd6390>
|
|
|
| tests/cli/test_sector_momentum_filter.py:2417: AssertionError
|