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:
Layer1ApiAdminProvider.login(LoginData)
is called with instance of
UserPasswordDemoLoginData
as parameter.Layer1ApiAdminListener.onLoginFailed(velox.api.layer1.data.LoginFailedReason, String)
and another Layer1ApiAdminProvider.login(LoginData)
call can be made later. If connection
is established Layer1ApiAdminListener.onLoginSuccessful()
should be
called
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(velox.api.layer1.data.DisconnectionReason, String)
and use Layer1ApiAdminListener.onConnectionRestored()
when it's
restored.
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.
Modifier and Type | Field and Description |
---|---|
java.util.concurrent.CopyOnWriteArrayList<Layer1ApiAdminListener> |
adminListeners |
java.util.concurrent.CopyOnWriteArrayList<Layer1ApiDataListener> |
dataListeners |
java.util.concurrent.CopyOnWriteArrayList<Layer1ApiInstrumentListener> |
instrumentListeners |
java.util.concurrent.CopyOnWriteArrayList<Layer1ApiMboDataListener> |
mboDataListeners |
java.util.concurrent.CopyOnWriteArrayList<Layer1ApiTradingListener> |
tradingListeners |
Constructor and Description |
---|
ExternalLiveBaseProvider() |
Modifier and Type | Method and Description |
---|---|
void |
addListener(Layer1ApiAdminListener listener)
Add listener for general events
|
void |
addListener(Layer1ApiDataListener listener)
Add data listener
|
void |
addListener(Layer1ApiInstrumentListener listener)
Add instrument events listener
|
void |
addListener(Layer1ApiMboDataListener listener)
Add mbo data listener
|
void |
addListener(Layer1ApiTradingListener listener)
Add trading listener
|
protected java.lang.String |
formatPriceDefault(double pips,
double price)
Formats prices using default bookmap price formatting logic.
|
long |
getCurrentTime()
This method will not be invoked for external providers
|
Layer1ApiProviderSupportedFeatures |
getSupportedFeatures()
You can override this if you are implementing a live trading support.
|
void |
removeListener(Layer1ApiAdminListener listener)
Remove listener for general events
|
void |
removeListener(Layer1ApiDataListener listener)
Remove data listener
|
void |
removeListener(Layer1ApiInstrumentListener listener)
Remove instrument events listener
|
void |
removeListener(Layer1ApiMboDataListener listener)
Remove mbo data listener
|
void |
removeListener(Layer1ApiTradingListener listener)
Remove trading listener
|
java.lang.Object |
sendUserMessage(java.lang.Object data)
Some messages might reach the provider, but those can be ignored
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
subscribe, subscribe, unsubscribe
formatPrice
sendOrder, updateOrder
close, getSource, login
public java.util.concurrent.CopyOnWriteArrayList<Layer1ApiAdminListener> adminListeners
public java.util.concurrent.CopyOnWriteArrayList<Layer1ApiInstrumentListener> instrumentListeners
public java.util.concurrent.CopyOnWriteArrayList<Layer1ApiDataListener> dataListeners
public java.util.concurrent.CopyOnWriteArrayList<Layer1ApiMboDataListener> mboDataListeners
public java.util.concurrent.CopyOnWriteArrayList<Layer1ApiTradingListener> tradingListeners
protected java.lang.String formatPriceDefault(double pips, double price)
PriceFormatHelper.formatPriceDefault(double, double)
can be used
insteadpublic Layer1ApiProviderSupportedFeatures getSupportedFeatures()
getSupportedFeatures
in interface Layer1ApiAdminProvider
MaximumSupportedFeatures
public java.lang.Object sendUserMessage(java.lang.Object data)
sendUserMessage
in interface Layer1ApiAdminProvider
data
- Message contentpublic void addListener(Layer1ApiAdminListener listener)
Layer1ApiAdminListenable
addListener
in interface Layer1ApiAdminListenable
listener
- listener to addpublic void removeListener(Layer1ApiAdminListener listener)
Layer1ApiAdminListenable
removeListener
in interface Layer1ApiAdminListenable
listener
- listener to removepublic void addListener(Layer1ApiInstrumentListener listener)
Layer1ApiInstrumentListenable
addListener
in interface Layer1ApiInstrumentListenable
listener
- listener to addpublic void removeListener(Layer1ApiInstrumentListener listener)
Layer1ApiInstrumentListenable
removeListener
in interface Layer1ApiInstrumentListenable
listener
- listener to removepublic void addListener(Layer1ApiTradingListener listener)
Layer1ApiTradingListenable
addListener
in interface Layer1ApiTradingListenable
listener
- listener to addpublic void removeListener(Layer1ApiTradingListener listener)
Layer1ApiTradingListenable
removeListener
in interface Layer1ApiTradingListenable
listener
- listener to removepublic void addListener(Layer1ApiDataListener listener)
Layer1ApiDataListenable
addListener
in interface Layer1ApiDataListenable
listener
- listener to addpublic void removeListener(Layer1ApiDataListener listener)
Layer1ApiDataListenable
removeListener
in interface Layer1ApiDataListenable
listener
- listener to removepublic void addListener(Layer1ApiMboDataListener listener)
Layer1ApiMboDataListenable
addListener
in interface Layer1ApiMboDataListenable
listener
- listener to addpublic void removeListener(Layer1ApiMboDataListener listener)
Layer1ApiMboDataListenable
removeListener
in interface Layer1ApiMboDataListenable
listener
- listener to removepublic final long getCurrentTime()
getCurrentTime
in interface Layer1ApiAdminProvider