Welcome to IB4m

Interactive Brokers API for Matlab

For the latest src and docs visit IB4m at github

Contents

Quick Start Guide

Getting started with IB4m is easy. Follow the steps below assuming you already have an IB tradding account and Trader Workstation installed.

  1. Enable API access in TWS for "Active X and Socket Clients" (File -> GlobalConfiguration -> API -> Settings)
  2. Add trusted IP address for local host 127.0.0.1 in TWS (File -> GlobalConfiguration -> API -> Settings)
  3. Clone IB4m on Github: git clone https://github.com/softwarespartan/IB4m.git or download from Matlab File Central

Navigate to the IB4m directory in Matlab

cd ~/Dropbox/IB4m

OK, now add IB4m and IB4m/docs to your matlab path

addpath(path,pwd);  addpath(path,fullfile(pwd,'docs'))

Finally, add TWS.jar to the (dynamic) java classpath

javaaddpath(fullfile(pwd,'Jar','TWS.jar'))

You're all set! Do a quick test to get summary of your IB account

AccountSummaryExample
added interface method: TWSNotification
notification listener has been added
Server Version:75
TWS Time at connection:20150104 18:32:00 EST
DU207406: RegTEquity = 1003650.61 (USD)
DU207406: LookAheadInitMarginReq = 0.00 (USD)
DU207406: RegTMargin = 0.00 (USD)
DU207406: GrossPositionValue = 0.00 (USD)
DU207406: LookAheadNextChange = 0 ()
DU207406: SMA = 1003650.62 (USD)
DU207406: ExcessLiquidity = 1003650.61 (USD)
DU207406: FullMaintMarginReq = 0.00 (USD)
DU207406: InitMarginReq = 0.00 (USD)
DU207406: FullAvailableFunds = 1003650.61 (USD)
DU207406: MaintMarginReq = 0.00 (USD)
DU207406: LookAheadMaintMarginReq = 0.00 (USD)
DU207406: FullExcessLiquidity = 1003650.61 (USD)
DU207406: LookAheadAvailableFunds = 1003650.61 (USD)
DU207406: LookAheadExcessLiquidity = 1003650.61 (USD)
DU207406: DayTradesRemaining = -1 ()
DU207406: FullInitMarginReq = 0.00 (USD)
DU207406: Cushion = 1 ()
DU207406: AvailableFunds = 1003650.61 (USD)

To save your matlab path use "savepath" or "pathtool". Also, consider adding TWS.jar to your static java classpath ("edit classpath.txt"). Otherwise, will need to add the jar file after each matlab restart.

Tutorials

Tutorials for MarketData, Scanner Subscriptions, Execution Details, and more. Everything you need to get up and running.

Have fun!

Getting More Help

Email brown.2179-at-gmail.com with questions, suggestions, comments etc.

References

System Requirements

IB4m has been tested on OSX 10.10, Windows 7, and Windows 8 with both Java 7 and Java 8 using the latest versions of Trader Workstation (Dec 19, 2014, Server versions 75 and 76)