diff --git a/ib_insync/ib.py b/ib_insync/ib.py index dbe53cde..96012bca 100644 --- a/ib_insync/ib.py +++ b/ib_insync/ib.py @@ -1333,6 +1333,8 @@ def reqMktDepth( """ reqId = self.client.getReqId() ticker = self.wrapper.startTicker(reqId, contract, 'mktDepth') + ticker.domBids.clear() + ticker.domAsks.clear() self.client.reqMktDepth( reqId, contract, numRows, isSmartDepth, mktDepthOptions) return ticker @@ -1349,8 +1351,6 @@ def cancelMktDepth(self, contract: Contract, isSmartDepth=False): reqId = self.wrapper.endTicker(ticker, 'mktDepth') if ticker else 0 if ticker and reqId: self.client.cancelMktDepth(reqId, isSmartDepth) - ticker.domBids.clear() - ticker.domAsks.clear() else: self._logger.error( f'cancelMktDepth: No reqId found for contract {contract}')