Class ExternalReaderBaseProvider
- All Implemented Interfaces:
AutoCloseable,Layer1ApiAdminListenable,Layer1ApiAdminProvider,Layer1ApiDataListenable,Layer1ApiDataProvider,Layer1ApiInstrumentListenable,Layer1ApiInstrumentProvider,Layer1ApiMboDataListenable,Layer1ApiProvider,Layer1ApiTradingListenable,Layer1ApiTradingProvider,LayerApiListenable
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:
- An instance of your provider class is created (constructor with no parameters is invoked).
- 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.
Layer1ApiAdminProvider.login(LoginData)is called with instance ofReadFileLoginDataas parameter. Before exiting this method, provider should check that file format is supported. If it is not thenFileNotSupportedUserMessageshould be sent viaLayer1ApiAdminListener.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.- 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. - 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. - When all data is sent, provider calls
Layer1ApiAdminListener.onUserMessage(Object)passing an instance ofFileEndReachedUserMessage. After this point no other callback methods should be invoked! 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.
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Layer1ApiAdminListener listener) Add listener for general eventsvoidaddListener(Layer1ApiDataListener listener) Add data listenervoidaddListener(Layer1ApiInstrumentListener listener) Add instrument events listenervoidaddListener(Layer1ApiMboDataListener listener) Add mbo data listenervoidaddListener(Layer1ApiTradingListener listener) Add trading listenerformatPrice(String alias, double price) Format price using platform capabilities if possibleGet information about features that are supported by a provider.voidremoveListener(Layer1ApiAdminListener listener) Remove listener for general eventsvoidremoveListener(Layer1ApiDataListener listener) Remove data listenervoidremoveListener(Layer1ApiInstrumentListener listener) Remove instrument events listenervoidremoveListener(Layer1ApiMboDataListener listener) Remove mbo data listenervoidremoveListener(Layer1ApiTradingListener listener) Remove trading listenervoidsendOrder(OrderSendParameters orderSendParameters) Submit order with specified parameterssendUserMessage(Object data) Send a downstream event.voidsubscribe(SubscribeInfo subscribeInfo) Subscribe to specified instrument.voidunsubscribe(String alias) Unsubscribe from the instrumentvoidupdateOrder(OrderUpdateParameters orderUpdateParameters) Update order according to parametersMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface velox.api.layer1.Layer1ApiAdminProvider
close, getCurrentTime, getSource, loginMethods inherited from interface velox.api.layer1.Layer1ApiInstrumentProvider
subscribe
-
Field Details
-
adminListeners
-
instrumentListeners
-
dataListeners
-
mboDataListeners
-
tradingListeners
-
-
Constructor Details
-
ExternalReaderBaseProvider
public ExternalReaderBaseProvider()
-
-
Method Details
-
subscribe
Description copied from interface:Layer1ApiInstrumentProviderSubscribe to specified instrument. Some parameters can be null depending on the platform.- Specified by:
subscribein interfaceLayer1ApiInstrumentProvider- Parameters:
subscribeInfo- has fields similar toInstrumentCoreInfo
-
unsubscribe
Description copied from interface:Layer1ApiInstrumentProviderUnsubscribe from the instrument- Specified by:
unsubscribein interfaceLayer1ApiInstrumentProvider- Parameters:
alias- instrument alias
-
formatPrice
Description copied from interface:Layer1ApiDataProviderFormat price using platform capabilities if possible- Specified by:
formatPricein interfaceLayer1ApiDataProvider- Returns:
-
sendOrder
Description copied from interface:Layer1ApiTradingProviderSubmit order with specified parameters- Specified by:
sendOrderin interfaceLayer1ApiTradingProvider- Parameters:
orderSendParameters- parameters
-
updateOrder
Description copied from interface:Layer1ApiTradingProviderUpdate order according to parameters- Specified by:
updateOrderin interfaceLayer1ApiTradingProvider- Parameters:
orderUpdateParameters- parameters
-
getSupportedFeatures
Description copied from interface:Layer1ApiAdminProviderGet information about features that are supported by a provider. Note that some fields might be set differently depending on when request is made. E.g. adapter might not know if trading will be there until login actually happens.
If you are writing a provider - take a look at
MaximumSupportedFeaturesas a way to declare full list of capabilities before being instantiated- Specified by:
getSupportedFeaturesin interfaceLayer1ApiAdminProvider- Returns:
- object describing supported features
- See Also:
-
sendUserMessage
Description copied from interface:Layer1ApiAdminProviderSend a downstream event. Allows incorporating arbitrary functionality into protocol- Specified by:
sendUserMessagein interfaceLayer1ApiAdminProvider- Parameters:
data- Message content- Returns:
-
addListener
Description copied from interface:Layer1ApiAdminListenableAdd listener for general events- Specified by:
addListenerin interfaceLayer1ApiAdminListenable- Parameters:
listener- listener to add
-
removeListener
Description copied from interface:Layer1ApiAdminListenableRemove listener for general events- Specified by:
removeListenerin interfaceLayer1ApiAdminListenable- Parameters:
listener- listener to remove
-
addListener
Description copied from interface:Layer1ApiInstrumentListenableAdd instrument events listener- Specified by:
addListenerin interfaceLayer1ApiInstrumentListenable- Parameters:
listener- listener to add
-
removeListener
Description copied from interface:Layer1ApiInstrumentListenableRemove instrument events listener- Specified by:
removeListenerin interfaceLayer1ApiInstrumentListenable- Parameters:
listener- listener to remove
-
addListener
Description copied from interface:Layer1ApiTradingListenableAdd trading listener- Specified by:
addListenerin interfaceLayer1ApiTradingListenable- Parameters:
listener- listener to add
-
removeListener
Description copied from interface:Layer1ApiTradingListenableRemove trading listener- Specified by:
removeListenerin interfaceLayer1ApiTradingListenable- Parameters:
listener- listener to remove
-
addListener
Description copied from interface:Layer1ApiDataListenableAdd data listener- Specified by:
addListenerin interfaceLayer1ApiDataListenable- Parameters:
listener- listener to add
-
removeListener
Description copied from interface:Layer1ApiDataListenableRemove data listener- Specified by:
removeListenerin interfaceLayer1ApiDataListenable- Parameters:
listener- listener to remove
-
addListener
Description copied from interface:Layer1ApiMboDataListenableAdd mbo data listener- Specified by:
addListenerin interfaceLayer1ApiMboDataListenable- Parameters:
listener- listener to add
-
removeListener
Description copied from interface:Layer1ApiMboDataListenableRemove mbo data listener- Specified by:
removeListenerin interfaceLayer1ApiMboDataListenable- Parameters:
listener- listener to remove
-