In order to use the API the IB Workstation must be installed and running – one then connects to this using the API. Installation is available for Mac, Linux and Windows – for mac the automatic pkg is here.
Next step is to download the API – a collection of java source files which handle talking to the IB Workstation. Download the jar and extract it somewhere.
Manually running the GUI app each time/manually clicking through dialogs etc, is a pain. To mitigate this the IB Controller github project provides a wrapper around launching/controlling the app. Getting this working was just a matter of following the userguide.
Creating a Simple Automated Client (Eclipse)
Ultimately this’ll be done with gradle, but for now let’s just quickly use eclipse.
- Create a new eclipse project
- Add the folder ‘javaclient’ from wherever the API was extracted as a linked source folder (right click on project -> build path -> link source folder)
- We’ll use classes in
- instantiate an ApiController
- instantiate a NewContract
- instantiate a NewOrder
- call the controller’s placeOrModifyOrder method (for now just use a no-op IOrderHandler)
I feel it’s important for this type of thing (i.e. time sensitive, immediate monetary penalties for errors) to focus on verification/programming defensively.
Thinking in pseudocode I feel like I want to place an order, and be notified if it’s not filled in $timeout seconds/any other error happens. I also feel like I want to maintain a local version of the truth, and always compare this against what the API reports as the truth before doing anything.