Closed benjaminsingleton closed 2 months ago
@benjaminsingleton
Because factory name is now overriding hence special treatment of Portfolio might not be working. Do you still experience if you make any of the following changes?
a) Set node.portfolio.set_specific_venue(Venue("IB"))
(because factory name according to your logs is 'IB')
b) Set factory name to INTERACTIVE_BROKERS
which is the value of IB_VENUE
This got my code working again:
b) Set factory name to INTERACTIVE_BROKERS which is the value of IB_VENUE
But this didn't:
a) Set node.portfolio.set_specific_venue(Venue("IB")) (because factory name according to your logs is 'IB')
2024-04-26T02:19:25.220031001Z [INFO] TESTER-001.ExecEngine: Reconciling ExecutionMassStatus for INTERACTIVE_BROKERS
2024-04-26T02:19:25.220034001Z [INFO] TESTER-001.ExecEngine: Reconciling order for ClientOrderId('AAPL.NASDAQ')
2024-04-26T02:19:25.220035001Z [INFO] TESTER-001.ExecEngine: Generating order ClientOrderId('AAPL.NASDAQ')
2024-04-26T02:19:25.220506001Z [DEBUG] TESTER-001.ExecEngine: Generated OrderInitialized(instrument_id=AAPL.NASDAQ, client_order_id=AAPL.NASDAQ, side=BUY, type=MARKET, quantity=1_200, time_in_force=GTC, post_only=False, reduce_only=False, quote_quantity=False, options={'expire_time_ns': 0}, emulation_trigger=NO_TRIGGER, trigger_instrument_id=None, contingency_type=NO_CONTINGENCY, order_list_id=None, linked_order_ids=None, parent_order_id=None, exec_algorithm_id=None, exec_algorithm_params=None, exec_spawn_id=None, tags=EXTERNAL)
2024-04-26T02:19:25.220644001Z [DEBUG] TESTER-001.Cache: Added MarketOrder(BUY 1_200 AAPL.NASDAQ MARKET GTC, status=INITIALIZED, client_order_id=AAPL.NASDAQ, venue_order_id=None, position_id=None, tags=EXTERNAL)
2024-04-26T02:19:25.220939001Z [DEBUG] TESTER-001.ExecEngine: Generated OrderAccepted(instrument_id=AAPL.NASDAQ, client_order_id=AAPL.NASDAQ, venue_order_id=AAPL.NASDAQ, account_id=IB-DU1234567, ts_event=1714097965209516001)
2024-04-26T02:19:25.221667001Z [ERROR] TESTER-001.Portfolio: Cannot update order: no account registered for IB-DU1234567
2024-04-26T02:19:25.222006001Z [WARN] TESTER-001.ExecEngine: Generated inferred OrderFilled(instrument_id=AAPL.NASDAQ, client_order_id=AAPL.NASDAQ, venue_order_id=AAPL.NASDAQ, account_id=IB-DU1234567, trade_id=0edb8a82-65f9-4db6-b900-9428c46b5fb3, position_id=AAPL.NASDAQ-EXTERNAL, order_side=BUY, order_type=MARKET, last_qty=1200, last_px=185.17 USD, commission=0.00 USD, liquidity_side=TAKER, ts_event=1714097965209516001)
2024-04-26T02:19:25.222023001Z [ERROR] TESTER-001.Portfolio: Cannot update order: no account registered for IB-DU1234567
2024-04-26T02:19:25.222044001Z [ERROR] TESTER-001.ExecEngine: Cannot handle order fill: no account found for NASDAQ, OrderFilled(instrument_id=AAPL.NASDAQ, client_order_id=AAPL.NASDAQ, venue_order_id=AAPL.NASDAQ, account_id=IB-DU1234567, trade_id=0edb8a82-65f9-4db6-b900-9428c46b5fb3, position_id=AAPL.NASDAQ-EXTERNAL, order_side=BUY, order_type=MARKET, last_qty=1200, last_px=185.17 USD, commission=0.00 USD, liquidity_side=TAKER, ts_event=1714097965209516001)
2024-04-26T02:19:25.222053001Z [INFO] TESTER-001.ExecEngine: Reconciling order for ClientOrderId('BTC/USD.PAXOS')
2024-04-26T02:19:25.222057001Z [INFO] TESTER-001.ExecEngine: Generating order ClientOrderId('BTC/USD.PAXOS')
2024-04-26T02:19:25.222086001Z [DEBUG] TESTER-001.ExecEngine: Generated OrderInitialized(instrument_id=BTC/USD.PAXOS, client_order_id=BTC/USD.PAXOS, side=BUY, type=MARKET, quantity=0.05159349, time_in_force=GTC, post_only=False, reduce_only=False, quote_quantity=False, options={'expire_time_ns': 0}, emulation_trigger=NO_TRIGGER, trigger_instrument_id=None, contingency_type=NO_CONTINGENCY, order_list_id=None, linked_order_ids=None, parent_order_id=None, exec_algorithm_id=None, exec_algorithm_params=None, exec_spawn_id=None, tags=EXTERNAL)
2024-04-26T02:19:25.222090001Z [DEBUG] TESTER-001.Cache: Added MarketOrder(BUY 0.05159349 BTC/USD.PAXOS MARKET GTC, status=INITIALIZED, client_order_id=BTC/USD.PAXOS, venue_order_id=None, position_id=None, tags=EXTERNAL)
2024-04-26T02:19:25.222104001Z [DEBUG] TESTER-001.ExecEngine: Generated OrderAccepted(instrument_id=BTC/USD.PAXOS, client_order_id=BTC/USD.PAXOS, venue_order_id=BTC/USD.PAXOS, account_id=IB-DU1234567, ts_event=1714097965209516001)
2024-04-26T02:19:25.222107001Z [ERROR] TESTER-001.Portfolio: Cannot update order: no account registered for IB-DU1234567
2024-04-26T02:19:25.222133001Z [WARN] TESTER-001.ExecEngine: Generated inferred OrderFilled(instrument_id=BTC/USD.PAXOS, client_order_id=BTC/USD.PAXOS, venue_order_id=BTC/USD.PAXOS, account_id=IB-DU1234567, trade_id=419e00e0-5dfa-4559-9724-6e35e22d325f, position_id=BTC/USD.PAXOS-EXTERNAL, order_side=BUY, order_type=MARKET, last_qty=0.05159349, last_px=42908.56 USD, commission=0.00 USD, liquidity_side=TAKER, ts_event=1714097965209516001)
2024-04-26T02:19:25.222140001Z [ERROR] TESTER-001.Portfolio: Cannot update order: no account registered for IB-DU1234567
@cjdsellers
It is because the name doesn't match here after 'Implement custom client IDs'. Because the name can be customized now and dynamically setting may not work in other cases as well (at the moment) i.e if user tries run more than one-adapters, it may be less confusing if we require the user to explicity set_specific_venue
as specified in example.
Yes, good catch @rsmb7z and we parse the custom name
here.
Then I think we shouldn't rely on this hard coded string (I note the "temporary" comment there too), but should check if factory
is an instance of either InteractiveBrokersDataExecClientFactory
or InteractiveBrokersLiveExecClientFactory
?
But then following onto L268 we set a specific venue of Venue("InteractiveBrokers")
. Will this still work with multiple Interactive Brokers clients?
But then following onto L268 we set a specific venue of
Venue("InteractiveBrokers")
. Will this still work with multiple Interactive Brokers clients?
The problem I believe is we only have one Portfolio, while it may not raise any errors, multiple ExecCients would be sending their own balance updates and calculations maynot be as expected within Portfolio. Some more info is tracked in #1051.
we parse the custom
name
here.Then I think we shouldn't rely on this hard coded string (I note the "temporary" comment there too), but should check if
factory
is an instance of eitherInteractiveBrokersDataExecClientFactory
orInteractiveBrokersLiveExecClientFactory
?
Both of the L202 and L268 would be removed and for ExecClient dynamic addition can be done when the Factory is IB, if you prefer that way.
In node_builder.py
, should we check if name == 'INTERACTIVE_BROKERS'
instead of InteractiveBrokers
so it matches IB_VENUE
here?
I have pushed the fix in #1616.
Thank you!
Bug Report
It looks like a bug was introduced in 1.191 that is not present in 1.190. I'm not sure yet if this is specific to the Interactive Brokers adapter or whether it is related to other changes.
Expected Behavior
Able to reconcile existing positions in Interactive Brokers.
Actual Behavior
Here are some more comprehensive log differences for the same strategy in 1.190 vs 1.191:
1.190
1.191
1.190
1.191
Steps to Reproduce the Problem
Specifications
nautilus_trader
version: 1.191