From 432b2d74e0a08a27a2b33f6bc3623e97becd0135 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Fri, 25 Sep 2026 22:37:42 +0800 Subject: [PATCH] Send heartbeat for completed no-trade cycles Co-Authored-By: Codex --- application/rebalance_service.py | 5 +++-- tests/test_rebalance_service.py | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/application/rebalance_service.py b/application/rebalance_service.py index f104ce3..d6cf3d1 100644 --- a/application/rebalance_service.py +++ b/application/rebalance_service.py @@ -267,7 +267,8 @@ def _should_publish_cycle_notification(result: Mapping[str, Any]) -> bool: return True if result.get("error") or result.get("ok") is False: return True - return False + # A completed strategy run without an order is itself a useful heartbeat. + return result.get("ok") is True def load_strategy_plugin_signals( @@ -857,7 +858,7 @@ def acquire_submission_claim() -> bool: elif send_cycle_notification: result["notification_sent"] = False result["notification_suppressed"] = True - result.setdefault("notification_suppressed_reason", "no_trade_or_error") + result.setdefault("notification_suppressed_reason", "policy_or_incomplete_cycle") else: result["notification_sent"] = False result["notification_suppressed"] = True diff --git a/tests/test_rebalance_service.py b/tests/test_rebalance_service.py index 285cc6d..3a1cd35 100644 --- a/tests/test_rebalance_service.py +++ b/tests/test_rebalance_service.py @@ -585,10 +585,11 @@ def evaluate(self, **inputs): assert result["skipped_orders"] == [ {"symbol": "AAA", "reason": "below_trade_threshold", "delta_value": 0.0} ] - assert result["notification_sent"] is False - assert result["notification_suppressed"] is True - assert result["notification_suppressed_reason"] == "no_trade_or_error" - assert messages == [] + assert result["notification_sent"] is True + assert len(messages) == 1 + assert "Heartbeat" in messages[0] + assert "Total assets: $0.00" in messages[0] + assert "Available cash: $0.00" in messages[0] def test_run_strategy_cycle_loads_strategy_plugin_report_and_sends_email(