Hello Luciano,

The error you are receiving is a very common side effect of a deeper issue with the communication to Interactive Brokers. This error is most associate with what Interactive Brokers called a 'Broken Pipe'.

A broken pipe is the result of a faulty initialization connection to the Trader Workstation. You do have to log in to the TWS, ensure it's running in the background, and set up the global configuration API setting within the TWS to accept from the port specified in the code.

The code only works when the setup is correct. Check this out for more information on setup: http://interactivebrokers.github.io/tws-api/initial_setup.html

This should be enough to get you up and running. I cover the topic and following code a more in depth in the official guide: https://thequantacademy.com/products/code-guide-bundle

If you're ready to get a little more advanced and make sure your set up is correct then check it out. If you're not ready for that yet, then hopefully you've found my other free guide on Medium.

Happy Coding!

Corbin

Incoming Consultant (@McKinsey), Former Developer (@JahnelGroup), Teaching with thequantacademy.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store