Open datamonke1 opened 5 months ago
I reproduce your code and it works for me. realtime got updated if keepUpTodate is set to True
from ib_async import *
ib = IB()
ib.connect('127.0.0.1',7496,1)
contract = Stock('IDIA', 'SMART','CHF')
bars=ib.reqHistoricalData(
contract,
endDateTime='',
durationStr='1 D',
barSizeSetting='1 min',
whatToShow='MIDPOINT',
useRTH=True,
formatDate=1,keepUpToDate=True)
for _ in range(100):
print(bars[-1])
ib.sleep(10)
output:
BarData(date=datetime.datetime(2024, 6, 27, 18, 16, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.055, high=2.055, low=2.055, close=2.055, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 16, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.055, high=2.055, low=2.055, close=2.055, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 16, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.055, high=2.069, low=2.055, close=2.069, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 16, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.055, high=2.069, low=2.055, close=2.069, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 16, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.055, high=2.069, low=2.055, close=2.069, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 17, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.069, high=2.069, low=2.069, close=2.069, volume=-1.0, average=-1.0, barCount=-1) BarData(date=datetime.datetime(2024, 6, 27, 18, 17, tzinfo=zoneinfo.ZoneInfo(key='Asia/Singapore')), open=2.069, high=2.069, low=2.069, close=2.069, volume=-1.0, average=-1.0, barCount=-1)
The time got updated on last bar
keepUpToDate does not work. I dont know if it has anything todo with ib.reqMarketDataType(3)