Package velox.api.layer1.layers
Class Layer1ApiUpstreamRelay
java.lang.Object
velox.api.layer1.Layer1ApiBasicListenable
velox.api.layer1.layers.Layer1ApiUpstreamRelay
- All Implemented Interfaces:
Layer1ApiAdminListenable
,Layer1ApiAdminListener
,Layer1ApiDataListenable
,Layer1ApiDataListener
,Layer1ApiInstrumentListenable
,Layer1ApiInstrumentListener
,Layer1ApiListener
,Layer1ApiMboDataListenable
,Layer1ApiMboDataListener
,Layer1ApiTradingListenable
,Layer1ApiTradingListener
,LayerApiListenable
- Direct Known Subclasses:
Layer1ApiRelay
public class Layer1ApiUpstreamRelay extends Layer1ApiBasicListenable implements Layer1ApiListener
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.atomic.AtomicBoolean
closed
Fields inherited from class velox.api.layer1.Layer1ApiBasicListenable
adminListeners, dataListeners, instrumentListeners, mboDataListeners, theOnlyAdminListener, theOnlyDataListener, theOnlyInstrumentListener, theOnlyMboDataListener, theOnlyTradingListener, tradingListeners
-
Constructor Summary
Constructors Constructor Description Layer1ApiUpstreamRelay()
-
Method Summary
Modifier and Type Method Description void
close()
Stop relaying data.void
onBalance(BalanceInfo balanceInfo)
Called when account balance information changesvoid
onConnectionLost(DisconnectionReason reason, java.lang.String message)
Connection to server lostvoid
onConnectionRestored()
Connection to server restoredvoid
onDepth(java.lang.String alias, boolean isBid, int price, int size)
Depth data update.void
onInstrumentAdded(java.lang.String alias, InstrumentInfo instrumentInfo)
Indicates successful subscription to the instrumentvoid
onInstrumentAlreadySubscribed(java.lang.String symbol, java.lang.String exchange, java.lang.String type)
Indicates that attempt to subscribe failed because subscription is already activevoid
onInstrumentNotFound(java.lang.String symbol, java.lang.String exchange, java.lang.String type)
Indicates that attempt to subscribe failed because instrument does not existvoid
onInstrumentRemoved(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.void
onLoginFailed(LoginFailedReason reason, java.lang.String message)
Failed to login with specified credentialsvoid
onLoginSuccessful()
Successful login.void
onMarketMode(java.lang.String alias, MarketMode marketMode)
Market mode update.void
onMboCancel(java.lang.String alias, java.lang.String orderId)
void
onMboReplace(java.lang.String alias, java.lang.String orderId, int price, int size)
void
onMboSend(java.lang.String alias, java.lang.String orderId, boolean isBid, int price, int size)
void
onOrderExecuted(ExecutionInfo executionInfo)
Called when one of our orders gets executedvoid
onOrderUpdated(OrderInfoUpdate orderInfoUpdate)
Called when order is updated (order creation is also considered an update).void
onStatus(StatusInfo statusInfo)
Called when instrument status information changes (PnL, number of open orders, position, etc).void
onSystemTextMessage(java.lang.String message, SystemTextMessageType messageType)
Some message from the system.void
onTrade(java.lang.String alias, double price, int size, TradeInfo tradeInfo)
Tradevoid
onUserMessage(java.lang.Object data)
Allows incorporating arbitrary functionality into protocolMethods inherited from class velox.api.layer1.Layer1ApiBasicListenable
addListener, addListener, addListener, addListener, addListener, getAdminListenerBroadcaster, getDataListenerBroadcaster, getInstrumentListenerBroadcaster, getTradingListenerBroadcaster, getUniqueListenersCount, onNoSubscribers, removeListener, removeListener, removeListener, removeListener, removeListener
-
Field Details
-
closed
protected java.util.concurrent.atomic.AtomicBoolean closed
-
-
Constructor Details
-
Layer1ApiUpstreamRelay
public Layer1ApiUpstreamRelay()
-
-
Method Details
-
onInstrumentAdded
Description copied from interface:Layer1ApiInstrumentListener
Indicates successful subscription to the instrument- Specified by:
onInstrumentAdded
in interfaceLayer1ApiInstrumentListener
- Parameters:
alias
- instrument aliasinstrumentInfo
- instrument specifications
-
onInstrumentRemoved
public void onInstrumentRemoved(java.lang.String alias)Description copied from interface:Layer1ApiInstrumentListener
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. The reason is that you can getLayer1ApiInstrumentListener.onInstrumentRemoved(String)
in the middle ofOnlineCalculatable
request- Specified by:
onInstrumentRemoved
in interfaceLayer1ApiInstrumentListener
-
onInstrumentNotFound
public void onInstrumentNotFound(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Description copied from interface:Layer1ApiInstrumentListener
Indicates that attempt to subscribe failed because instrument does not exist- Specified by:
onInstrumentNotFound
in interfaceLayer1ApiInstrumentListener
type
- seeInstrumentCoreInfo.type
-
onInstrumentAlreadySubscribed
public void onInstrumentAlreadySubscribed(java.lang.String symbol, java.lang.String exchange, java.lang.String type)Description copied from interface:Layer1ApiInstrumentListener
Indicates that attempt to subscribe failed because subscription is already active- Specified by:
onInstrumentAlreadySubscribed
in interfaceLayer1ApiInstrumentListener
type
- seeInstrumentCoreInfo.type
-
onTrade
Description copied from interface:Layer1ApiDataListener
Trade- Specified by:
onTrade
in interfaceLayer1ApiDataListener
- 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:Layer1ApiDataListener
Depth data update.- Specified by:
onDepth
in interfaceLayer1ApiDataListener
- 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:
onMboSend
in interfaceLayer1ApiMboDataListener
-
onMboReplace
public void onMboReplace(java.lang.String alias, java.lang.String orderId, int price, int size)- Specified by:
onMboReplace
in interfaceLayer1ApiMboDataListener
-
onMboCancel
public void onMboCancel(java.lang.String alias, java.lang.String orderId)- Specified by:
onMboCancel
in interfaceLayer1ApiMboDataListener
-
onMarketMode
Description copied from interface:Layer1ApiDataListener
Market mode update.- Specified by:
onMarketMode
in interfaceLayer1ApiDataListener
-
onOrderUpdated
Description copied from interface:Layer1ApiTradingListener
Called when order is updated (order creation is also considered an update).- Specified by:
onOrderUpdated
in interfaceLayer1ApiTradingListener
- Parameters:
orderInfoUpdate
- information about update
-
onOrderExecuted
Description copied from interface:Layer1ApiTradingListener
Called when one of our orders gets executed- Specified by:
onOrderExecuted
in interfaceLayer1ApiTradingListener
- Parameters:
executionInfo
- information about execution
-
onStatus
Description copied from interface:Layer1ApiTradingListener
Called when instrument status information changes (PnL, number of open orders, position, etc).- Specified by:
onStatus
in interfaceLayer1ApiTradingListener
- Parameters:
statusInfo
- status information
-
onBalance
Description copied from interface:Layer1ApiTradingListener
Called when account balance information changes- Specified by:
onBalance
in interfaceLayer1ApiTradingListener
- Parameters:
balanceInfo
- account balance information
-
onLoginFailed
Description copied from interface:Layer1ApiAdminListener
Failed to login with specified credentials- Specified by:
onLoginFailed
in interfaceLayer1ApiAdminListener
- Parameters:
reason
- reason codemessage
- test message associated with login fail (may be null)
-
onLoginSuccessful
public void onLoginSuccessful()Description copied from interface:Layer1ApiAdminListener
Successful login.- Specified by:
onLoginSuccessful
in interfaceLayer1ApiAdminListener
-
onConnectionLost
Description copied from interface:Layer1ApiAdminListener
Connection to server lost- Specified by:
onConnectionLost
in interfaceLayer1ApiAdminListener
- Parameters:
reason
- reason codemessage
- test message associated with login disconnection (may be null)
-
onConnectionRestored
public void onConnectionRestored()Description copied from interface:Layer1ApiAdminListener
Connection to server restored- Specified by:
onConnectionRestored
in interfaceLayer1ApiAdminListener
-
onSystemTextMessage
Description copied from interface:Layer1ApiAdminListener
Some message from the system. Usually you want to show it to user in some way- Specified by:
onSystemTextMessage
in interfaceLayer1ApiAdminListener
- Parameters:
message
- message itselfmessageType
- message type
-
onUserMessage
public void onUserMessage(java.lang.Object data)Description copied from interface:Layer1ApiAdminListener
Allows incorporating arbitrary functionality into protocol- Specified by:
onUserMessage
in interfaceLayer1ApiAdminListener
- Parameters:
data
- Message content
-
close
public void close()Stop relaying data. Will not let send new events upwards, but is not guaranteed to stop ones already in progress.
-