0
我正在尝试使用reqHistoricalData
获取股票的历史数据。我想回顾1年,但是我的功能只打印本周的数据。如何使用`ibpy`从Interactive Broker获取历史股票数据?
conn.connect()
conn.reqCurrentTime()
oid=cid #cid = 105
contract = make_contract2(265598, 'STK', 'SMART', 'SMART', 'USD') #AAPL
endtime = strftime('%Y%m%d %H:%M:%S')
conn.reqHistoricalData(1,contract,endtime,"1 Y","1 day","TRADES",1,1)
time.sleep(5)
conn.cancelHistoricalData(1);
sleep(5)
print('disconnecting')
time.sleep(1) #Simply to give the program time to print messages sent from IB
conn.disconnect()
任何人都可以帮忙吗?