Change ib.cancelMktData(tick_id)
to ib.cancelMktData(instr)
Based on ib_insync source code:
def cancelMktData(self, contract: Contract):
"""
Unsubscribe from realtime streaming tick data.
Args:
contract: The exact contract object that was used to
subscribe with.
"""
ticker = self.ticker(contract)
reqId = self.wrapper.endTicker(ticker, 'mktData') if ticker else 0
if reqId:
self.client.cancelMktData(reqId)
else:
self._logger.error(
'cancelMktData: ' f'No reqId found for contract {contract}')