ceilican / IbScala

A Scala encapsulation of the Interactive Broker's Java API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IbScala

IbScala is a Scala encapsulation of the Interactive Brokers Java API. Its design features the use of Scala/Akka Futures and RxScala/RxJava Observables.

This initial version was built using IB API version 9.68.

The project is principally maintained with SBT, for this, initial commit, version 0.13.0.

There is an overview of the structure and files in the project in Overview.md

Using Eclipse

You can generate an Eclipse project from the SBT settings by:

  1. at a command line/shell prompt change (cd) to the main directory for this project
  2. type 'sbt' ( sbt will attempt to resolve the library dependencies for the project )
  3. once its finished, at the sbt prompt type 'eclipse'
  4. sbt will generate the appropriate project files
  5. open eclipse and then import the main folder (project) as a new project

The above procedure assumes that the file 'plugins.sbt' exists in the project directory. If that file is missing, then add it with the following content:

// Comment to get more information during initialization
logLevel := Level.Warn

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// add SBTeclipse
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

Empty lines are required between each of the above entries.

TWS Connection

The test code as well as the sample applications require that an instance of the IB Trader Workstation application is running. The current connection code assumes that TWS is running on the same machine, and tries to connect through localhost, IP address 127.0.0.1. The standard port for TWS of 7496 is used. You will need to set TWS to allow local connections. The setting is found through the TWS application menu at: File -> Global Configuration -> API -> Settings

  1. Enable ActiveX and Socket Clients.
  2. Set the port to 7496.

The dialog in question looks like this:
TWS Settings

Likewise add the localhost address, 127.0.0.1. It will need to be in the following list, which may have other entries as well.

Trusted IP Addresses

Testing

Most of the ScalaTest tests in src/test/scala require a connection to TWS. The first test in a suite displays a message and then pauses until the user "presses enter/return" indicating that TWS is active. If TWS is not active the test suite will fail. In general most tests will perform an individual connect and then disconnect so that each can be self-contained.

For tests that place orders additional warning messages have been included.

Do not run the tests in the OrderTests module in a standard, active IB account !!!

Use a paper trading, or demo account only !!!####

$$$ Otherwise, MONETARY LOSSES MAY RESULT $$$ !!!####

All of the testing for this release was done within a paper trading account.

Caveats

The current codebase is lacking particular areas of functionality:

  1. There is no Financial Advisor support. The code to manage accounts has not been implemented.
  2. There is no specific support for algo-based orders.
  3. There is no support for News bulletins.
  4. There is no support for the retrieval of execution reports.
  5. There is no explicit support for bond contracts, unlike stock, futures, and option ( on stocks and futures ) contracts.

In the Pipeline

  • an Options module
  • abstracted classes for realtime Bars and Indicators ( code in the MA_Exp_Test.scala file hints at where these are headed, especially the code implementing moving averages ). These will be designed with an eye to incorporation into a trading DSL.

About

A Scala encapsulation of the Interactive Broker's Java API


Languages

Language:Scala 100.0%