Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Trading using the Python TWS API - Updated
Rating: 4.2 out of 5(22 ratings)
1,574 students

Trading using the Python TWS API - Updated

Python programming with Interactive Brokers' Trader Workstation API
Last updated 10/2023
English

What you'll learn

  • Learn how to install & configure TWS for the API
  • Explore requesting market data – Code Walkthrough
  • Learn how to place basic and complex orders using the TWS Python API
  • Use the API to access portfolio data and account information
  • TWS Python API Concurrency Example - Code Walkthrough

Course content

1 section10 lectures1h 33m total length
  • Video - What is the TWS API?2:53

    We’ll cover what the TWS API is, what it can provide, and where it can be found. We’ll discuss the hardware and software requirements.

  • Lecture 1 Quiz
  • Video -Installing & Configuring TWS for the API5:26

    In this lesson, we’ll show you where to find the software applications Trader Workstation (TWS) and IB Gateway on the IBKR website for download and installation. TWS and IB Gateway are the standalone software applications which integrates with our API that can be used with custom or third party trading applications. We’ll then discuss the settings in TWS/IB Gateway which are necessary to connect an API client and those which can affect order placement.

  • Lecture 2 Quiz
  • Video - Accessing the TWS Python API Source Code4:52

    We’ll begin by describing how to obtain access to the TWS Python API open source code repository on GitHub, and explain the differences between the public download site and the private GitHub repository which has bleeding-edge source. We then discuss what the source code consists of and what it does, with a high-level view of the API architecture, and mention some of the many different environments in which Python API programs are being run.

  • Lecture 3 Quiz
  • Video -Essential components of TWS API programs8:57

    This lesson will explore the essential components of a TWS API Python program. This includes the API classes EClient and EWrapper, a function call to create a connection to TWS, and a run loop for processing returned messages in the queue. We’ll walk through a simple “Hello World” example which implements each of these components in order to send a query for details about a financial instrument and then print received details to the console. We’ll then discuss the more comprehensive sample program “Program.py” which is included with the API download and shows the syntax of all API functions.

  • Lecture 4 Quiz
  • Video - Requesting Market Data – Code Walkthrough11:36

    This lesson will explore how to request market and historical data using the TWS Python API. Code examples will be presented which show the minimum Python code necessary to request streaming and historical data and display market data in the console. Finally, we will discuss limitations on requesting data, and the types of data which are included in IBKR’s real time feed as compared to the historical database.

  • Lecture 5 Quiz
  • Video - Placing Orders using TWS Python API13:08

    In this lesson we discuss how orders can be placed, monitored, modified, and cancelled from the TWS API. To demonstrate the essential components necessary to place an order, a simple Python program is introduced which places an AAPL order to a paper account, and then prints order status messages to the console. Important topics associated with placing and monitoring orders from the API, including the master client ID, and the API maximum message rate are introduced.

  • Lecture 6 Quiz
  • Video - TWS Python API Placing Complex Orders11:03

    In this lesson, we will walk through placing complex orders, such as a Bracket and Combo orders, using the TWS Python API.

  • Lecture 7 Quiz
  • Video - Accessing Portfolio Data and Account Information10:55

    In this lesson, we discuss how to use the TWS API to portfolio data, and account information. An overview is given of API functionality for receiving portfolio and account data with descriptions of each of the different functions available and the account structures with which they are commonly used. The function reqAccountUpdates is demonstrated in a Python program to show how it can be used to subscribe to both portfolio and account data for an individual account under a subscribe-and-publish model to continuously receive updates in real time.

  • Lecture 8 Quiz
  • Video - TWS Python API Market Parameters and Scanners9:22

    In this lesson, we will walk through how to request market scanner parameters using the TWS Python API, and how to request the TWS market scanner itself.

  • Lecture 9 Quiz
  • Video - TWS Python API Concurrency Example15:32

    In this lesson we will be introducing the most basic concepts behind concurrency using the TWS Python API as well as further exploring how we can combine our requests. Request a market scanner, request market data, perform calculations and then trade.

  • Lecture 10 Quiz

Requirements

  • Programmers with experience in Python who are interested in building custom applications.
  • The TWS API utilizes socket programming, multiple threads, and other concepts which it is recommended to be familiar with beforehand.

Description

This is a course in programming with the Trader Workstation Application Programming Interface (TWS API) for Python developers. In this course, we describe how to get started in developing Python applications that use the API.

We’ll show you where to find the software applications Trader Workstation (TWS) and IB Gateway on the IBKR website for download and installation. TWS and IB Gateway are the standalone software applications which integrates with our API that can be used with custom or third party trading applications. We’ll  discuss the settings in TWS/IB Gateway which are necessary to connect an API client and those which can affect order placement.

Presenter:  Andrew Wise, US API Support Supervisor, Interactive Brokers

Andrew came on board with IBKR API in early 2022 and in addition to the support you know and love, has been contributing to many of the public resources offered by Interactive Brokers. This includes public github repositories, regular Traders Academy video series, and reinventing our public documentation. Before joining IBKR, Andrew focused primarily on IT and Linux Server support over the years, standing as a testament that anybody with any level of experience can get started with the Interactive Brokers APIs. Andrew has a BS in Spatial Data Science & Technology from the University of Oregon.


Lesson Structure:

  • What is the TWS API?

  • Installing & Configuring TWS for the API

  • Accessing the TWS Python API Source Code

  • Essential components of TWS API programs

  • Requesting Market Data – Code Walkthrough

  • Placing Orders using TWS Python API

  • TWS Python API Placing Complex Orders

  • Accessing Portfolio Data and Account Information

  • TWS Python API Market Parameters and Scanners

  • TWS Python API Concurrency Example

Prerequisites for this course:

  • Windows, Linux, or Mac OS computer with a Graphical User Interface and Python 3.3 or higher installed.

  • Familiarity with Python programming.

  • The TWS API utilizes socket programming, multiple threads, and other concepts which it is recommended to be familiar with beforehand. If not, it is suggested to first try an Introduction to Python course which covers these topics.

Intended Audience:

  • Programmers with experience in Python who are interested in building custom applications.


Who this course is for:

  • This is a course in programming with the Interactive Brokers' Trader Workstation Application Programming Interface (TWS API) for Python developers. In this course, we describe how to get started in developing Python applications that use the API.