Python Trading 1 – How to connect to Interactive Brokers with PyCharm and an API

video
play-sharp-fill

A few months ago, Interactive Brokers has changed a few things and so I decided to start over with Python, Interactive Brokers, TWS and see how it works.

They have a few tutorials up and running and I would like to check, if it is hard to get at least a good idea if this would be a good solution for what I want to do.

First we download PyCharm as this is the IDE (integrated development environment) that also is used in the videos.

I will go with the community edition.

Interactive Brokers also has an API (application programming interface) for Java, but I think Python is a better choice, because there are so many options.

After the Pycharm Community Edition was downloaded, I need to configure a few options.

I marked all the checkboxes that came up.

For the installation path I took the default option and now the installation started.

After the installation was finished, a reboot was required.

I rebooted my PC and now I can start PyCharm by clicking on the icon that the setup routine has created.

Another dialog comes up. As I have nothing to import, I chose the second option.

Now the Privacy Policy and the user agreement need to be confirmed.

And no, I don’t want the software to send user statistics, so I chose “don’t send”. 

I would like the light theme, so I chose that.

PyCharm also supports the Markdown language, so I activated that option.

Now the IDE setup process is done, I can create a new project.

My PC started to create a virtual environment for the new project. 

Even with 16 GB and a Ryzen CPU that takes a while…

PyCharm comes up with a “tip of the day window”, some of those tips are really useful.

So let’s download the API from the Interactive Brokers website.

They support Java, C++, Python, Dotnet, ActiveX and a DDE Excel solution.

On the bottom of the page there are three download buttons, we need to download the API software.

Once again a license agreement comes up. Let’s agree to that.

I want to download the latest Interactive Brokers API for windows, the current version has been released in May.

The download took just a few seconds, now a setup program comes up.

I need to agree to a third End-User Licence agreement to continue.

The default path for the installation is in the root of my hard drive, I will go with that.

Now the installation can be started.

Now my computer comes up with a virus warning?

Okay, I think I will have to investigate that later. 

The Interactive Broker API requires that we install TWS, that is an abbreviation for Trading Work Station.

Basically Python and the API will act as a remote controller for TWS. 

There is also another version that is called Gateway, but as that gateway solution doesn’t support any graphical interface, we will go on and install TWS in the next part.