erdewit / ib_insync

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

Stream Live News #698

Open NimaMPH opened 9 months ago

NimaMPH commented 9 months ago

I am trying to start streaming live news but it seems that there is no genericTickList that provides it. I got f"mdoff,292:{provider_codes}" from IBKR API document but it does not work and the ticker does not have news data:

Get live news data for each symbol

for contract in settings.contracts_list: symbol = contract.symbol

# Request live news data for each contract
ticker_live_news = ib_obj.reqMktData(
                                   contract           = contract,
                                   genericTickList    = f"mdoff,292:{provider_codes}",
                                   snapshot           = False,
                                   regulatorySnapshot = False
                                   )

# Confirm live news data is streaming for the symbol
print(f"{symbol} Live News Data Streaming Started!")
print(ticker_live_news)

# Call on_live_news_data_update_func if there is new data
ticker_live_news.updateEvent += on_live_news_data_update_func