20 lines
364 B
Python
20 lines
364 B
Python
from ib_async import IB, Stock
|
|
|
|
ib = IB()
|
|
ib.connect('127.0.0.1', port=4002, clientId=1)
|
|
|
|
aapl = Stock('AAPL', 'SMART', 'USD')
|
|
ib.qualifyContracts(aapl)
|
|
|
|
bars = ib.reqHistoricalData(
|
|
aapl,
|
|
endDateTime='',
|
|
durationStr='1 D',
|
|
barSizeSetting='1 day',
|
|
whatToShow='TRADES',
|
|
useRTH=True,
|
|
)
|
|
print(f'AAPL close: {bars[-1].close}')
|
|
|
|
ib.disconnect()
|