public class ClientImpl extends Object implements Client, ExceptionListener
| Modifier and Type | Class and Description |
|---|---|
class |
ClientImpl.BrokerStatusReceiver |
class |
ClientImpl.TradeMessageReceiver |
| Modifier and Type | Field and Description |
|---|---|
protected ClientParameters |
mParameters |
| Constructor and Description |
|---|
ClientImpl(ClientParameters inParameters)
Creates an instance given the parameters and connects to the server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBrokerStatusListener(BrokerStatusListener listener)
Adds a broker status listener, which receives all the
broker status changes sent out by the server.
|
void |
addExceptionListener(ExceptionListener inListener)
Adds an exception listener.
|
void |
addReport(FIXMessageWrapper inReport,
BrokerID inBrokerID,
Hierarchy inHierarchy)
Adds the given report to the system data flow.
|
void |
addReportListener(ReportListener inListener)
Adds a report listener.
|
void |
addServerStatusListener(ServerStatusListener listener)
Adds a server connection status listener, which receives all
the server connection status changes.
|
void |
close()
Closes the connection to the server.
|
protected void |
closeWebServices()
Closes the web service.
|
protected void |
connectJms()
Connects the JMS service.
|
protected void |
connectWebServices()
Connects the web services.
|
void |
deleteReport(ExecutionReportImpl inReport)
Removes the given report from the persistent report store.
|
OrderID |
findRootOrderIdFor(OrderID inOrderID)
Find the root order ID for the order chain of the given order ID.
|
Map<PositionKey<Currency>,BigDecimal> |
getAllCurrencyPositionsAsOf(Date inDate)
Returns all open currency positions based on reports,
generated and received on or before the supplied date in UTC.
|
Map<PositionKey<Equity>,BigDecimal> |
getAllEquityPositionsAsOf(Date inDate)
Returns all open equity positions based on reports,
generated and received on or before the supplied date in UTC.
|
Map<PositionKey<Future>,BigDecimal> |
getAllFuturePositionsAsOf(Date inDate)
Returns all open future positions based on reports,
generated and received on or before the supplied date in UTC.
|
Map<PositionKey<Option>,BigDecimal> |
getAllOptionPositionsAsOf(Date inDate)
Returns the aggregate position of each option (option,account,actor)
tuple based on all reports received for each option instrument on or before
the supplied date in UTC and which are visible to the given user.
|
BrokersStatus |
getBrokersStatus()
Returns the server's broker status.
|
BigDecimal |
getCurrencyPositionAsOf(Date inDate,
Currency inCurrency)
Returns the position of the supplied currency based on reports,
generated and received on or before the supplied date in UTC.
|
BigDecimal |
getEquityPositionAsOf(Date inDate,
Equity inEquity)
Returns the position of the supplied equity based on reports,
generated and received on or before the supplied date in UTC.
|
BigDecimal |
getFuturePositionAsOf(Date inDate,
Future inFuture)
Returns the position of the supplied future based on reports,
generated and received on or before the supplied date in UTC.
|
Date |
getLastConnectTime()
Returns the last time the client was successfully connected
or reconnected to the server.
|
protected String |
getNextServerID()
Fetches the next orderID base from server.
|
List<ReportBaseImpl> |
getOpenOrders()
Gets all open orders visible to the current user.
|
BigDecimal |
getOptionPositionAsOf(Date inDate,
Option inOption)
Gets the current aggregate position for the option instrument based on
execution reports received on or before the supplied date in UTC, and which
are visible to the given user.
|
Map<PositionKey<Option>,BigDecimal> |
getOptionPositionsAsOf(Date inDate,
String... inSymbols)
Returns the aggregate position of each option
(option,account,actor)
tuple based on all reports received for each option instrument on or before
the supplied date in UTC, and which are visible to the given user.
|
Collection<String> |
getOptionRoots(String inUnderlying)
Returns the collection of known option roots for the underlying symbol.
|
ClientParameters |
getParameters()
Returns the parameters that client is using to connect to the server.
|
ReportBase[] |
getReportsSince(Date inDate)
Returns all the reports (execution report and order cancel rejects)
generated and received by the server since the supplied date in UTC.
|
protected SessionId |
getSessionId()
Gets the session ID value.
|
String |
getUnderlying(String inOptionRoot)
Returns the underlying symbol for the supplied option root, if
a mapping is found for it.
|
Properties |
getUserData()
Gets the user data associated with the current user.
|
UserInfo |
getUserInfo(UserID id,
boolean useCache)
Returns the information of the user with the given ID.
|
protected void |
heartbeat()
Executes a heartbeat.
|
boolean |
isCredentialsMatch(String inUsername,
char[] inPassword)
Returns true if the supplied user name, password match the
credentials used to connect to the server.
|
boolean |
isServerAlive()
Returns true if client has a live connection to the server.
|
void |
onException(JMSException e) |
void |
reconnect()
Disconnects the connection to the server and reconnects back
using the same properties as were supplied when creating this
instance.
|
void |
reconnect(ClientParameters inParameters)
Disconnects the connection to the server and reconnects back
using the properties supplied to this method.
|
protected void |
reconnectWebServices()
Reconnects the web service.
|
void |
removeBrokerStatusListener(BrokerStatusListener listener)
Removes a broker status listener that was previously added
via
Client.addBrokerStatusListener(BrokerStatusListener). |
void |
removeExceptionListener(ExceptionListener inListener)
Removes exception listener that was previously added via
Client.addExceptionListener(java.beans.ExceptionListener). |
void |
removeReportListener(ReportListener inListener)
Removes a report listener that was previously added via
Client.addReportListener(ReportListener). |
void |
removeServerStatusListener(ServerStatusListener listener)
Removes a server connection status listener that was previously
added via
Client.addServerStatusListener(ServerStatusListener). |
Instrument |
resolveSymbol(String inSymbol)
Resolves the given symbol to an
Instrument. |
void |
sendOrder(OrderCancel inOrderCancel)
Sends the supplied order to the server.
|
void |
sendOrder(OrderReplace inOrderReplace)
Sends the supplied order to the server.
|
void |
sendOrder(OrderSingle inOrderSingle)
Sends the supplied order to the server.
|
void |
sendOrderRaw(FIXOrder inFIXOrder)
Sends the supplied FIX Message Order to the server.
|
void |
setUserData(Properties inProperties)
Sets the user data associated with the current user.
|
protected void |
startJms()
Starts the JMS connection.
|
protected volatile ClientParameters mParameters
public ClientImpl(ClientParameters inParameters) throws ConnectionException
inParameters - the parameters to connect to the server, cannot
be null.ConnectionException - if there were errors connecting
to the server.public void sendOrder(OrderSingle inOrderSingle) throws ConnectionException, OrderValidationException
ClientsendOrder in interface ClientinOrderSingle - The order to send.ConnectionException - if there were connection errors sending
the order out to the server.OrderValidationException - if the order didn't have complete
or consistent data to be sent to the server.public void sendOrder(OrderReplace inOrderReplace) throws ConnectionException, OrderValidationException
ClientsendOrder in interface ClientinOrderReplace - The order to send.ConnectionException - if there were connection errors sending
the order out to the server.OrderValidationException - if the orders didn't have complete
or consistent data to be sent to the server.public void sendOrder(OrderCancel inOrderCancel) throws ConnectionException, OrderValidationException
ClientsendOrder in interface ClientinOrderCancel - The order to send.ConnectionException - if there were connection errors sending
the order out to the server.OrderValidationException - if the orders didn't have complete
or consistent data to be sent to the server.public void sendOrderRaw(FIXOrder inFIXOrder) throws ConnectionException, OrderValidationException
ClientWhen supplying raw FIX Message, a brokerID has to be supplied
sendOrderRaw in interface ClientinFIXOrder - the raw FIX Order to send.ConnectionException - if there were connection errors sending
the order to the server.OrderValidationException - if the supplied message was not of a
type that's supported by the system.public void addReportListener(ReportListener inListener)
ClientIf the same listener is added more than once, it will receive notifications as many times as it's been added.
The listeners are notified in the reverse order of their addition.
addReportListener in interface ClientinListener - The listener instance that should be supplied
the reports.public void removeReportListener(ReportListener inListener)
ClientClient.addReportListener(ReportListener). If the listener
was added more than once, only its most recently added occurrence
will be removed.removeReportListener in interface ClientinListener - The listener instance that should no longer
be receiving the reports.public void addBrokerStatusListener(BrokerStatusListener listener)
ClientIf the same listener is added more than once, it will receive notifications as many times as it has been added.
The listeners are notified in the reverse order of their addition.
addBrokerStatusListener in interface Clientlistener - The listener which should be supplied the
broker status changes.public void removeBrokerStatusListener(BrokerStatusListener listener)
ClientClient.addBrokerStatusListener(BrokerStatusListener).
If the listener was added more than once, only its most recently added instance will be removed.
removeBrokerStatusListener in interface Clientlistener - The listener which should stop receiving
broker status changes.public void addServerStatusListener(ServerStatusListener listener)
ClientIf the same listener is added more than once, it will receive notifications as many times as it has been added.
The listeners are notified in the reverse order of their addition.
addServerStatusListener in interface Clientlistener - The listener which should be supplied the
server connection status changes.public void removeServerStatusListener(ServerStatusListener listener)
ClientClient.addServerStatusListener(ServerStatusListener).
If the listener was added more than once, only its most recently added instance will be removed.
removeServerStatusListener in interface Clientlistener - The listener which should stop receiving server
connection status changes.public ReportBase[] getReportsSince(Date inDate) throws ConnectionException
ClientgetReportsSince in interface ClientinDate - The date in UTC. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public BigDecimal getEquityPositionAsOf(Date inDate, Equity inEquity) throws ConnectionException
ClientgetEquityPositionAsOf in interface ClientinDate - the date in UTC. Cannot be null.inEquity - The equity. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public Map<PositionKey<Equity>,BigDecimal> getAllEquityPositionsAsOf(Date inDate) throws ConnectionException
ClientgetAllEquityPositionsAsOf in interface ClientinDate - the date in UTC. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public BigDecimal getCurrencyPositionAsOf(Date inDate, Currency inCurrency) throws ConnectionException
ClientgetCurrencyPositionAsOf in interface ClientinDate - the date in UTC. Cannot be null.inCurrency - The currency. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public Map<PositionKey<Currency>,BigDecimal> getAllCurrencyPositionsAsOf(Date inDate) throws ConnectionException
ClientgetAllCurrencyPositionsAsOf in interface ClientinDate - the date in UTC. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public Map<PositionKey<Future>,BigDecimal> getAllFuturePositionsAsOf(Date inDate) throws ConnectionException
ClientgetAllFuturePositionsAsOf in interface ClientinDate - the date in UTC. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public BigDecimal getFuturePositionAsOf(Date inDate, Future inFuture) throws ConnectionException
ClientgetFuturePositionAsOf in interface ClientinDate - the date in UTC. Cannot be null.inFuture - The future. Cannot be null.ConnectionException - if there were connection errors fetching
data from the server.public BigDecimal getOptionPositionAsOf(Date inDate, Option inOption) throws ConnectionException
ClientBuy trades result in positive positions. All other kinds of trades result in negative positions.
getOptionPositionAsOf in interface ClientinDate - the date in UTC. Cannot be null.inOption - the option instrumentConnectionException - if there were errors retrieving the
position.public Map<PositionKey<Option>,BigDecimal> getAllOptionPositionsAsOf(Date inDate) throws ConnectionException
ClientBuy trades result in positive positions. All other kinds of trades result in negative positions.
getAllOptionPositionsAsOf in interface ClientinDate - the date in UTC. Cannot be null.ConnectionException - if there were errors retrieving the
position map.public Map<PositionKey<Option>,BigDecimal> getOptionPositionsAsOf(Date inDate, String... inSymbols) throws ConnectionException
ClientBuy trades result in positive positions. All other kinds of trades result in negative positions.
getOptionPositionsAsOf in interface ClientinDate - the date in UTC. Cannot be null.inSymbols - the list of option root symbols.ConnectionException - if there were errors retrieving the
position map.public String getUnderlying(String inOptionRoot) throws ConnectionException
Client
The mapping is retrieved from the server the first time an
option root symbol is specified. The value returned by the server is
cached on the client for all subsequent invocations for the
same root symbol. All the cached values are cleared when the client
is closed.
getUnderlying in interface ClientinOptionRoot - The option root symbol.ConnectionException - if there were errors retrieving the
underlying symbol.public Collection<String> getOptionRoots(String inUnderlying) throws ConnectionException
Client
The mapping is retrieved from the server the first time an
underlying symbol is specified. The value returned by the server is
cached on the client for all subsequent invocations for the
same underlying symbol. All the cached values are cleared when the client
is closed.
getOptionRoots in interface ClientinUnderlying - The underlying symbol.ConnectionException - if there were errors retrieving the
option roots.public BrokersStatus getBrokersStatus() throws ConnectionException
ClientgetBrokersStatus in interface ClientConnectionException - Thrown if the operation cannot be
completed.public UserInfo getUserInfo(UserID id, boolean useCache) throws ConnectionException
Client
All cached values are cleared when the client is closed.
getUserInfo in interface Clientid - The user ID.useCache - True if the local cache should be used.ConnectionException - Thrown if the operation cannot be
completed.public void addReport(FIXMessageWrapper inReport, BrokerID inBrokerID, Hierarchy inHierarchy) throws ConnectionException
ClientReports added this way will be added to the system data bus. Reports will be persisted and become part of the system record. All clients will receive this report.
This will affect reported positions
.addReport in interface ClientinReport - a FIXMessageWrapper valueinBrokerID - a BrokerID valueinHierarchy - a Hierarchy valueConnectionException - if an error occurs connecting to the serverpublic void deleteReport(ExecutionReportImpl inReport) throws ConnectionException
ClientReports removed this way will not be added to the system data bus and no clients will receive this report.
This will affect reported positions
.deleteReport in interface ClientinReport - an ExecutionReportImpl valueConnectionException - if an error occurs connecting to the serverpublic void close()
Clientpublic void reconnect()
throws ConnectionException
Clientreconnect in interface ClientConnectionException - if there were errors reconnecting.public void reconnect(ClientParameters inParameters) throws ConnectionException
Clientreconnect in interface ClientinParameters - The parameters to use when reconnecting to the
server. These parameters are stored so that subsequent invocations
of Client.reconnect() will use these parameters instead of the
ones that were supplied when creating this instance.ConnectionException - if there were errors reconnecting.public void addExceptionListener(ExceptionListener inListener)
Client
The listeners are notified only when connectivity issues are
encountered when sending or receiving messages, ie. when any of
the send*() methods are invoked, or when the
client receives a message and encounters errors processing it
before delivering it to ReportListener or BrokerStatusListener, or when client heartbeats cannot reach
the server.
If the same listener is added more than once, it will receive notifications as many times as it's been added.
The listeners are notified in the reverse order of their addition.
addExceptionListener in interface ClientinListener - the listener instance.public void removeExceptionListener(ExceptionListener inListener)
ClientClient.addExceptionListener(java.beans.ExceptionListener). The
listener will stop receiving exception notifications after this
method returns.
If the listener was added more than once, only its most
recently added occurrence will be removed.removeExceptionListener in interface ClientinListener - The exception listener that should no longerpublic ClientParameters getParameters()
ClientgetParameters in interface Clientpublic Date getLastConnectTime()
ClientgetLastConnectTime in interface Clientpublic boolean isCredentialsMatch(String inUsername, char[] inPassword)
ClientThis method returns false if the client is not connected to the server.
isCredentialsMatch in interface ClientinUsername - the usernameinPassword - the passwordpublic boolean isServerAlive()
ClientisServerAlive in interface Clientpublic Properties getUserData() throws ConnectionException
ClientgetUserData in interface ClientProperties valueConnectionException - if an error occurs connecting to the serverpublic void setUserData(Properties inProperties) throws ConnectionException
ClientsetUserData in interface ClientinProperties - a Properties valueConnectionException - if an error occurs connecting to the serverpublic Instrument resolveSymbol(String inSymbol) throws ConnectionException
ClientInstrument.resolveSymbol in interface ClientinSymbol - a String valueInstrument valueConnectionException - if an error occurs connecting to the serverpublic List<ReportBaseImpl> getOpenOrders() throws ConnectionException
ClientgetOpenOrders in interface ClientList<ReportBaseImpl> valueConnectionException - if an error occurs connecting to the serverpublic OrderID findRootOrderIdFor(OrderID inOrderID)
ClientfindRootOrderIdFor in interface ClientinOrderID - an OrderID valueOrderID valuepublic void onException(JMSException e)
onException in interface ExceptionListenerprotected String getNextServerID() throws RemoteException
RemoteException - if there were communication errors.protected void connectWebServices()
throws I18NException,
RemoteException
I18NException - if an error occurs connectingRemoteException - if an error occurs connectingprotected void closeWebServices()
throws RemoteException
RemoteException - if an error occurs closingprotected void reconnectWebServices()
throws RemoteException
RemoteException - if an error occurs reconnectingprotected void connectJms()
throws JAXBException
JAXBException - if an error occurs connecting to the JMS serviceprotected void heartbeat()
throws RemoteException
RemoteException - if the heartbeat cannot be executedprotected SessionId getSessionId()
SessionId valueprotected void startJms()
throws JAXBException
JAXBException - if an error occurs starting the JMS connectionCopyright © 2015. All Rights Reserved.