Class ExternalLiveBaseProvider

All Implemented Interfaces:
java.lang.AutoCloseable, Layer1ApiAdminListenable, Layer1ApiAdminProvider, Layer1ApiDataListenable, Layer1ApiDataProvider, Layer1ApiInstrumentListenable, Layer1ApiInstrumentProvider, Layer1ApiMboDataListenable, Layer1ApiProvider, Layer1ApiTradingListenable, Layer1ApiTradingProvider, LayerApiListenable

public abstract class ExternalLiveBaseProvider
extends java.lang.Object
implements Layer1ApiProvider

This is a base class that should help you writing your own connector for live data and trading.


Typical lifecycle looks like this:

  1. Provider is created (constructor with no parameters is invoked).
  2. addListener methods are called. Provider should remember the listeners and use those for sending data later.
  3. Layer1ApiAdminProvider.login(LoginData) is called with instance of UserPasswordDemoLoginData as parameter.
  4. Provider should attempt to establish connection asynchronously, if that fails it should call Layer1ApiAdminListener.onLoginFailed(, String) and another Layer1ApiAdminProvider.login(LoginData) call can be made later. If connection is established Layer1ApiAdminListener.onLoginSuccessful() should be called
  5. Now provider is in connected state. Subscription/unsubscription requests could be made as well as order-related requests (if provider supports trading, which should be stated using getSupportedFeatures()).

    Provider should push updates into Bookmap by calling corresponding listener methods.

    If connection is lost provider can report it with Layer1ApiAdminAdapter.onConnectionLost(, String) and use Layer1ApiAdminListener.onConnectionRestored() when it's restored.

  6. Layer1ApiAdminProvider.close() is invoked. This is the place to clean up resources. After this point provider instance will not be used anymore.

However it's possible that Layer1ApiAdminProvider.close() method will be called earlier. In this case provider should stop invoking callbacks and clean up resources.

Important note: All callbacks that do not return a value are asynchronous. Timestamp of an event is defined by the time when callback was invoked. Provider methods that do not return value are also allowed to be implemented in asynchronous manner. For ones that take noticeable amount of time it's recommended.

If event rate is higher than Bookmap can process events will be queued but timestamps will not be distorted.