liveBook · Manning

Trader Workstation

As explained in Investing for Programmers

Trader Workstation is Interactive Brokers' desktop trading application that provides access to market data and trading functions.

Trader Workstation (TWS) is Interactive Brokers’ local desktop application for accessing market data and trading functions through a Python API. The local dependency adds setup complexity, especially for cloud-based systems, but enables programmatic portfolio access and order execution. section 6.3.2 section 11.4.3

A practical integration typically involves:

  • Configure and start TWS, then connect with ib_insync. section 6.3.2
  • Retrieve positions or market data and normalize them into DataFrame-compatible records. section 6.3.2
  • Choose market or limit orders while accounting for bid-ask spread and potentially delayed data without premium subscriptions. section 11.4.3
Listing 6.2 Extracting data from Interactive Brokers
from ib_insync import *     #1
util.startLoop()           #1
ib =  IB()                 #1
ib.connect()               #1

ibr = util.df(ib.positions())                #2
ibr[COL_TICKER] = (ibr.contract.apply
                   (lambda x: x.symbol))    #2
ibr["exchange"] = (ibr.contract.apply
                   (lambda x: x.exchange))  #2
ibr["broker"] = "INTERACTIVE_BROKER"        #2

IB_balances = (ibr[[COL_TICKER, 'position', 'avgCost', 
                   COL_EXCHANGE, COL_BROKER]].
               rename(columns={'position': COL_AMOUNT, 
                               'avgCost': COL_PRICE_INIT}))

The listing demonstrates connecting through ib_insync, extracting positions, and reshaping contract fields into a consistent portfolio table. section 6.3.2

How Investing for Programmers covers it

How deep it goes
Explains setup, connection, data retrieval, market orders, and limit orders, but defers detailed configuration to an appendix.
Examples
Uses position extraction, contract normalization, market-data requests, and market- or limit-order snippets.
What it assumes
Requires a locally installed and configured TWS application plus Python API credentials and connection setup.
What you can do after
Operate TWS through ib_insync to retrieve positions, inspect quotes, and submit market or limit orders.
How it connects
Connects Python APIs, ib_insync, market data, positions, market orders, limit orders, and bid-ask spreads.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Investing for Programmers. The section links point to the parts of the book it draws on.