Package velox.api.layer1.layers
Class Layer1ApiRelay
java.lang.Object
velox.api.layer1.Layer1ApiBasicListenable
velox.api.layer1.layers.Layer1ApiUpstreamRelay
velox.api.layer1.layers.Layer1ApiRelay
- All Implemented Interfaces:
java.lang.AutoCloseable
,Layer1ApiAdminListenable
,Layer1ApiAdminListener
,Layer1ApiAdminProvider
,Layer1ApiDataListenable
,Layer1ApiDataListener
,Layer1ApiDataProvider
,Layer1ApiInstrumentListenable
,Layer1ApiInstrumentListener
,Layer1ApiInstrumentProvider
,Layer1ApiListener
,Layer1ApiMboDataListenable
,Layer1ApiMboDataListener
,Layer1ApiProvider
,Layer1ApiTradingListenable
,Layer1ApiTradingListener
,Layer1ApiTradingProvider
,LayerApiListenable
,Layer1ApiTimeSource
- Direct Known Subclasses:
Layer1ApiDepthFreezer
,Layer1ApiInjectorRelay
public class Layer1ApiRelay extends Layer1ApiUpstreamRelay implements Layer1ApiProvider, Layer1ApiListener, Layer1ApiTimeSource
Good starting point for all injectable strategies. Just passes all events
through.
-
Nested Class Summary
Nested classes/interfaces inherited from interface velox.api.layer1.layers.Layer1ApiTimeSource
Layer1ApiTimeSource.Layer1TimeSourceShortcutAllowed
-
Field Summary
Fields Modifier and Type Field Description protected Layer1ApiProvider
provider
Do not change it directly, usesetProvider(Layer1ApiProvider)
.Fields inherited from class velox.api.layer1.Layer1ApiBasicListenable
adminListeners, dataListeners, instrumentListeners, mboDataListeners, theOnlyAdminListener, theOnlyDataListener, theOnlyInstrumentListener, theOnlyMboDataListener, theOnlyTradingListener, tradingListeners
-
Constructor Summary
Constructors Modifier Constructor Description Layer1ApiRelay(Layer1ApiProvider provider)
protected
Layer1ApiRelay(Layer1ApiProvider provider, boolean subscribeToProvider)
-
Method Summary
Modifier and Type Method Description void
close()
Stop relaying data.java.lang.String
formatPrice(java.lang.String alias, double price)
Format price using platform capabilities if possiblelong
getCurrentTime()
Returns current Unix epoch time.java.lang.String
getSource()
Returns string representing data source.Layer1ApiProviderSupportedFeatures
getSupportedFeatures()
Get information about features that are supported by a provider.Layer1ApiProvider
getTimeSource()
void
login(LoginData loginData)
Initiate login to the platform.void
sendOrder(OrderSendParameters orderSendParameters)
Submit order with specified parametersjava.lang.Object
sendUserMessage(java.lang.Object data)
Allows incorporating arbitrary functionality into protocolprotected void
setProvider(Layer1ApiProvider provider)
If you use this method you must implementgetCurrentTime()
so time shortcut is not appliedvoid
subscribe(SubscribeInfo subscribeInfo)
Subscribe to specified instrument.void
unsubscribe(java.lang.String alias)
Unsubscribe from the instrumentvoid
updateOrder(OrderUpdateParameters orderUpdateParameters)
Update order according to parametersMethods inherited from class velox.api.layer1.layers.Layer1ApiUpstreamRelay
onBalance, onConnectionLost, onConnectionRestored, onDepth, onInstrumentAdded, onInstrumentAlreadySubscribed, onInstrumentNotFound, onInstrumentRemoved, onLoginFailed, onLoginSuccessful, onMarketMode, onMboCancel, onMboReplace, onMboSend, onOrderExecuted, onOrderUpdated, onStatus, onSystemTextMessage, onTrade, onUserMessage
Methods inherited from class velox.api.layer1.Layer1ApiBasicListenable
addListener, addListener, addListener, addListener, addListener, getAdminListenerBroadcaster, getDataListenerBroadcaster, getInstrumentListenerBroadcaster, getTradingListenerBroadcaster, getUniqueListenersCount, onNoSubscribers, removeListener, removeListener, removeListener, removeListener, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface velox.api.layer1.Layer1ApiAdminListenable
addListener, removeListener
Methods inherited from interface velox.api.layer1.Layer1ApiAdminListener
onConnectionLost, onConnectionRestored, onLoginFailed, onLoginSuccessful, onSystemTextMessage, onUserMessage
Methods inherited from interface velox.api.layer1.Layer1ApiDataListenable
addListener, removeListener
Methods inherited from interface velox.api.layer1.Layer1ApiDataListener
onDepth, onMarketMode, onTrade
Methods inherited from interface velox.api.layer1.Layer1ApiInstrumentListenable
addListener, removeListener
Methods inherited from interface velox.api.layer1.Layer1ApiInstrumentListener
onInstrumentAdded, onInstrumentAlreadySubscribed, onInstrumentNotFound, onInstrumentRemoved
Methods inherited from interface velox.api.layer1.Layer1ApiMboDataListenable
addListener, removeListener
Methods inherited from interface velox.api.layer1.Layer1ApiMboDataListener
onMboCancel, onMboReplace, onMboSend
Methods inherited from interface velox.api.layer1.Layer1ApiTradingListenable
addListener, removeListener
Methods inherited from interface velox.api.layer1.Layer1ApiTradingListener
onBalance, onOrderExecuted, onOrderUpdated, onStatus
-
Field Details
-
provider
Do not change it directly, usesetProvider(Layer1ApiProvider)
. And don't do that unless you really need to.
-
-
Constructor Details
-
Method Details
-
setProvider
If you use this method you must implementgetCurrentTime()
so time shortcut is not applied -
formatPrice
public java.lang.String formatPrice(java.lang.String alias, double price)Description copied from interface:Layer1ApiDataProvider
Format price using platform capabilities if possible- Specified by:
formatPrice
in interfaceLayer1ApiDataProvider
- Returns:
-
subscribe
Description copied from interface:Layer1ApiInstrumentProvider
Subscribe to specified instrument. Some parameters can be null depending on the platform.- Specified by:
subscribe
in interfaceLayer1ApiInstrumentProvider
- Parameters:
subscribeInfo
- has fields similar toInstrumentCoreInfo
-
unsubscribe
public void unsubscribe(java.lang.String alias)Description copied from interface:Layer1ApiInstrumentProvider
Unsubscribe from the instrument- Specified by:
unsubscribe
in interfaceLayer1ApiInstrumentProvider
- Parameters:
alias
- instrument alias
-
sendOrder
Description copied from interface:Layer1ApiTradingProvider
Submit order with specified parameters- Specified by:
sendOrder
in interfaceLayer1ApiTradingProvider
- Parameters:
orderSendParameters
- parameters
-
updateOrder
Description copied from interface:Layer1ApiTradingProvider
Update order according to parameters- Specified by:
updateOrder
in interfaceLayer1ApiTradingProvider
- Parameters:
orderUpdateParameters
- parameters
-
login
Description copied from interface:Layer1ApiAdminProvider
Initiate login to the platform.- Specified by:
login
in interfaceLayer1ApiAdminProvider
- Parameters:
loginData
- credentials, different platforms use different subclasses
-
getCurrentTime
public long getCurrentTime()Description copied from interface:Layer1ApiAdminProvider
Returns current Unix epoch time. This method allows time distortions if consumer is too slow - in this case time of the next event may be returned.- Specified by:
getCurrentTime
in interfaceLayer1ApiAdminProvider
- Returns:
- current Unix epoch time in nanoseconds
-
close
public void close()Description copied from class:Layer1ApiUpstreamRelay
Stop relaying data. Will not let send new events upwards, but is not guaranteed to stop ones already in progress.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceLayer1ApiAdminProvider
- Overrides:
close
in classLayer1ApiUpstreamRelay
-
getSource
public java.lang.String getSource()Description copied from interface:Layer1ApiAdminProvider
Returns string representing data source.- Specified by:
getSource
in interfaceLayer1ApiAdminProvider
- Returns:
- string representing data source
-
sendUserMessage
public java.lang.Object sendUserMessage(java.lang.Object data)Description copied from interface:Layer1ApiAdminProvider
Allows incorporating arbitrary functionality into protocol- Specified by:
sendUserMessage
in interfaceLayer1ApiAdminProvider
- Parameters:
data
- Message content- Returns:
-
getSupportedFeatures
Description copied from interface:Layer1ApiAdminProvider
Get 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
MaximumSupportedFeatures
as a way to declare full list of capabilities before being instantiated- Specified by:
getSupportedFeatures
in interfaceLayer1ApiAdminProvider
- Returns:
- object describing supported features
- See Also:
MaximumSupportedFeatures
-
getTimeSource
- Specified by:
getTimeSource
in interfaceLayer1ApiTimeSource
-