Package velox.api.layer1.layers
Class Layer1ApiInjectorRelay
java.lang.Object
velox.api.layer1.Layer1ApiBasicListenable
velox.api.layer1.layers.Layer1ApiUpstreamRelay
velox.api.layer1.layers.Layer1ApiRelay
velox.api.layer1.layers.Layer1ApiInjectorRelay
- 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:
Layer1ApiStrategiesEchoMessagesLayer
public class Layer1ApiInjectorRelay extends Layer1ApiRelay
This relay is also capable of injecting messages into provider -> gui stream
in asynchronous manner. Use it when you need to do on* call in response to
some event.
-
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 java.lang.ObjectupstreamInjectorLockFields inherited from class velox.api.layer1.Layer1ApiBasicListenable
adminListeners, dataListeners, instrumentListeners, mboDataListeners, theOnlyAdminListener, theOnlyDataListener, theOnlyInstrumentListener, theOnlyMboDataListener, theOnlyTradingListener, tradingListeners -
Constructor Summary
Constructors Constructor Description Layer1ApiInjectorRelay(Layer1ApiProvider provider) -
Method Summary
Modifier and Type Method Description voidclose()Stop relaying data.protected voidinject(java.lang.Runnable r)Inject runnable into messages stream provider -> gui.protected voidinjectSynchronously(java.lang.Runnable r)Inject runnable into messages stream provider -> gui from the same thread.voidonBalance(BalanceInfo balanceInfo)Called when account balance information changesvoidonConnectionLost(DisconnectionReason reason, java.lang.String message)Connection to server lostvoidonConnectionRestored()Connection to server restoredvoidonDepth(java.lang.String alias, boolean isBid, int price, int size)Depth data update.voidonInstrumentAdded(java.lang.String alias, InstrumentInfo instrumentInfo)Indicates successful subscription to the instrumentvoidonInstrumentAlreadySubscribed(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Indicates that attempt to subscribe failed because subscription is already activevoidonInstrumentNotFound(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Indicates that attempt to subscribe failed because instrument does not existvoidonInstrumentRemoved(java.lang.String alias)Unsubscribed from instrument (user-initiated or provider initiated).
Please note that if you use this in strategy that implementsOnlineCalculatable, you should not delete any data about instrument that is expected inOnlineCalculatable.calculateValuesInRange(String, String, long, long, int, velox.api.layer1.layers.strategies.interfaces.CalculatedResultListener)orOnlineCalculatable.createOnlineValueCalculator(String, String, long, java.util.function.Consumer, velox.api.layer1.layers.strategies.interfaces.InvalidateInterface), or should handle absence of that data (in case you delete it) gracefully.voidonLoginFailed(LoginFailedReason reason, java.lang.String message)Failed to login with specified credentialsvoidonLoginSuccessful()Successful login.voidonMarketMode(java.lang.String alias, MarketMode marketMode)Market mode update.voidonMboCancel(java.lang.String alias, java.lang.String orderId)voidonMboReplace(java.lang.String alias, java.lang.String orderId, int price, int size)voidonMboSend(java.lang.String alias, java.lang.String orderId, boolean isBid, int price, int size)voidonOrderExecuted(ExecutionInfo executionInfo)Called when one of our orders gets executedvoidonOrderUpdated(OrderInfoUpdate orderInfoUpdate)Called when order is updated (order creation is also considered an update).voidonStatus(StatusInfo statusInfo)Called when instrument status information changes (PnL, number of open orders, position, etc).voidonSystemTextMessage(java.lang.String message, SystemTextMessageType messageType)Some message from the system.voidonTrade(java.lang.String alias, double price, int size, TradeInfo tradeInfo)TradevoidonUserMessage(java.lang.Object data)Allows incorporating arbitrary functionality into protocolprotected voidsafeInject(java.lang.Runnable r)Deprecated.Methods inherited from class velox.api.layer1.layers.Layer1ApiRelay
formatPrice, getCurrentTime, getSource, getSupportedFeatures, getTimeSource, login, sendOrder, sendUserMessage, setProvider, subscribe, unsubscribe, updateOrderMethods inherited from class velox.api.layer1.Layer1ApiBasicListenable
addListener, addListener, addListener, addListener, addListener, getAdminListenerBroadcaster, getDataListenerBroadcaster, getInstrumentListenerBroadcaster, getTradingListenerBroadcaster, getUniqueListenersCount, onNoSubscribers, removeListener, removeListener, removeListener, removeListener, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface velox.api.layer1.Layer1ApiAdminListenable
addListener, removeListenerMethods inherited from interface velox.api.layer1.Layer1ApiDataListenable
addListener, removeListenerMethods inherited from interface velox.api.layer1.Layer1ApiInstrumentListenable
addListener, removeListenerMethods inherited from interface velox.api.layer1.Layer1ApiMboDataListenable
addListener, removeListenerMethods inherited from interface velox.api.layer1.Layer1ApiTradingListenable
addListener, removeListener
-
Field Details
-
upstreamInjectorLock
protected final java.lang.Object upstreamInjectorLock
-
-
Constructor Details
-
Method Details
-
inject
protected void inject(java.lang.Runnable r)Inject runnable into messages stream provider -> gui. Event is handled asynchronously. If you need to inject event synchronously and/or from the same thread - take a look atinjectSynchronously(Runnable) -
injectSynchronously
protected void injectSynchronously(java.lang.Runnable r)Inject runnable into messages stream provider -> gui from the same thread. Blocks until event is injected. Be careful when using this method, it's easy to cause a deadlock. If in doubt - useinject(Runnable)instead. -
safeInject
@Deprecated protected void safeInject(java.lang.Runnable r)Deprecated.Inject runnable into messages stream provider -> gui. If exception happens this method will log it, but won't crash the application (this was a behavior that appeared by accident). Useinject(Runnable)instead. -
close
public void close()Description copied from class:Layer1ApiUpstreamRelayStop relaying data. Will not let send new events upwards, but is not guaranteed to stop ones already in progress.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceLayer1ApiAdminProvider- Overrides:
closein classLayer1ApiRelay
-
onInstrumentAdded
Description copied from interface:Layer1ApiInstrumentListenerIndicates successful subscription to the instrument- Specified by:
onInstrumentAddedin interfaceLayer1ApiInstrumentListener- Overrides:
onInstrumentAddedin classLayer1ApiUpstreamRelay- Parameters:
alias- instrument aliasinstrumentInfo- instrument specifications
-
onInstrumentRemoved
public void onInstrumentRemoved(java.lang.String alias)Description copied from interface:Layer1ApiInstrumentListenerUnsubscribed from instrument (user-initiated or provider initiated).
Please note that if you use this in strategy that implementsOnlineCalculatable, you should not delete any data about instrument that is expected inOnlineCalculatable.calculateValuesInRange(String, String, long, long, int, velox.api.layer1.layers.strategies.interfaces.CalculatedResultListener)orOnlineCalculatable.createOnlineValueCalculator(String, String, long, java.util.function.Consumer, velox.api.layer1.layers.strategies.interfaces.InvalidateInterface), or should handle absence of that data (in case you delete it) gracefully. The reason is that you can getLayer1ApiInstrumentListener.onInstrumentRemoved(String)in the middle ofOnlineCalculatablerequest- Specified by:
onInstrumentRemovedin interfaceLayer1ApiInstrumentListener- Overrides:
onInstrumentRemovedin classLayer1ApiUpstreamRelay
-
onInstrumentNotFound
public void onInstrumentNotFound(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Description copied from interface:Layer1ApiInstrumentListenerIndicates that attempt to subscribe failed because instrument does not exist- Specified by:
onInstrumentNotFoundin interfaceLayer1ApiInstrumentListener- Overrides:
onInstrumentNotFoundin classLayer1ApiUpstreamRelaytype- seeInstrumentCoreInfo.type
-
onInstrumentAlreadySubscribed
public void onInstrumentAlreadySubscribed(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Description copied from interface:Layer1ApiInstrumentListenerIndicates that attempt to subscribe failed because subscription is already active- Specified by:
onInstrumentAlreadySubscribedin interfaceLayer1ApiInstrumentListener- Overrides:
onInstrumentAlreadySubscribedin classLayer1ApiUpstreamRelaytype- seeInstrumentCoreInfo.type
-
onTrade
Description copied from interface:Layer1ApiDataListenerTrade- Specified by:
onTradein interfaceLayer1ApiDataListener- Overrides:
onTradein classLayer1ApiUpstreamRelay- Parameters:
alias- instrument aliasprice- price in the same units as in depth update (e.g. if pips=25 then price=1000 means 25000)size- trade sizetradeInfo- additional information about the trade
-
onDepth
public void onDepth(java.lang.String alias, boolean isBid, int price, int size)Description copied from interface:Layer1ApiDataListenerDepth data update.- Specified by:
onDepthin interfaceLayer1ApiDataListener- Overrides:
onDepthin classLayer1ApiUpstreamRelay- Parameters:
alias- instrument aliasisBid- true if it is for bids, false for asksprice- price where size changedsize- new size
-
onMboSend
public void onMboSend(java.lang.String alias, java.lang.String orderId, boolean isBid, int price, int size)- Specified by:
onMboSendin interfaceLayer1ApiMboDataListener- Overrides:
onMboSendin classLayer1ApiUpstreamRelay
-
onMboReplace
public void onMboReplace(java.lang.String alias, java.lang.String orderId, int price, int size)- Specified by:
onMboReplacein interfaceLayer1ApiMboDataListener- Overrides:
onMboReplacein classLayer1ApiUpstreamRelay
-
onMboCancel
public void onMboCancel(java.lang.String alias, java.lang.String orderId)- Specified by:
onMboCancelin interfaceLayer1ApiMboDataListener- Overrides:
onMboCancelin classLayer1ApiUpstreamRelay
-
onMarketMode
Description copied from interface:Layer1ApiDataListenerMarket mode update.- Specified by:
onMarketModein interfaceLayer1ApiDataListener- Overrides:
onMarketModein classLayer1ApiUpstreamRelay
-
onOrderUpdated
Description copied from interface:Layer1ApiTradingListenerCalled when order is updated (order creation is also considered an update).- Specified by:
onOrderUpdatedin interfaceLayer1ApiTradingListener- Overrides:
onOrderUpdatedin classLayer1ApiUpstreamRelay- Parameters:
orderInfoUpdate- information about update
-
onOrderExecuted
Description copied from interface:Layer1ApiTradingListenerCalled when one of our orders gets executed- Specified by:
onOrderExecutedin interfaceLayer1ApiTradingListener- Overrides:
onOrderExecutedin classLayer1ApiUpstreamRelay- Parameters:
executionInfo- information about execution
-
onStatus
Description copied from interface:Layer1ApiTradingListenerCalled when instrument status information changes (PnL, number of open orders, position, etc).- Specified by:
onStatusin interfaceLayer1ApiTradingListener- Overrides:
onStatusin classLayer1ApiUpstreamRelay- Parameters:
statusInfo- status information
-
onBalance
Description copied from interface:Layer1ApiTradingListenerCalled when account balance information changes- Specified by:
onBalancein interfaceLayer1ApiTradingListener- Overrides:
onBalancein classLayer1ApiUpstreamRelay- Parameters:
balanceInfo- account balance information
-
onLoginFailed
Description copied from interface:Layer1ApiAdminListenerFailed to login with specified credentials- Specified by:
onLoginFailedin interfaceLayer1ApiAdminListener- Overrides:
onLoginFailedin classLayer1ApiUpstreamRelay- Parameters:
reason- reason codemessage- test message associated with login fail (may be null)
-
onLoginSuccessful
public void onLoginSuccessful()Description copied from interface:Layer1ApiAdminListenerSuccessful login.- Specified by:
onLoginSuccessfulin interfaceLayer1ApiAdminListener- Overrides:
onLoginSuccessfulin classLayer1ApiUpstreamRelay
-
onConnectionLost
Description copied from interface:Layer1ApiAdminListenerConnection to server lost- Specified by:
onConnectionLostin interfaceLayer1ApiAdminListener- Overrides:
onConnectionLostin classLayer1ApiUpstreamRelay- Parameters:
reason- reason codemessage- test message associated with login disconnection (may be null)
-
onConnectionRestored
public void onConnectionRestored()Description copied from interface:Layer1ApiAdminListenerConnection to server restored- Specified by:
onConnectionRestoredin interfaceLayer1ApiAdminListener- Overrides:
onConnectionRestoredin classLayer1ApiUpstreamRelay
-
onSystemTextMessage
Description copied from interface:Layer1ApiAdminListenerSome message from the system. Usually you want to show it to user in some way- Specified by:
onSystemTextMessagein interfaceLayer1ApiAdminListener- Overrides:
onSystemTextMessagein classLayer1ApiUpstreamRelay- Parameters:
message- message itselfmessageType- message type
-
onUserMessage
public void onUserMessage(java.lang.Object data)Description copied from interface:Layer1ApiAdminListenerAllows incorporating arbitrary functionality into protocol- Specified by:
onUserMessagein interfaceLayer1ApiAdminListener- Overrides:
onUserMessagein classLayer1ApiUpstreamRelay- Parameters:
data- Message content
-