Class ExternalReaderBaseProvider

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

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

This is a base class that should help you writing your own providers for reading files in replay.

Lifecycle

Provider is guaranteed to be used for replay of only one file

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 ReadFileLoginData as parameter. Before exiting this method provider should check that file format is supported. If it is not then FileNotSupportedUserMessage should be sent via Layer1ApiAdminListener.onUserMessage(Object), and Bookmap will try other ways to decode the file. Failure to send the message will prevent bookmap from attempting other decoding modules and will result in file reading being done by this module instead.
  4. As soon as Layer1ApiAdminProvider.login(LoginData) completes, Layer1ApiAdminProvider.getCurrentTime() might be called before you invoke any callbacks. If this happens then time it returns will be be used as a time where file starts. Usually you want it to be the time of the first event.
  5. Provider sends data via callbacks. Calls will be blocked until data is processed. When callback is invoked Layer1ApiAdminProvider.getCurrentTime() call will usually be made at least once before it returns. Returned value will be used as event timestamp.
  6. When all data is sent, provider calls Layer1ApiAdminListener.onUserMessage(Object) passing an instance of FileEndReachedUserMessage. After this point no other callback methods should be invoked!
  7. 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 before leaving this method.