Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions application/rebalance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def log_message(message: str) -> None:
result = {
"ok": True,
"api_kind": "unofficial-reverse-engineered",
"account": masked_account,
"account": account,
"strategy_profile": strategy_runtime.profile,
"strategy_display_name": strategy_runtime.display_name,
"dry_run_only": settings.dry_run_only,
Expand Down Expand Up @@ -594,7 +594,7 @@ def log_message(message: str) -> None:
result = {
"ok": not execution_blocked,
"api_kind": "unofficial-reverse-engineered",
"account": mask_account_id(account),
"account": account,
"strategy_profile": strategy_runtime.profile,
"strategy_display_name": strategy_runtime.display_name,
"dry_run_only": settings.dry_run_only,
Expand Down
6 changes: 3 additions & 3 deletions application/session_check_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def persist_session_check_maintenance(
as_of = now or _utcnow()
payload = {
"checked_at": as_of.isoformat(),
"account": mask_account_id(account),
"account": account,
"session_reused": session_reused,
"strategy_profile": decision.strategy_profile,
"strategy_cadence": decision.strategy_cadence,
Expand Down Expand Up @@ -332,7 +332,7 @@ def build_account_funds_snapshot(
as_of = now or _utcnow()
snapshot: dict[str, Any] = {
"as_of": as_of.isoformat(),
"account": mask_account_id(account),
"account": account,
"session_reused": session_reused,
"account_summaries": account_summaries,
"balance_metrics": selected_numeric_metrics(balances, BALANCE_KEYWORDS),
Expand Down Expand Up @@ -445,7 +445,7 @@ def run_session_check(
result: dict[str, Any] = {
"ok": True,
"api_kind": "unofficial-reverse-engineered",
"account": mask_account_id(account),
"account": account,
"session_reused": session_reused,
"funds_snapshot": snapshot,
"snapshot_persisted": snapshot_persisted,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_decision_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ def test_value_decision_without_threshold_uses_platform_default():
strategy_profile="russell_top50_leader_rotation",
)

assert plan["execution"]["trade_threshold_value"] == 200.0
assert plan["execution"]["current_min_trade"] == 200.0
assert plan["execution"]["trade_threshold_value"] == 100.0
assert plan["execution"]["current_min_trade"] == 100.0
assert plan["allocation"]["targets"]["AAA"] == 500.0


Expand Down
2 changes: 1 addition & 1 deletion tests/test_execution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def test_execute_value_target_plan_projects_unbuyable_value_target_to_zero():
assert result.action_done is True
assert [(order.side, order.symbol, order.quantity) for order in execution_port.orders] == [
("sell", "SOXX", 1.0),
("buy", "SOXL", 1.0),
("buy", "SOXL", 2.0),
]


Expand Down
2 changes: 1 addition & 1 deletion tests/test_notifications_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_render_cycle_summary_dashboard_text_does_not_hide_account_overview():
)

assert " - Total assets: $2,345.67" in message
assert " - Buying power: $456.78" in message
assert " - Available cash: $456.78" in message
assert " - Reserved cash: $50.00" in message
assert " - Investable cash: $406.78" in message
assert " - SOXL: $1,000.00 / 5 shares" in message
Expand Down
3 changes: 2 additions & 1 deletion tests/test_rebalance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def test_runtime_metadata_uses_platform_execution_policy_over_strategy_metadata(
"firstrade_execution_policy": {
"reserved_cash_floor_usd": 250.0,
"reserved_cash_ratio": 0.03,
"cash_only_execution": True,
},
}

Expand Down Expand Up @@ -242,7 +243,7 @@ def fake_client_factory(*args, **kwargs):
assert result["notification_sent"] is True
assert "🔔 【Rebalance Instruction】" in messages[0]
assert "🧭 Strategy: TQQQ Growth Income" in messages[0]
assert "🆔 Account: ****5678" in messages[0]
assert "🆔 Account: 12345678" in messages[0]
assert "📌 Strategy Account" in messages[0]
assert "Target changes: AAA +50.00 USD" in messages[0]
assert "🧾 Execution details" in messages[0]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_runtime_broker_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ def get_balances(self, _account):

portfolio = adapters.build_portfolio_port().get_portfolio_snapshot()

assert portfolio.total_equity == 1234.56
assert portfolio.total_equity == 221.0
assert portfolio.cash_balance == 200.0
assert portfolio.metadata["total_equity_source"] == "balance_total"
assert portfolio.metadata["total_equity_source"] == "cash_plus_positions"


def test_managed_portfolio_snapshot_ignores_full_account_value_balance_key():
Expand Down
10 changes: 5 additions & 5 deletions tests/test_session_check_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _env(values):
return lambda name, default=None: values.get(name, default)


def test_build_account_funds_snapshot_masks_account_and_compacts_values():
def test_build_account_funds_snapshot_uses_full_account_and_compacts_values():
snapshot = build_account_funds_snapshot(
account="12345678",
account_summaries=[{"account": "****5678", "total_value": "100.00"}],
Expand All @@ -74,7 +74,7 @@ def test_build_account_funds_snapshot_masks_account_and_compacts_values():
now=datetime(2026, 5, 23, 1, 2, 3, tzinfo=timezone.utc),
)

assert snapshot["account"] == "****5678"
assert snapshot["account"] == "12345678"
assert snapshot["session_reused"] is True
assert snapshot["balance_metrics"] == {
"total_account_value": 100.0,
Expand Down Expand Up @@ -104,8 +104,8 @@ def test_run_session_check_persists_funds_snapshot_when_enabled():
assert result["session_reused"] is True
assert result["snapshot_persisted"] is True
assert len(store.writes) == 2
assert store.writes[0][0] == "accounts/____5678/funds/latest.json"
assert store.writes[1][0] == "accounts/____5678/funds/history/2026/05/23/20260523T010203Z.json"
assert store.writes[0][0] == "accounts/12345678/funds/latest.json"
assert store.writes[1][0] == "accounts/12345678/funds/history/2026/05/23/20260523T010203Z.json"
assert store.writes[0][1]["positions"][0]["symbol"] == "SPY"


Expand Down Expand Up @@ -162,7 +162,7 @@ def test_monthly_session_check_runs_and_persists_maintenance_state_when_due():
state_key,
{
"checked_at": "2026-06-03T01:02:03+00:00",
"account": "****5678",
"account": "12345678",
"session_reused": True,
"strategy_profile": "russell_top50_leader_rotation",
"strategy_cadence": "monthly",
Expand Down