我正在尝试为多只股票获取 OHLC。但是,我是 IBAPI 的新手,我找不到任何同时获取多个股票 OHLC 的示例。这是代码:
class TestApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId, errorCode, errorString):
print("Error: ", reqId, " ", errorCode, " ", errorString)
def realtimeBar(self, reqId, time:int, open_: float, high: float, low: float, close: float,volume: int, wap: float, count: int):
super().realtimeBar(reqId, time, open_, high, low, close, volume, wap, count)
print(RealTimeBar(time, -1, open_, high, low, close, volume, wap, count))
app = TestApp()
app.connect("127.0.0.1", 7499, 0)
contract = Contract()
contract.secType = "STK"
contract.symbol = "XYZ"
contract.currency = "XYZ"
contract.exchange = "XYZ"
app.reqRealTimeBars(1,contract,1,'TRADES',False,[])
app.run()
任何人都可以帮我解决我缺少或没有得到的东西吗?提前致谢。