Skip to content

Commit 7b38920

Browse files
committed
Report small-account cash substitutions
1 parent 7b641f1 commit 7b38920

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/quant_platform_kit/common/small_account_compatibility.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def apply_small_account_cash_compatibility(
147147
safe_haven_substituted.append(symbol)
148148

149149
notes: list[dict[str, object]] = []
150-
if safe_haven_substituted:
150+
if substituted:
151151
normalized_targets = {
152152
_normalize_symbol(symbol): float(value or 0.0)
153153
for symbol, value in dict(target_values or {}).items()

tests/test_small_account_compatibility.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,17 @@ def test_keeps_safe_haven_when_cash_projection_exceeds_small_account_limit(self)
6868
self.assertEqual(result.targets["BOXX"], 5000.0)
6969
self.assertEqual(result.whole_share_substituted_symbols, ("SOXX",))
7070
self.assertEqual(result.safe_haven_cash_substituted_symbols, ())
71-
self.assertEqual(result.cash_substitution_notes, ())
71+
self.assertEqual(
72+
result.cash_substitution_notes,
73+
(
74+
{
75+
"symbol": "SOXX",
76+
"target_value": 163.14,
77+
"price": 504.60,
78+
"cash_symbols": (),
79+
},
80+
),
81+
)
7282

7383
def test_formats_cash_substitution_notes_through_i18n(self):
7484
messages = format_small_account_cash_substitution_notes(
@@ -85,7 +95,7 @@ def test_formats_cash_substitution_notes_through_i18n(self):
8595
"buy_deferred": "ℹ️ [买入说明] {detail}",
8696
"buy_deferred_small_account_cash_substitution": (
8797
"{symbol} 目标金额 ${diff} 低于 1 股价格 ${price};"
88-
"为避免超过目标仓位,小账户本轮保留现金,不回补 {cash_symbols}"
98+
"为避免超过目标仓位,本轮保留现金(现金替代:{cash_symbols}"
8999
),
90100
}.get(key, key).format(**kwargs),
91101
)
@@ -94,7 +104,7 @@ def test_formats_cash_substitution_notes_through_i18n(self):
94104
messages,
95105
(
96106
"ℹ️ [买入说明] SOXX.US 目标金额 $163.14 低于 1 股价格 $504.60;"
97-
"为避免超过目标仓位,小账户本轮保留现金,不回补 BOXX.US",
107+
"为避免超过目标仓位,本轮保留现金(现金替代:BOXX.US",
98108
),
99109
)
100110

0 commit comments

Comments
 (0)