From 4a547ac7d1c1fde6f54590f49c677f2d377aa110 Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 27 May 2026 01:30:25 +0800 Subject: [PATCH 1/2] Redact live account ids in examples --- README.md | 4 ++-- tests/conftest.py | 2 +- tests/test_connect_timeout_alert.py | 2 +- tests/test_execution_service.py | 12 ++++++------ tests/test_ibkr_order_execution.py | 6 +++--- tests/test_notifications.py | 2 +- tests/test_rebalance_service.py | 4 ++-- tests/test_request_handling.py | 2 +- tests/test_runtime_config_support.py | 6 +++--- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 9ea5c54..ff1d76f 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ For slot deployments, use `CLOUD_RUN_SERVICE_TARGETS_JSON` instead of a shared ` "strategy_profile": "tqqq_growth_income", "dry_run_only": false, "deployment_selector": "live-slot-a", - "account_selector": ["U18308207"], + "account_selector": ["U1234567"], "account_scope": "live-slot-a", "service_name": "interactive-brokers-live-slot-a-service", "execution_mode": "live" @@ -311,7 +311,7 @@ For slot deployments, use `CLOUD_RUN_SERVICE_TARGETS_JSON` instead of a shared ` "strategy_profile": "mega_cap_leader_rotation_top50_balanced", "dry_run_only": false, "deployment_selector": "live-slot-b", - "account_selector": ["U15998061"], + "account_selector": ["U7654321"], "account_scope": "live-slot-b", "service_name": "interactive-brokers-live-slot-b-service", "execution_mode": "live" diff --git a/tests/conftest.py b/tests/conftest.py index 87ce62c..74f73ef 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -26,7 +26,7 @@ def load_strategy_module(**env_overrides): "IBKR_RECONCILIATION_OUTPUT_PATH": None, "IB_ACCOUNT_GROUP_CONFIG_JSON": ( '{"groups":{"default":{"ib_gateway_instance_name":"127.0.0.1",' - '"ib_gateway_mode":"live","ib_client_id":1,"account_ids":["U18308207"]}}}' + '"ib_gateway_mode":"live","ib_client_id":1,"account_ids":["U1234567"]}}}' ), "IB_ACCOUNT_GROUP_CONFIG_SECRET_NAME": None, "GLOBAL_TELEGRAM_CHAT_ID": None, diff --git a/tests/test_connect_timeout_alert.py b/tests/test_connect_timeout_alert.py index cda9803..38aa693 100644 --- a/tests/test_connect_timeout_alert.py +++ b/tests/test_connect_timeout_alert.py @@ -105,7 +105,7 @@ def run(self, *args, **kwargs): strategy_display_name="TQQQ Growth Income", strategy_domain="us_equity", account_group="default", - account_ids=("U18308207",), + account_ids=("U1234567",), service_name="interactive-brokers-platform", ib_gateway_instance_name="127.0.0.1", ib_gateway_zone=None, diff --git a/tests/test_execution_service.py b/tests/test_execution_service.py index 5e59aad..7adfd76 100644 --- a/tests/test_execution_service.py +++ b/tests/test_execution_service.py @@ -233,8 +233,8 @@ def fills(self): def accountValues(self): return [ - SimpleNamespace(account="U18308207", tag="AvailableFunds", currency="USD", value="5000"), - SimpleNamespace(account="U15998061", tag="AvailableFunds", currency="USD", value="100"), + SimpleNamespace(account="U1234567", tag="AvailableFunds", currency="USD", value="5000"), + SimpleNamespace(account="U7654321", tag="AvailableFunds", currency="USD", value="100"), ] submitted = [] @@ -260,7 +260,7 @@ def fake_submit_order_intent(_ib, intent): strategy_profile="tqqq_growth_income", account_group="live-tqqq", service_name="ibkr-tqqq-live", - account_ids=("U18308207",), + account_ids=("U1234567",), signal_metadata=_signal_metadata({"TQQQ": 1.0}, risk_symbols=("TQQQ",), trade_date="2026-04-01"), dry_run_only=False, cash_reserve_ratio=0.0, @@ -272,8 +272,8 @@ def fake_submit_order_intent(_ib, intent): ) assert len(submitted) == 1 - assert submitted[0].account_id == "U18308207" - assert summary["order_account_id"] == "U18308207" + assert submitted[0].account_id == "U1234567" + assert summary["order_account_id"] == "U1234567" def test_execute_rebalance_rejects_multiple_order_account_ids(): @@ -293,7 +293,7 @@ def accountValues(self): translator=translate, strategy_symbols=["TQQQ"], signal_metadata=_signal_metadata({"TQQQ": 1.0}, risk_symbols=("TQQQ",)), - account_ids=("U18308207", "U15998061"), + account_ids=("U1234567", "U7654321"), dry_run_only=False, cash_reserve_ratio=0.0, rebalance_threshold_ratio=0.02, diff --git a/tests/test_ibkr_order_execution.py b/tests/test_ibkr_order_execution.py index d57f7ca..6091568 100644 --- a/tests/test_ibkr_order_execution.py +++ b/tests/test_ibkr_order_execution.py @@ -66,11 +66,11 @@ def test_submit_order_intent_preserves_account_id(): report = submit_order_intent( ib, - OrderIntent(symbol="AAPL", side="buy", quantity=3, account_id="U18308207"), + OrderIntent(symbol="AAPL", side="buy", quantity=3, account_id="U1234567"), wait_seconds=0, stock_factory=fake_stock, market_order_factory=FakeMarketOrder, ) - assert ib.placed_order.account == "U18308207" - assert report.raw_payload["account_id"] == "U18308207" + assert ib.placed_order.account == "U1234567" + assert report.raw_payload["account_id"] == "U1234567" diff --git a/tests/test_notifications.py b/tests/test_notifications.py index 746e80f..88c3a2c 100644 --- a/tests/test_notifications.py +++ b/tests/test_notifications.py @@ -60,7 +60,7 @@ def test_build_translator_supports_chinese(): assert translate("strategy_plugin_alert_scope_note", scope_note="不会自动下单") == "执行范围:不会自动下单" assert "降低杠杆" in translate("strategy_plugin_guidance_crisis_response_shadow_true_crisis_defend") assert "小仓位" in translate("strategy_plugin_guidance_taco_rebound_shadow_taco_rebound_notify_manual_review") - assert translate("account_ids_detail", account_ids="U18308207") == "🆔 账户: U18308207" + assert translate("account_ids_detail", account_ids="U1234567") == "🆔 账户: U1234567" assert ( translate( "small_account_warning_note", diff --git a/tests/test_rebalance_service.py b/tests/test_rebalance_service.py index 3a27c9c..f152e5e 100644 --- a/tests/test_rebalance_service.py +++ b/tests/test_rebalance_service.py @@ -391,7 +391,7 @@ def test_trade_notification_keeps_detailed_logs_out_of_compact_message(): separator="---", strategy_display_name="TQQQ Growth Income", extra_notification_lines=( - "🆔 Account: U18308207", + "🆔 Account: U1234567", "🧩 Plugin: Crisis Watch Notice | status: no crisis detected | notice: no action", ), ) @@ -401,7 +401,7 @@ def test_trade_notification_keeps_detailed_logs_out_of_compact_message(): assert "📌 Strategy portfolio" in notification.compact_text assert "⏱ Timing: 2026-04-01 -> 2026-04-02 (next trading day)" in notification.compact_text assert "no_order_plan_reason reason=min_notional:QQQ,TQQQ" in notification.compact_text - assert notification.compact_text.index("🆔 Account: U18308207") < notification.compact_text.index("🧩 Plugin:") + assert notification.compact_text.index("🆔 Account: U1234567") < notification.compact_text.index("🧩 Plugin:") def test_run_strategy_core_writes_reconciliation_record_under_strategy_dir(tmp_path): diff --git a/tests/test_request_handling.py b/tests/test_request_handling.py index 2c52cf5..c90ceab 100644 --- a/tests/test_request_handling.py +++ b/tests/test_request_handling.py @@ -230,7 +230,7 @@ def test_handle_probe_failure_sends_notification(strategy_module, monkeypatch): def test_build_extra_notification_lines_includes_account_id(strategy_module): lines = strategy_module.build_extra_notification_lines(("plugin-line",)) - assert any("U18308207" in line for line in lines) + assert any("U1234567" in line for line in lines) assert all("plugin-line" not in line for line in lines) diff --git a/tests/test_runtime_config_support.py b/tests/test_runtime_config_support.py index 1115a19..0564332 100644 --- a/tests/test_runtime_config_support.py +++ b/tests/test_runtime_config_support.py @@ -699,7 +699,7 @@ def test_build_cloud_run_env_sync_plan_supports_per_service_targets(): runtime_target_json( "tqqq_growth_income", deployment_selector="live-slot-a", - account_selector=["U18308207"], + account_selector=["U1234567"], account_scope="live-slot-a", service_name="interactive-brokers-live-slot-a-service", ) @@ -723,7 +723,7 @@ def test_build_cloud_run_env_sync_plan_supports_per_service_targets(): runtime_target_json( "mega_cap_leader_rotation_top50_balanced", deployment_selector="live-slot-b", - account_selector=["U15998061"], + account_selector=["U7654321"], account_scope="live-slot-b", service_name="interactive-brokers-live-slot-b-service", ) @@ -786,7 +786,7 @@ def test_build_cloud_run_env_sync_plan_requires_target_snapshot_in_per_service_m runtime_target_json( "mega_cap_leader_rotation_top50_balanced", deployment_selector="live-slot-b", - account_selector=["U15998061"], + account_selector=["U7654321"], account_scope="live-slot-b", service_name="interactive-brokers-live-slot-b-service", ) From a649495a3033a284892409277c21e57267362c8b Mon Sep 17 00:00:00 2001 From: Pigbibi <20649888+Pigbibi@users.noreply.github.com> Date: Wed, 27 May 2026 01:51:17 +0800 Subject: [PATCH 2/2] Use account-style names in live examples --- README.md | 10 ++++----- tests/test_runtime_config_support.py | 32 ++++++++++++++-------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ff1d76f..820b534 100644 --- a/README.md +++ b/README.md @@ -304,16 +304,16 @@ For slot deployments, use `CLOUD_RUN_SERVICE_TARGETS_JSON` instead of a shared ` } }, { - "service": "interactive-brokers-live-slot-b-service", - "account_group": "live-slot-b", + "service": "interactive-brokers-live-u7654-mega-service", + "account_group": "live-u7654-mega", "runtime_target": { "platform_id": "ibkr", "strategy_profile": "mega_cap_leader_rotation_top50_balanced", "dry_run_only": false, - "deployment_selector": "live-slot-b", + "deployment_selector": "live-u7654-mega", "account_selector": ["U7654321"], - "account_scope": "live-slot-b", - "service_name": "interactive-brokers-live-slot-b-service", + "account_scope": "live-u7654-mega", + "service_name": "interactive-brokers-live-u7654-mega-service", "execution_mode": "live" }, "ibkr_feature_snapshot_path": "gs://qsl-runtime-logs-interactivebrokersquant/strategy-artifacts/us_equity/mega_cap_leader_rotation_top50_balanced_staging/mega_cap_leader_rotation_top50_balanced_feature_snapshot_latest.csv", diff --git a/tests/test_runtime_config_support.py b/tests/test_runtime_config_support.py index 0564332..9c6a02c 100644 --- a/tests/test_runtime_config_support.py +++ b/tests/test_runtime_config_support.py @@ -717,15 +717,15 @@ def test_build_cloud_run_env_sync_plan_supports_per_service_targets(): }, }, { - "service": "interactive-brokers-live-slot-b-service", - "account_group": "live-slot-b", + "service": "interactive-brokers-live-u7654-mega-service", + "account_group": "live-u7654-mega", "runtime_target": json.loads( runtime_target_json( "mega_cap_leader_rotation_top50_balanced", - deployment_selector="live-slot-b", + deployment_selector="live-u7654-mega", account_selector=["U7654321"], - account_scope="live-slot-b", - service_name="interactive-brokers-live-slot-b-service", + account_scope="live-u7654-mega", + service_name="interactive-brokers-live-u7654-mega-service", ) ), "ibkr_feature_snapshot_path": "gs://runtime/mega/snapshot.csv", @@ -751,7 +751,7 @@ def test_build_cloud_run_env_sync_plan_supports_per_service_targets(): assert plan["mode"] == "per_service" by_service = {target["service_name"]: target for target in plan["targets"]} slot_a = by_service["interactive-brokers-live-slot-a-service"] - slot_b = by_service["interactive-brokers-live-slot-b-service"] + u7654_mega = by_service["interactive-brokers-live-u7654-mega-service"] assert slot_a["env"]["ACCOUNT_GROUP"] == "live-slot-a" assert slot_a["env"]["STRATEGY_PROFILE"] == "tqqq_growth_income" @@ -762,11 +762,11 @@ def test_build_cloud_run_env_sync_plan_supports_per_service_targets(): "strategy" ] == "tqqq_growth_income" - assert slot_b["env"]["ACCOUNT_GROUP"] == "live-slot-b" - assert slot_b["env"]["STRATEGY_PROFILE"] == "mega_cap_leader_rotation_top50_balanced" - assert slot_b["env"]["IBKR_FEATURE_SNAPSHOT_PATH"] == "gs://runtime/mega/snapshot.csv" + assert u7654_mega["env"]["ACCOUNT_GROUP"] == "live-u7654-mega" + assert u7654_mega["env"]["STRATEGY_PROFILE"] == "mega_cap_leader_rotation_top50_balanced" + assert u7654_mega["env"]["IBKR_FEATURE_SNAPSHOT_PATH"] == "gs://runtime/mega/snapshot.csv" assert ( - slot_b["env"]["IBKR_FEATURE_SNAPSHOT_MANIFEST_PATH"] + u7654_mega["env"]["IBKR_FEATURE_SNAPSHOT_MANIFEST_PATH"] == "gs://runtime/mega/snapshot.csv.manifest.json" ) @@ -780,15 +780,15 @@ def test_build_cloud_run_env_sync_plan_requires_target_snapshot_in_per_service_m }, "targets": [ { - "service": "interactive-brokers-live-slot-b-service", - "account_group": "live-slot-b", + "service": "interactive-brokers-live-u7654-mega-service", + "account_group": "live-u7654-mega", "runtime_target": json.loads( runtime_target_json( "mega_cap_leader_rotation_top50_balanced", - deployment_selector="live-slot-b", + deployment_selector="live-u7654-mega", account_selector=["U7654321"], - account_scope="live-slot-b", - service_name="interactive-brokers-live-slot-b-service", + account_scope="live-u7654-mega", + service_name="interactive-brokers-live-u7654-mega-service", ) ), } @@ -808,7 +808,7 @@ def test_build_cloud_run_env_sync_plan_requires_target_snapshot_in_per_service_m ) assert result.returncode != 0 - assert "interactive-brokers-live-slot-b-service:IBKR_FEATURE_SNAPSHOT_PATH" in result.stderr + assert "interactive-brokers-live-u7654-mega-service:IBKR_FEATURE_SNAPSHOT_PATH" in result.stderr assert "gs://stale-paper/snapshot.csv" not in result.stderr