@@ -20,7 +20,7 @@ def worker():
2020 assert not loop .is_closed ()
2121
2222
23- def test_connect_ib_prepares_event_loop_before_connect (strategy_module , monkeypatch ):
23+ def test_connect_ib_prepares_readonly_event_loop_before_dry_run_connect (strategy_module , monkeypatch ):
2424 observed = {}
2525
2626 def fake_ibkr_connect (host , port , client_id , ** kwargs ):
@@ -32,7 +32,23 @@ def fake_ibkr_connect(host, port, client_id, **kwargs):
3232 with ThreadPoolExecutor (max_workers = 1 ) as executor :
3333 executor .submit (strategy_module .connect_ib ).result ()
3434
35- assert observed ["args" ] == ("127.0.0.1" , 4001 , 1 , {"timeout" : 60 })
35+ assert observed ["args" ] == ("127.0.0.1" , 4001 , 1 , {"timeout" : 60 , "readonly" : True })
36+
37+
38+ def test_live_runtime_adapter_keeps_writable_gateway_session (strategy_module_factory , monkeypatch ):
39+ module = strategy_module_factory (IBKR_DRY_RUN_ONLY = "false" )
40+ observed = {}
41+
42+ def fake_ibkr_connect (host , port , client_id , ** kwargs ):
43+ observed ["args" ] = (host , port , client_id , kwargs )
44+ return object ()
45+
46+ monkeypatch .setattr (module , "ibkr_connect_ib" , fake_ibkr_connect )
47+
48+ adapters = module .build_broker_adapters ()
49+ adapters .connect_ib_fn ("127.0.0.1" , 4001 , 1 , timeout = 60 )
50+
51+ assert observed ["args" ] == ("127.0.0.1" , 4001 , 1 , {"timeout" : 60 , "readonly" : False })
3652
3753
3854def test_connect_ib_retries_with_offset_client_ids (strategy_module_factory , monkeypatch ):
0 commit comments