When I try to get Bar data of Stock tickers like("AMZN", "AAPL" etc.) not getting any output, but successfully able to retrieve data for Forex tickers like ("EURUSD", "AUDUSD" etc.). I looked for lots of sources to find a way, but couldn't come across any solution so far.
This is the code below
from ib_insync import *
util.startLoop()
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=14)
contract = Stock('IBM', 'SMART', 'USD')
# contract = Forex("EURUSD")
bars = ib.reqHistoricalData(
contract,
endDateTime='',
durationStr='1 D',
barSizeSetting='1 min',
whatToShow='MIDPOINT',
useRTH=True,
formatDate=1,
keepUpToDate=True)
def onBarUpdate(bars, hasNewBar):
print(bars[-1])
bars.updateEvent += onBarUpdate
ib.run()
if I change the contract with Forex then its giving the desired output.