0

Keep seeing this error message

Hi guys,

I tried to run this code for IBKR API. I literally just copy/pasted what I learned in the udemy course but still getting this message.

Some additional info below:

  1. I did it twice in two of my computers, but seeing the same error.
  2. I made sure TWS files are in the right location when I opened Spyder(python) in my anaconda virtual environment. Some summaries of code I used in terminal below:

conda create —name quant python=3.8

conda info —envs (it will tell all the environments created in the computer)

conda activate quant

conda install -c anaconda spyder

conda install pandas==0.24.1

conda install threading

conda install times

cd “....\TWS API\source\pythonclient”

conda activate quant

python setup.py install

spyder

spyder —new-instance (use this if spyder is already running in different environment)

Ryan C
  • 15
  • 4

1 Answers1

-1

That's your second problem. First is you don't have a connection. I'm guessing the course has a section on how to make TWS accept a connection.

note: The code is not how IB recommends using the api, you should never need to use sleep. However, once TWS accepts a connection the code will probably work.

Follow the program flow. After TWS accepts a connection, nextValidId is fired, then self.nextValidOrderId is set and can be accessed later.

brian
  • 10,619
  • 4
  • 21
  • 79