erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 772 forks source link

reqMktData sends an empty ticker after a while #700

Open coolworld2049 opened 8 months ago

coolworld2049 commented 8 months ago
@cache(ttl=CACHING_TTL)
async def get_stock_contract(self, symbol: str) -> Contract | None:
    stk_contract = ib_insync.Stock()
    stk_contract.symbol = symbol
    stk_contract.exchange = "SMART"
    stk_contract.currency = "USD"
    stk_contract.primaryExchange = "NASDAQ"
    contracts = await self.qualifyContractsAsync(stk_contract)
    if len(contracts) < 1:
        return stk_contract
    return contracts[0]
...
contract = await self.get_stock_contract(symbol)
ticker = self.reqMktData(contract)
self.sleep(timeout)
...

logs: image