AlgoTraderAlgoTrader Documentation

Chapter 23. Adapters

23.1. Fix Interface
23.2. IB Native Interface
23.3. IB Fix Interface
23.4. Bloomberg
23.5. Real Tick
23.6. Trading Technologies (TT) interface
23.7. JP Morgan Fix Interface
23.8. DukasCopy Fix Interface
23.9. Currenex interface
23.10. FXCM interface
23.11. LMAX interface
23.12. Fortex interface
23.13. Session life-cycle events
23.14. Drop-copy support
23.15. FIX configuration
23.15.1. FIX logging
23.15.2. FIX message persistence

The following sections give a detailed overview of the different adapters available for AlgoTrader.

AlgoTrader uses QuickFix/J for it's Fix connections and currently supports FIX 4.2 and 4.4. Because FIX messages are not compatible between different version, the two distinct services Fix42OrderService and Fix44OrderService exist. Incoming messages are handled by their corresponding Fix42MessageHandler and Fix44MessageHandler.

The Fix infrastructure consists of the following classes:

Table 23.1. Fix Infrastructure

Class / InterfaceDescription
SessionA Session represents a connection to a broker / exchange / market data provider
ApplicationFor each Session an Application object is created. It will forward incoming messages to the corresponding MessageHandlers
DefaultFixApplication
FixApplicationFactoryIs responsible for the creation of Applications
DefaultFixApplicationFactory
FixMultiApplicationSessionFactory

Creates a Session and Application using the specified FixApplicationFactory according to the following steps:

  • lookup the FixApplicationFactory by its name

  • create an Application

  • create a DefaultSessionFactory

  • create a Session

ExternalSessionStateHolder Represents the current state of a Session (i.e. DISCONNECTED, CONNECTED, LOGGED_ON and SUBSCRIBED)
DefaultFixSessionStateHolder
MarketDataFixSessionStateHolderA ExternalSessionStateHolder for market data sessions that will subscribe to securities as soon as the session is logged on.
FixOrderIdGeneratorGenerator for Fix Order Ids. The default implementation reads the last Order Ids from the Fix log on start-up.
DefaultFixOrderIdGenerator
FixAdapter Management Adapter for the Fix environment. Allows the creation of dynamic sessions, sending Messages and managing OrderIds.
DefaultFixAdapter
ManagedFixAdapterManageable implementation of a FixAdapter (based on JMX)
FixEventSchedulerQuickFix/J currently supports daily sessions (with a daily session 7 times a week) and weekly sessions (with one weekly session). However some brokers (e.g. JP Morgan) use daily sessions during workdays. To accomplish this scenario, AlgoTrader allows creation of a weekly logon/logoff event (e.g. Mo 08:00:00 and Fr 18:00:00) using Esper Statements
DefaultFixEventScheduler
EventPattern
FixSocketInitiatorFactoryBeanA Spring Factory Bean that creates the SocketInitiator necessary for all Fix Sessions.
Fix42MarketDataMessageHandlerMessage Handler for incoming Fix market data messages. These classes need to be subclassed by the corresponding market data interface. Messages are propagated into the Esper Engine.
Fix44MarketDataMessageHandler
Fix42OrderMessageHandlerMessage Handler for incoming Fix ExecutionReports. These classes need to be subclassed by the corresponding order interface. Messages are propagated into the Esper Engine.
Fix44OrderMessageHandler

The native IB Interface connects to the local Trader Workstation (TWS) or IB Gateway instance and uses methods supplied by the IB client. The interface is fully capable of handling IB's Financial Advisor functionality like Sub Accounts, Account Groups and Allocation Profiles.

The IB interface supports Market Data, Historical Data, Order Processing, Retrieval of account information as well as Reference Data.

The IB infrastructure consists of the following classes:


For further details on the IB native interface please visit the IB API Reference Guide

The IB Fix Interface provides the same Order Management features as the IB Native Interface. However Market Data is not available through this interface.

The interface is fully capable of handling IB's Financial Advisor functionality like Sub Accounts, Account Groups and Allocation Profiles.

For further details on the IB Fix interface please visit the IB FIX/CTCI Users' Guide

The Bloomberg interface supports Market Data, Historical Data as well as Reference Data.

In contrast to the IB interface the Bloomberg interface provides both synchronous connections and asynchronous connections. Asynchronous connections are generally used for live market data whereas synchronous connections are used for retrieval of historical data as well as retrieval of reference data.

The Bloomberg infrastructure consists of the following classes:


For further details on the Bloomberg interface please visit the Bloomberg Open API

RealTick provides connectivity to about 30 institutional and 10 retail brokers.

The RealTick Fix interface currently supports only Order Processing.

The Fix Implementation of RealTick is well conforming with the Fix Standard no customizations had to be made

Supports a wide range of future and option contracts tradeable at multiple venues / exchanges.

The JP Morgan Fix interface currently supports only Order Processing.

As the JP Morgan Fix Implementation is well conforming with the Fix Standard no customizations had to be made

The DukasCopy interface supports Market Data as well as Order Processing.

Since the DukasCopy Fix Implementation does not follow the Fix Standard very closely, quite a few customizations had to be made including a fully independent MessageHandler (not subclassing any of the existing FixMessageHandler classes)

The DukasCopy Fix interface uses an SSL encrypted connection which is supported by QuickFix/J using Mina. In addition the DukasCopy interface requires username and password to be send with the Logon message. For this purpose the class DCLogonMessageHandler is used as an outgoing MessageHandler.

The main features of the Currenex platform are

Currenex implementation of the FiX/4.4 protocol has some peculiarities

FXCM interface FiX/4.4 protocol does not deviate much from the standard but has some peculiarities about the way FIX sessions are established

Supports only a limited number of securities, mainly Forex

LMAX implementation of the FiX/4.4 protocol has some peculiarities

Fortex uses almost vanilla Fix/4.4 protocol with a very customizations. It supports FX only.

All trading interface adapters generate session events, which enable the server engine as well as individual strategies to listen for and react to session events such as session being fully established or temporary loss of connectivity.

@Override

public void onChange(final SessionEventVO event) {
    switch (event.getState()) {
        case CONNECTED:
            // session connected but not yet authenticated
            break;
        case LOGGED_ON:
            // session connected and authenticated
            break;
        case DISCONNECTED:
            // session disconnected
            break;
    }
}

LMAX and Trading Technologies interfaces provide support for so called drop-copy mode wherein the adapter can receive order status and fill messages from orders initiated externally (usually by external applications such as native trading front-ends). By default external fills get recorded as transactions of the SERVER strategy and allocated to the external account specified in the original execution report message. One, however, can provide a custom implementation of DropCopyAllocator interface in order to apply custom transaction allocation logic.

AlgoTrader uses standard QuickFix/J configuration facilities described in details here http://www.quickfixj.org/quickfixj/usermanual/1.5.0/usage/configuration.html

FIX configuration is stored in fix.cfg file by default.

These are default parameters suggested by AlgoTrader for all FIX sessions:

[default]
ConnectionType=initiator
HeartBtInt=30
ReconnectInterval=5
FileStorePath=files/fix
FileLogPath=log
FileLogHeartbeats=N
FileIncludeMilliseconds=Y
FileIncludeTimeStampForMessages=Y
SLF4JLogHeartbeats=N

Details of individual FIX sessions are expected to be provided by the brokerages.