4

If I run a basic TWS example, I receive the error message . If I comment out the error() call back it runs fine. I've tried this on several examples and get the same result.

    Exception has occurred: TypeError
    
    error() takes 4 positional arguments but 5 were given
    
    File "/Users/jayurbain/Dropbox/twsapi/Algorithmic Trading using Interactive Broker's 
    Python API /ib_basic_app.py", line 20, in <module> app.run()

Please advise.

Thanks,

Jay

Here's the call back that is being overridden in wrapper.py:

    def error(self, reqId:TickerId, errorCode:int, errorString:str, advancedOrderRejectJson = ""):

Here is the entire code:

from ibapi.client import EClient
from ibapi.wrapper import EWrapper
 
class TradingApp(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self,self)
        
    def error(self, reqId, errorCode, errorString):
        print("Error {} {} {}".format(reqId,errorCode,errorString))
 
app = TradingApp()      
app.connect("127.0.0.1", 7497, clientId=1)
app.run()
jayurbain
  • 429
  • 1
  • 5
  • 11
  • The code as you have presented it does not reproduce the error (when I run it on my machine), so you may need to dig deeper to find the underlying cause. Have you debugged to look at what variables are correctly/incorrectly being passed to the error function? What version of ibapi are you using? – DavidWalker Nov 18 '22 at 23:42

2 Answers2

4

There are breaking API changes in versions starting 10.14. Since there is another argument for the error callback, you need to include it in args.

def error(self, reqId, errorCode, errorString, advancedOrderRejectJson):
    print("Error {} {} {}".format(reqId,errorCode,errorString))
misantroop
  • 2,276
  • 1
  • 16
  • 24
-2

The solution to the problem was to execute python setup install rather than using pip to install ibapi. Thanks for your answers.

jayurbain
  • 429
  • 1
  • 5
  • 11