IB-Matlab User Guide

DISCLAIMER

1 Introduction

2 Installation and licensing

2.1 Licensing and activation

2.2 Switching activated computers

2.3 Updating the static Java classpath

3 Using IBMatlab

3.1 General usage

3.2 Contract properties

3.3 Returned data format

4 Querying account and portfolio data

4.1 Account information

4.2 Portfolio data

5 Querying current market data

5.1 Single-quote data

5.2 Market depth (Level II) data

5.3 Scanner data

5.4 Contract details and options chain

5.5 Fundamental data

6 Querying historical and intra-day data

7 Streaming data

7.1 Streaming quotes

7.2 Realtime bars

7.3 Streaming market depth (Level II) data

8 Sending trade orders

8.1 General usage

8.2 Close orders

8.3 Order types

8.4 Trail orders

8.5 Financial Advisor (multi-client) orders

8.6 Potential impact of an order (“what-if”)

9 Specialized trade orders

9.1 VWAP (best-effort) orders

9.2 TWAP (best-effort) orders

9.3 Bracket (child) orders

9.4 Automated orders

9.5 Combo orders

9.6 Setting special order attributes

9.7 Exercising and lapsing options

9.8 Algorithmic trading orders

10 Accessing and cancelling open trade orders

10.1 Retrieving the list of open orders

10.2 Modifying open orders

10.3 Cancelling open orders

11 Processing IB events

11.1 Processing events in IB-Matlab

11.2 Example – using CallbackExecDetails to track executions

11.3 Example – using CallbackTickGeneric to check if a security is shortable

11.4 Example – using CallbackContractDetails to get a contract’s full options chain

11.5 Example – using CallbackUpdateMktDepth for realtime order-book GUI update

12 Tracking trade executions

12.1 User requests

12.2 Automated log files

12.3 Using CallbackExecDetails

13 TWS connection parameters

14 Handling errors, problems, and IB messages

14.1 Messages sent from IB

14.2 Ambiguous/invalid security errors

14.3 Programmatic errors

14.4 Troubleshooting specific problems/errors

15 Using the Java connector object

15.1 Using the connector object

15.2 Programming interface

15.3 Usage example

16 Sample strategies/models using IB-Matlab

16.1 Pairs trading

16.1.1 Once a day – decide whether two securities are co-integrated 171

16.1.2 Runtime – process TickPrice streaming-quote events

16.2 Using RSI technical indicator

17 Frequently-asked questions (FAQ)

1. Can IB-Matlab be used with other brokers?

2. Does IB-Matlab impose limitations on historical data or streaming quotes?

3. Can I see a demo of IB-Matlab?

4. How does IB-Matlab compare to alternative products?

5. How do you know that IB-Matlab trades $100M daily?

6. Does IB-Matlab send you any information?

7. How can I be sure IB-Matlab does not contain bugs that will affect my trades?

8. Is IB-Matlab being maintained? supported?

9. I saw a nice new feature in the online User Guide – can I get it?

10. What happens when the license term is over?

11. Can I transfer my IB-Matlab license to another computer?

12. I have a laptop and desktop – can I use IB-Matlab on both?

13. Can IB-Matlab be compiled and deployed?

14. Is IB-Matlab provided in source-code format?

15. Do you provide an escrow service for IB-Matlab’s source-code?

16. Is feature ABC available in IB-Matlab?

17. Can you add feature ABC in IB-Matlab for me?

18. Can you develop a trading strategy for me?

19. Does IB-Matlab include back-testing/charting/GUI/data analysis/algo-trading?

20. Does IB-Matlab work with the IB demo account?

21. Is IB-Matlab supported on my platform?

18 Professional services

18.1 Sample program screenshots

18.2 About the author (Yair Altman)

Appendix A – resources

A.1 IB-related resources

A.2 MathWorks webinars

A.3 Additional open-source Matlab resources

Appendix B – change log

Changelog