public class Layer1ApiInjectorRelay extends Layer1ApiRelay
Layer1ApiTimeSource.Layer1TimeSourceShortcutAllowed
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
upstreamInjectorLock |
private java.util.concurrent.ExecutorService |
userMessageInjectorExecutor |
provider
closed
adminListeners, dataListeners, instrumentListeners, mboDataListeners, tradingListeners
Constructor and Description |
---|
Layer1ApiInjectorRelay(Layer1ApiProvider provider) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Stop relaying data.
|
protected void |
inject(java.lang.Runnable r)
Inject runnable into messages stream provider -> gui.
|
protected void |
injectSynchronously(java.lang.Runnable r)
Inject runnable into messages stream provider -> gui from the same thread.
|
void |
onBalance(BalanceInfo balanceInfo)
Called when account balance information changes
|
void |
onConnectionLost(DisconnectionReason reason,
java.lang.String message)
Connection to server lost
|
void |
onConnectionRestored()
Connection to server restored
|
void |
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 instrument
|
void |
onInstrumentAlreadySubscribed(java.lang.String symbol,
java.lang.String exchange,
java.lang.String type)
Indicates that attempt to subscribe failed because subscription is
already active
|
void |
onInstrumentNotFound(java.lang.String symbol,
java.lang.String exchange,
java.lang.String type)
Indicates that attempt to subscribe failed because instrument does not
exist
|
void |
onInstrumentRemoved(java.lang.String alias)
Unsubscribed from instrument (user-initiated or provider initiated).
Please note that if you use this in strategy that implements OnlineCalculatable ,
you should not delete any data about instrument that is expected in OnlineCalculatable.calculateValuesInRange(String, String, long, long, int, velox.api.layer1.layers.strategies.interfaces.CalculatedResultListener)
or OnlineCalculatable.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 credentials
|
void |
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 executed
|
void |
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)
Trade
|
void |
onUserMessage(java.lang.Object data)
Allows incorporating arbitrary functionality into protocol
|
protected void |
safeInject(java.lang.Runnable r)
Deprecated.
|
formatPrice, getCurrentTime, getSource, getSupportedFeatures, getTimeSource, login, sendOrder, sendUserMessage, setProvider, subscribe, unsubscribe, updateOrder
addListener, addListener, addListener, addListener, addListener, getAdminListenerBroadcaster, getDataListenerBroadcaster, getInstrumentListenerBroadcaster, getTradingListenerBroadcaster, getUniqueListenersCount, onNoSubscribers, removeListener, removeListener, removeListener, removeListener, removeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
subscribe
addListener, removeListener
addListener, removeListener
addListener, removeListener
addListener, removeListener
addListener, removeListener
getTimeSource
private final java.util.concurrent.ExecutorService userMessageInjectorExecutor
protected final java.lang.Object upstreamInjectorLock
public Layer1ApiInjectorRelay(Layer1ApiProvider provider)
protected void inject(java.lang.Runnable r)
injectSynchronously(Runnable)
protected void injectSynchronously(java.lang.Runnable r)
inject(Runnable)
instead.@Deprecated protected void safeInject(java.lang.Runnable r)
inject(Runnable)
instead.public void close()
Layer1ApiUpstreamRelay
close
in interface java.lang.AutoCloseable
close
in interface Layer1ApiAdminProvider
close
in class Layer1ApiRelay
public void onInstrumentAdded(java.lang.String alias, InstrumentInfo instrumentInfo)
Layer1ApiInstrumentListener
onInstrumentAdded
in interface Layer1ApiInstrumentListener
onInstrumentAdded
in class Layer1ApiUpstreamRelay
alias
- instrument aliasinstrumentInfo
- instrument specificationspublic void onInstrumentRemoved(java.lang.String alias)
Layer1ApiInstrumentListener
OnlineCalculatable
,
you should not delete any data about instrument that is expected in OnlineCalculatable.calculateValuesInRange(String, String, long, long, int, velox.api.layer1.layers.strategies.interfaces.CalculatedResultListener)
or OnlineCalculatable.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 get Layer1ApiInstrumentListener.onInstrumentRemoved(String)
in the middle of OnlineCalculatable
requestonInstrumentRemoved
in interface Layer1ApiInstrumentListener
onInstrumentRemoved
in class Layer1ApiUpstreamRelay
public void onInstrumentNotFound(java.lang.String symbol, java.lang.String exchange, java.lang.String type)
Layer1ApiInstrumentListener
onInstrumentNotFound
in interface Layer1ApiInstrumentListener
onInstrumentNotFound
in class Layer1ApiUpstreamRelay
type
- see InstrumentCoreInfo.type
public void onInstrumentAlreadySubscribed(java.lang.String symbol, java.lang.String exchange, java.lang.String type)
Layer1ApiInstrumentListener
onInstrumentAlreadySubscribed
in interface Layer1ApiInstrumentListener
onInstrumentAlreadySubscribed
in class Layer1ApiUpstreamRelay
type
- see InstrumentCoreInfo.type
public void onTrade(java.lang.String alias, double price, int size, TradeInfo tradeInfo)
Layer1ApiDataListener
onTrade
in interface Layer1ApiDataListener
onTrade
in class Layer1ApiUpstreamRelay
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 tradepublic void onDepth(java.lang.String alias, boolean isBid, int price, int size)
Layer1ApiDataListener
onDepth
in interface Layer1ApiDataListener
onDepth
in class Layer1ApiUpstreamRelay
alias
- instrument aliasisBid
- true if it is for bids, false for asksprice
- price where size changedsize
- new sizepublic void onMboSend(java.lang.String alias, java.lang.String orderId, boolean isBid, int price, int size)
onMboSend
in interface Layer1ApiMboDataListener
onMboSend
in class Layer1ApiUpstreamRelay
public void onMboReplace(java.lang.String alias, java.lang.String orderId, int price, int size)
onMboReplace
in interface Layer1ApiMboDataListener
onMboReplace
in class Layer1ApiUpstreamRelay
public void onMboCancel(java.lang.String alias, java.lang.String orderId)
onMboCancel
in interface Layer1ApiMboDataListener
onMboCancel
in class Layer1ApiUpstreamRelay
public void onMarketMode(java.lang.String alias, MarketMode marketMode)
Layer1ApiDataListener
onMarketMode
in interface Layer1ApiDataListener
onMarketMode
in class Layer1ApiUpstreamRelay
public void onOrderUpdated(OrderInfoUpdate orderInfoUpdate)
Layer1ApiTradingListener
onOrderUpdated
in interface Layer1ApiTradingListener
onOrderUpdated
in class Layer1ApiUpstreamRelay
orderInfoUpdate
- information about updatepublic void onOrderExecuted(ExecutionInfo executionInfo)
Layer1ApiTradingListener
onOrderExecuted
in interface Layer1ApiTradingListener
onOrderExecuted
in class Layer1ApiUpstreamRelay
executionInfo
- information about executionpublic void onStatus(StatusInfo statusInfo)
Layer1ApiTradingListener
onStatus
in interface Layer1ApiTradingListener
onStatus
in class Layer1ApiUpstreamRelay
statusInfo
- status informationpublic void onBalance(BalanceInfo balanceInfo)
Layer1ApiTradingListener
onBalance
in interface Layer1ApiTradingListener
onBalance
in class Layer1ApiUpstreamRelay
balanceInfo
- account balance informationpublic void onLoginFailed(LoginFailedReason reason, java.lang.String message)
Layer1ApiAdminListener
onLoginFailed
in interface Layer1ApiAdminListener
onLoginFailed
in class Layer1ApiUpstreamRelay
reason
- reason codemessage
- test message associated with login fail (may be null)public void onLoginSuccessful()
Layer1ApiAdminListener
onLoginSuccessful
in interface Layer1ApiAdminListener
onLoginSuccessful
in class Layer1ApiUpstreamRelay
public void onConnectionLost(DisconnectionReason reason, java.lang.String message)
Layer1ApiAdminListener
onConnectionLost
in interface Layer1ApiAdminListener
onConnectionLost
in class Layer1ApiUpstreamRelay
reason
- reason codemessage
- test message associated with login disconnection (may be null)public void onConnectionRestored()
Layer1ApiAdminListener
onConnectionRestored
in interface Layer1ApiAdminListener
onConnectionRestored
in class Layer1ApiUpstreamRelay
public void onSystemTextMessage(java.lang.String message, SystemTextMessageType messageType)
Layer1ApiAdminListener
onSystemTextMessage
in interface Layer1ApiAdminListener
onSystemTextMessage
in class Layer1ApiUpstreamRelay
message
- message itselfmessageType
- message typepublic void onUserMessage(java.lang.Object data)
Layer1ApiAdminListener
onUserMessage
in interface Layer1ApiAdminListener
onUserMessage
in class Layer1ApiUpstreamRelay
data
- Message content