有没有一种方法可以使用Interactive Brokers IBAPI库获取多只股票的实时OHLC数据?

问题描述

我正试图为多支股票获得OHLC。但是,我是IBAPI的新手,我找不到任何同时提取多个股票OHLC的示例。这是代码

class TestApp(EWrapper,EClient):
    def __init__(self):
        EClient.__init__(self,self)
    def error(self,reqId,errorCode,errorString):
        print("Error: "," ",errorString)
    
    def realtimeBar(self,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,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()

有人可以帮我解决我所缺少或没有得到的东西吗?预先感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)