@@ -317,7 +317,8 @@ def build_strategy_adapters():
317317 )
318318
319319
320- def build_broker_adapters ():
320+ def build_broker_adapters (* , dry_run_only_override : bool | None = None ):
321+ effective_dry_run_only = RUNTIME_SETTINGS .dry_run_only if dry_run_only_override is None else bool (dry_run_only_override )
321322 return build_runtime_broker_adapters (
322323 host_resolver = get_ib_host ,
323324 ib_port = IB_PORT ,
@@ -340,7 +341,7 @@ def build_broker_adapters():
340341 account_group = ACCOUNT_GROUP ,
341342 service_name = SERVICE_NAME ,
342343 account_ids = tuple (ACCOUNT_IDS ),
343- dry_run_only = RUNTIME_SETTINGS . dry_run_only ,
344+ dry_run_only = effective_dry_run_only ,
344345 cash_reserve_ratio = CASH_RESERVE_RATIO ,
345346 cash_reserve_floor_usd = CASH_RESERVE_FLOOR_USD ,
346347 rebalance_threshold_ratio = REBALANCE_THRESHOLD_RATIO ,
@@ -393,7 +394,14 @@ def build_composer(*, dry_run_only_override: bool | None = None):
393394 connect_ib_fn = connect_ib ,
394395 build_portfolio_snapshot_fn = build_portfolio_snapshot ,
395396 compute_signals_fn = compute_signals ,
396- execute_rebalance_fn = execute_rebalance ,
397+ execute_rebalance_fn = lambda ib , target_weights , positions , account_values , ** kwargs : execute_rebalance (
398+ ib ,
399+ target_weights ,
400+ positions ,
401+ account_values ,
402+ dry_run_only_override = effective_dry_run_only ,
403+ ** kwargs ,
404+ ),
397405 run_id_builder = build_run_id ,
398406 event_logger = emit_runtime_log ,
399407 report_builder = build_runtime_report_base ,
@@ -575,8 +583,9 @@ def execute_rebalance(
575583 * ,
576584 strategy_symbols = None ,
577585 signal_metadata = None ,
586+ dry_run_only_override : bool | None = None ,
578587):
579- return build_broker_adapters ().execute_rebalance (
588+ return build_broker_adapters (dry_run_only_override = dry_run_only_override ).execute_rebalance (
580589 ib ,
581590 target_weights ,
582591 positions ,
0 commit comments