Skip to content

Commit 732d846

Browse files
committed
fix(review-feedback-1289): <sub <sub !P2 Badge</sub </sub Detect buy advice before skipping
1 parent ceb3e4f commit 732d846

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/analyzer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,15 @@ def stabilize_decision_with_structure(
726726
default=getattr(result, "decision_type", "hold") or "hold",
727727
)
728728
decision_type = decision_type if decision_type in {"buy", "hold", "sell"} else "hold"
729+
advice_decision_type = infer_decision_type_from_advice(
730+
getattr(result, "operation_advice", ""),
731+
default="",
732+
)
729733

730734
flow_bias, flow_reason = _capital_flow_bias_with_status(fundamental_context)
731735
if flow_bias == "unavailable":
732736
if isinstance(fundamental_context, dict) and "capital_flow" in fundamental_context:
733-
if decision_type == "buy":
737+
if decision_type == "buy" or advice_decision_type == "buy":
734738
_downgrade_buy_without_capital_flow(
735739
result,
736740
language,

tests/test_decision_stability.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,27 @@ def test_downgrades_buy_when_capital_flow_values_are_na() -> None:
198198
assert "资金流数据缺失" in result.dashboard["decision_stability"]["capital_flow_status"]
199199

200200

201+
def test_downgrades_buy_advice_when_decision_type_is_hold_and_capital_flow_unavailable() -> None:
202+
result = _result(
203+
decision_type="hold",
204+
operation_advice="建议买入",
205+
score=68,
206+
current_price=32.0,
207+
)
208+
209+
stabilize_decision_with_structure(
210+
result,
211+
SimpleNamespace(support_levels=[30.0], resistance_levels=[34.0]),
212+
_unsupported_fund_flow(),
213+
)
214+
215+
assert result.decision_type == "hold"
216+
assert result.operation_advice == "持有观察"
217+
assert result.sentiment_score <= 59
218+
assert result.dashboard["decision_stability"]["applied"] is True
219+
assert "买入结论缺少资金面确认" in result.dashboard["decision_stability"]["reason"]
220+
221+
201222
def test_downgrades_buy_when_capital_flow_status_is_unavailable_case_insensitive() -> None:
202223
buy_result = _result(
203224
decision_type="buy",

0 commit comments

Comments
 (0)