You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
I was wondering how I could request historical news on each bar updates. Here is my code:
def on_historical_data_update_async(_bars, _has_new_bar, _contract, _timeframe):
symbol = _contract.symbol
if _has_new_bar:
try:
# Assuming there's an async equivalent or workaround
historical_news = ib_obj.reqHistoricalNews(
conId=_contract.conId,
providerCodes=provider_codes,
startDateTime='',
endDateTime='',
totalResults=10
)
if historical_news and len(historical_news) > 0:
print(historical_news[0].headline)
else:
print(f"No historical news found for {symbol}.")
except Exception as e:
print(f"Error fetching historical news for {symbol}: {e}")
I was wondering how I could request historical news on each bar updates. Here is my code:
def on_historical_data_update_async(_bars, _has_new_bar, _contract, _timeframe):
symbol = _contract.symbol
if _has_new_bar:
try:
# Assuming there's an async equivalent or workaround
historical_news = ib_obj.reqHistoricalNews(
conId=_contract.conId,
providerCodes=provider_codes,
startDateTime='',
endDateTime='',
totalResults=10
)
Request bars data----------------------------------------------------------------------------------------------------------------------
Call on_historical_data_update_func if there is new bar--------------------------------------------------------------------------------
But I receive an error related to asynchronous run.
The text was updated successfully, but these errors were encountered: