Class ExternalLiveBaseProvider

java.lang.Object
velox.api.layer0.live.ExternalLiveBaseProvider
All Implemented Interfaces:
AutoCloseable, Layer1ApiAdminListenable, Layer1ApiAdminProvider, Layer1ApiDataListenable, Layer1ApiDataProvider, Layer1ApiInstrumentListenable, Layer1ApiInstrumentProvider, Layer1ApiMboDataListenable, Layer1ApiProvider, Layer1ApiTradingListenable, Layer1ApiTradingProvider, LayerApiListenable

public abstract class ExternalLiveBaseProvider extends Object implements Layer1ApiProvider

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

Lifecycle

Typical lifecycle looks like this:

  1. An instance of your provider class is created (constructor with no parameters is invoked).
  2. addListener methods are called. Assuming you are extending this class, you don't need to worry about this step. This allows your provider to send data into Bookmap.
  3. A user tries to connect the provider - Layer1ApiAdminProvider.login(LoginData) is called with either an instance of:
  4. This object contains the user's credentials, you may use it to login into the exchange API.
  5. Provider should attempt to establish connection asynchronously.
  6. 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 methods on the corresponding listeners, e.g. to push a depth update use:

    dataListeners.forEach(listener -> listener.onDepth(alias, isBid, price, size));
  7. If the connection is lost provider can report it with Layer1ApiAdminListener.onConnectionLost(DisconnectionReason, String) and use Layer1ApiAdminListener.onConnectionRestored() when it's restored.
  8. Provider can be disconnected at any time - in this case Layer1ApiAdminProvider.close() is invoked. After this point provider instance will not be used anymore. Your provider should clean up resources and stop invoking callbacks

Important note: All callbacks that do not return a value (upstream events, available via *Listener interfaces, like Layer1ApiAdminListener), 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.

See Also: