diff --git a/src/quant_platform_kit/common/small_account_compatibility.py b/src/quant_platform_kit/common/small_account_compatibility.py index 240f4ec..1a7d819 100644 --- a/src/quant_platform_kit/common/small_account_compatibility.py +++ b/src/quant_platform_kit/common/small_account_compatibility.py @@ -147,7 +147,7 @@ def apply_small_account_cash_compatibility( safe_haven_substituted.append(symbol) notes: list[dict[str, object]] = [] - if safe_haven_substituted: + if substituted: normalized_targets = { _normalize_symbol(symbol): float(value or 0.0) for symbol, value in dict(target_values or {}).items() diff --git a/tests/test_small_account_compatibility.py b/tests/test_small_account_compatibility.py index 314fb57..8879469 100644 --- a/tests/test_small_account_compatibility.py +++ b/tests/test_small_account_compatibility.py @@ -68,7 +68,17 @@ def test_keeps_safe_haven_when_cash_projection_exceeds_small_account_limit(self) self.assertEqual(result.targets["BOXX"], 5000.0) self.assertEqual(result.whole_share_substituted_symbols, ("SOXX",)) self.assertEqual(result.safe_haven_cash_substituted_symbols, ()) - self.assertEqual(result.cash_substitution_notes, ()) + self.assertEqual( + result.cash_substitution_notes, + ( + { + "symbol": "SOXX", + "target_value": 163.14, + "price": 504.60, + "cash_symbols": (), + }, + ), + ) def test_formats_cash_substitution_notes_through_i18n(self): messages = format_small_account_cash_substitution_notes( @@ -85,7 +95,7 @@ def test_formats_cash_substitution_notes_through_i18n(self): "buy_deferred": "ℹ️ [买入说明] {detail}", "buy_deferred_small_account_cash_substitution": ( "{symbol} 目标金额 ${diff} 低于 1 股价格 ${price};" - "为避免超过目标仓位,小账户本轮保留现金,不回补 {cash_symbols}" + "为避免超过目标仓位,本轮保留现金(现金替代:{cash_symbols})" ), }.get(key, key).format(**kwargs), ) @@ -94,7 +104,7 @@ def test_formats_cash_substitution_notes_through_i18n(self): messages, ( "ℹ️ [买入说明] SOXX.US 目标金额 $163.14 低于 1 股价格 $504.60;" - "为避免超过目标仓位,小账户本轮保留现金,不回补 BOXX.US", + "为避免超过目标仓位,本轮保留现金(现金替代:BOXX.US)", ), )