Skip to content

Jochen1980/tws-api-examples

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

TWS API examples for Interactive Brokers (IB)

Interactive Brokers (IB) allows to connect with their trading software Trader Workstation (TWS) through their TWS API.

Enable TWS API access for your local computer

You first need to start TWS on your computer and within the settings menue you have to enable TWS API access for your "localhost" network interface (127.0.0.1) on port 7496. For paper trading this is port 7497 per default. This allows to run scripts on the same machine you run TWS on.

Check this: https://interactivebrokers.github.io/tws-api/initial_setup.html.

Official TWS API software from IB

Official TWS API software from Interactive Brokers can be found on https://www.interactivebrokers.com/en/trading/ib-api.php.

Discussions around the TWS API are best on https://groups.io/g/twsapi.

Please also check the FAQ at: https://dimon.ca/dmitrys-tws-api-faq/.

Install ib_insync for python

ib_insync ist another python API to connect to your TWS with discussions at https://groups.io/g/insync.

To install ib_insync, first install python3 and then run:

pip3 install ib_insync

To update ib_insync later on, run:

pip3 install --upgrade ib_insync

python library pandas

pandas is a useful additional python library for data analysis and manipulation.

Install on Debian or Ubuntu Linux with:

sudo apt-get install python3-pandas

Or you can install via pip3:

pip3 install pandas

For updates run:

pip3 install --upgrade pandas

historic stock data download

Example script which downloads historic stock data for all companies of the DOW, SP500 and Nasdaq100 indices.

See stock-hist-data-download.py.

links to similar / further projects

IB flex queries

A bit different to the TWS API are flex queries and downloading/parsing of them.

Here some projects around this:

About

IB TWS API examples

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%