开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

Re: TypeError: TestApp.error() takes 4 positional arguments but 5 were given


 

I came across this the other day.? I believe that IB has been making major changes to the API (in minor patch releases).

Look for your definition of error().? It now takes 5 arguments and not 4.

So something like this:

??? def error(self,
????????????? reqId: TickerId,
????????????? errorCode: int,
????????????? errorString: str):?

Needs to be changed to:

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

Take a look at the API Docs.? They have some boilerplate code around using that new advancedOrderRejectionJson parameter.

-s

On Thu, Aug 11, 2022, at 6:27 PM, Joel Gross wrote:
I have been running TWS API with Python for years without many issues. Suddenly my code that worked yesterday is no longer working. Any file I run, I get an error like this:


Traceback (most recent call last):
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 296, in <module>
? ? main()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 287, in main
? ? app.run()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 409, in run
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1377, in interpret
? ? self.interpretWithSignature(fields, handleInfo)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1358, in interpretWithSignature
? ? method(*args)
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 515, in nextValidId
? ? self.start()
? File "c:\Users\joel\joelvscode\ib\ibapp\ibapi\value_stock_picker\11_get_tws_fundamental_data.py", line 137, in start
? ? self.runWithoutSchedule()
? File "c:\users\joel\joelvscode\ib\ibapp\ibapi\launchLoop.py", line 466, in runWithoutSchedule
? ? self.decoder.interpret(fields)
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1379, in interpret
? ? handleInfo.processMeth(self, iter(fields))
? File "c:\Users\joel\joelvscode\.venv\lib\site-packages\ibapi\decoder.py", line 1273, in processErrorMsg
? ? self.wrapper.error(reqId, errorCode, errorString, advancedOrderRejectJson)
TypeError: TestApp.error() takes 4 positional arguments but 5 were given

I am running Windows 10, TWS Latest, API Latest. About the time this error started, I had to switch from Visual Studio Code to Visual Studio Code Insiders. Python files run regularly under VS Code Insiders just fine.

What could cause this to happen??

Join [email protected] to automatically receive all group messages.