Liam
Liam

Reputation: 1357

Argument required when calling function

I have a package which has the following documentation structure:

CLASSES builtins.object EClient

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.

Here I want to call the connection method like this:

if __name__ == '__main__':
ibapi.client.EClient.connect("127.0.0.1",7497,999)

and I keep getting this error:

Traceback (most recent call last): File "E:/Python/IB/IBTest/IBTutorial.py", line 30, in ibapi.client.EClient.connect("127.0.0.1",7497,999) TypeError: connect() missing 1 required positional argument: 'clientId'

So I vaguely see the problem lies in the argument self which I have not passed in, but I do not know how to get it work properly.

Upvotes: 1

Views: 198

Answers (1)

hspandher
hspandher

Reputation: 16733

You forgot to create the class instance.

ibapi.client.EClient(wrapper).connect("127.0.0.1",7497,999)

# assuming you have the wrapper object.

You're instead just calling an unbound method on the class itself, without providing all of its arguments.

Upvotes: 2

Related Questions