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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
"account_selector": ["U15998061"],
"account_scope": "live-slot-b",
"service_name": "interactive-brokers-live-slot-b-service",
"deployment_selector": "live-u7654-mega",
"account_selector": ["U7654321"],
"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",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_connect_timeout_alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions tests/test_execution_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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,
Expand All @@ -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():
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ibkr_order_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion tests/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_rebalance_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
),
)
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_request_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
38 changes: 19 additions & 19 deletions tests/test_runtime_config_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand All @@ -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",
account_selector=["U15998061"],
account_scope="live-slot-b",
service_name="interactive-brokers-live-slot-b-service",
deployment_selector="live-u7654-mega",
account_selector=["U7654321"],
account_scope="live-u7654-mega",
service_name="interactive-brokers-live-u7654-mega-service",
)
),
"ibkr_feature_snapshot_path": "gs://runtime/mega/snapshot.csv",
Expand All @@ -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"
Expand All @@ -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"
)

Expand All @@ -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",
account_selector=["U15998061"],
account_scope="live-slot-b",
service_name="interactive-brokers-live-slot-b-service",
deployment_selector="live-u7654-mega",
account_selector=["U7654321"],
account_scope="live-u7654-mega",
service_name="interactive-brokers-live-u7654-mega-service",
)
),
}
Expand All @@ -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


Expand Down