@@ -197,6 +197,7 @@ def __init__(
197197 self ._margin_mode = config .margin_mode
198198 self ._position_mode = config .position_mode
199199 self ._use_spot_position_reports = config .use_spot_position_reports
200+ self ._ignore_uncached_instrument_executions = config .ignore_uncached_instrument_executions
200201
201202 self ._log .info (f"Account type: { account_type_to_str (account_type )} " , LogColor .BLUE )
202203 self ._log .info (f"Product types: { [p .value for p in product_types ]} " , LogColor .BLUE )
@@ -205,6 +206,7 @@ def __init__(
205206 self ._log .info (f"{ config .use_ws_trade_api = } " , LogColor .BLUE )
206207 self ._log .info (f"{ config .use_http_batch_api = } " , LogColor .BLUE )
207208 self ._log .info (f"{ config .use_spot_position_reports = } " , LogColor .BLUE )
209+ self ._log .info (f"{ config .ignore_uncached_instrument_executions = } " , LogColor .BLUE )
208210 self ._log .info (f"{ config .max_retries = } " , LogColor .BLUE )
209211 self ._log .info (f"{ config .retry_delay_initial_ms = } " , LogColor .BLUE )
210212 self ._log .info (f"{ config .retry_delay_max_ms = } " , LogColor .BLUE )
@@ -1429,6 +1431,7 @@ def _handle_ws_message_private(self, raw: bytes) -> None:
14291431 def _handle_account_execution_update (self , raw : bytes ) -> None :
14301432 try :
14311433 msg = self ._decoder_ws_account_execution_update .decode (raw )
1434+
14321435 for trade in msg .data :
14331436 self ._process_execution (trade )
14341437 except Exception as e :
@@ -1437,12 +1440,13 @@ def _handle_account_execution_update(self, raw: bytes) -> None:
14371440 def _handle_account_execution_fast_update (self , raw : bytes ) -> None :
14381441 try :
14391442 msg = self ._decoder_ws_account_execution_fast_update .decode (raw )
1443+
14401444 for trade in msg .data :
14411445 self ._process_execution (trade )
14421446 except Exception as e :
14431447 self ._log .exception (f"Failed to handle account execution update: { e } " , e )
14441448
1445- def _process_execution (
1449+ def _process_execution ( # noqa: C901 (too complex)
14461450 self ,
14471451 execution : BybitWsAccountExecution | BybitWsAccountExecutionFast ,
14481452 ) -> None :
@@ -1489,6 +1493,9 @@ def _process_execution(
14891493
14901494 instrument = self ._cache .instrument (instrument_id )
14911495 if instrument is None :
1496+ if self ._ignore_uncached_instrument_executions :
1497+ return
1498+
14921499 raise ValueError (
14931500 f"Cannot handle trade event: instrument { instrument_id } not found" ,
14941501 )
0 commit comments