【发布时间】:2017-09-28 14:21:17
【问题描述】:
我有一个具有以下文档结构的包:
类 内置对象 电子客户端
class EClient(builtins.object)
| Methods defined here:
|
| __init__(self, wrapper)
| Initialize self. See help(type(self)) for accurate signature.
| connect(self, host, port, clientId)
| This function must be called before any other. There is no
| feedback for a successful connection, but a subsequent attempt to
| connect will return the message "Already connected."
|
| host:str - The host name or IP address of the machine where TWS is
| running. Leave blank to connect to the local host.
| port:int - Must match the port specified in TWS on the
| Configure>API>Socket Port field.
| clientId:int - A number used to identify this client connection. All
| orders placed/modified from this client will be associated with
| this client identifier.
|
| Note: Each client MUST connect with a unique clientId.
这里我想这样调用连接方法:
if __name__ == '__main__':
ibapi.client.EClient.connect("127.0.0.1",7497,999)
我不断收到此错误:
Traceback(最近一次调用最后一次): 文件“E:/Python/IB/IBTest/IBTutorial.py”,第 30 行,在 ibapi.client.EClient.connect("127.0.0.1",7497,999) 类型错误:connect() 缺少 1 个必需的位置参数:'clientId'
所以我隐约看出问题在于我没有传入的参数self,但我不知道如何让它正常工作。
【问题讨论】:
-
ibapi.client.EClient(wrapper).connect("127.0.0.1",7497,999). -
你必须创建一个
EClient的实例。 -
我怎样才能将它作为参数'wrapper = self' 传递,我是否需要编写另一个函数来覆盖它的 init?
标签: python