|
14 | 14 | build_strategy_display_name, |
15 | 15 | build_translator, |
16 | 16 | ) |
17 | | -from notifications.renderers import render_heartbeat_notification |
| 17 | +from notifications.renderers import render_heartbeat_notification, render_rebalance_notification |
18 | 18 | from strategy_registry import SUPPORTED_STRATEGY_PROFILES |
19 | 19 |
|
20 | 20 |
|
@@ -388,6 +388,44 @@ def test_heartbeat_localizes_strategy_diagnostics_and_source_input_status(self): |
388 | 388 | self.assertNotIn("target_stock=", rendered.compact_text) |
389 | 389 | self.assertNotIn("partial_history_refresh", rendered.compact_text) |
390 | 390 |
|
| 391 | + def test_dashboard_relabels_buying_power_for_cash_only_execution(self): |
| 392 | + rendered = render_rebalance_notification( |
| 393 | + execution={ |
| 394 | + "dashboard_text": " - 购买力: $100.00 | 可投资现金: $50.00", |
| 395 | + "cash_only_execution": True, |
| 396 | + "signal_display": "hold", |
| 397 | + "status_display": "hold", |
| 398 | + }, |
| 399 | + logs=(), |
| 400 | + skip_logs=(), |
| 401 | + note_logs=(), |
| 402 | + translator=build_translator("zh"), |
| 403 | + separator="━━━━━━━━━━━━━━━━━━", |
| 404 | + strategy_display_name="demo", |
| 405 | + dry_run_only=False, |
| 406 | + ) |
| 407 | + self.assertIn("可用现金: $100.00", rendered.compact_text) |
| 408 | + self.assertNotIn("购买力: $100.00", rendered.compact_text) |
| 409 | + |
| 410 | + def test_dashboard_keeps_margin_buying_power_label_when_cash_only_disabled(self): |
| 411 | + rendered = render_rebalance_notification( |
| 412 | + execution={ |
| 413 | + "dashboard_text": " - Available cash: $100.00 | Investable cash: $50.00", |
| 414 | + "cash_only_execution": False, |
| 415 | + "signal_display": "hold", |
| 416 | + "status_display": "hold", |
| 417 | + }, |
| 418 | + logs=(), |
| 419 | + skip_logs=(), |
| 420 | + note_logs=(), |
| 421 | + translator=build_translator("en"), |
| 422 | + separator="━━━━━━━━━━━━━━━━━━", |
| 423 | + strategy_display_name="demo", |
| 424 | + dry_run_only=False, |
| 425 | + ) |
| 426 | + self.assertIn("Buying power: $100.00", rendered.compact_text) |
| 427 | + self.assertNotIn("Available cash: $100.00", rendered.compact_text) |
| 428 | + |
391 | 429 | def test_build_prefixer_prefers_account_prefix_only(self): |
392 | 430 | with_prefix = build_prefixer("HK", "longbridge-quant-semiconductor-rotation-income-hk") |
393 | 431 | self.assertEqual(with_prefix("hello"), "[HK] hello") |
|
0 commit comments