1

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.

Liam
  • 1,287
  • 2
  • 9
  • 10
  • `ibapi.client.EClient(wrapper).connect("127.0.0.1",7497,999)`. –  Sep 28 '17 at 14:22
  • 1
    You'll have to create an instance of `EClient`. – Matthias Sep 28 '17 at 14:23
  • How can I just pass this as argument 'wrapper = self', do I need write another function that overwrite its __init__? – Liam Sep 28 '17 at 14:26
  • Possible duplicate of [TypeError: Missing 1 required positional argument: 'self'](https://stackoverflow.com/questions/17534345/typeerror-missing-1-required-positional-argument-self) – Jared Goguen Sep 28 '17 at 14:26

1 Answers1

2

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.

hspandher
  • 15,934
  • 2
  • 32
  • 45