Package org.marketcetera.trading.rpc
Class TradeRpcClient
- java.lang.Object
-
- org.marketcetera.rpc.client.AbstractRpcClient<TradeRpcServiceGrpc.TradeRpcServiceBlockingStub,TradeRpcServiceGrpc.TradeRpcServiceStub,TradeRpcClientParameters>
-
- org.marketcetera.trading.rpc.TradeRpcClient
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BaseClient,RpcClient,TradeClient,TradeMessagePublisher
public class TradeRpcClient extends AbstractRpcClient<TradeRpcServiceGrpc.TradeRpcServiceBlockingStub,TradeRpcServiceGrpc.TradeRpcServiceStub,TradeRpcClientParameters> implements TradeClient
Provides an RPCTradeClientimplementation.- Since:
- $Release$
- Version:
- $Id$
- Author:
- Colin DuPlantis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classTradeRpcClient.SuggestionListenerProxyProvides an interface between suggestion stream listeners and their handlers.private static classTradeRpcClient.TradeMessageListenerProxyProvides an interface between trade message stream listeners and their handlers.
-
Field Summary
Fields Modifier and Type Field Description private org.marketcetera.fix.MutableActiveFixSessionFactoryactiveFixSessionFactorycreatesActiveFixSessionobjectsprivate static org.marketcetera.util.ws.tags.AppIdAPP_IDThe client's application ID: the ID.private static StringAPP_ID_NAMEThe client's application ID: the application name.private static VersionInfoAPP_ID_VERSIONThe client's application ID: the version.private AverageFillPriceFactoryaverageFillPriceFactorycreatesAverageFillPriceobjectsprivate org.marketcetera.cluster.ClusterDataFactoryclusterDataFactorycreatesClusterDataobjectsprivate MutableExecutionReportSummaryFactoryexecutionReportSummaryFactorycreatesMutableExecutionReportSummaryobjectsprivate org.marketcetera.fix.MutableFixSessionFactoryfixSessionFactorycreatesFixSessionobjectsprivate com.google.common.cache.LoadingCache<Object,BaseRpcUtil.AbstractClientListenerProxy<?,?,?>>listenerProxiesholds listener proxies keyed by the listenerprivate com.google.common.cache.Cache<String,BaseRpcUtil.AbstractClientListenerProxy<?,?,?>>listenerProxiesByIdholds report listeners by their idprivate MutableOrderSummaryFactoryorderSummaryFactorycreatesMutableOrderSummaryobjectsprivate MutableReportFactoryreportFactorycreatesMutableReportobjectsprivate com.google.common.cache.Cache<OrderID,OrderID>rootOrderIdCacheroot order ID cacheprivate com.google.common.cache.Cache<String,Instrument>symbolCachesymbol to instrument cacheprivate org.marketcetera.admin.UserFactoryuserFactorycreatesUserobjects
-
Constructor Summary
Constructors Constructor Description TradeRpcClient(TradeRpcClientParameters inParameters)Create a new TradeRpcClient instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddReport(HasFIXMessage inReport, BrokerID inBrokerID)voidaddSuggestionListener(SuggestionListener inSuggestionListener)voidaddTradeMessageListener(TradeMessageListener inTradeMessageListener)voiddeleteReport(ReportID inReportId)protected BaseRpc.HeartbeatResponseexecuteHeartbeat(BaseRpc.HeartbeatRequest inRequest)protected BaseRpc.LoginResponseexecuteLogin(BaseRpc.LoginRequest inRequest)protected BaseRpc.LogoutResponseexecuteLogout(BaseRpc.LogoutRequest inRequest)OrderIDfindRootOrderIdFor(OrderID inOrderId)org.marketcetera.fix.MutableActiveFixSessionFactorygetActiveFixSessionFactory()Get the activeFixSessionFactory value.Map<PositionKey<? extends Instrument>,BigDecimal>getAllPositionsAsOf(Date inDate)protected org.marketcetera.util.ws.tags.AppIdgetAppId()protected TradeRpcServiceGrpc.TradeRpcServiceStubgetAsyncStub(io.grpc.Channel inChannel)AverageFillPriceFactorygetAverageFillPriceFactory()Get the averageFillPriceFactory value.CollectionPageResponse<AverageFillPrice>getAveragePriceFills(PageRequest inPageRequest)protected TradeRpcServiceGrpc.TradeRpcServiceBlockingStubgetBlockingStub(io.grpc.Channel inChannel)org.marketcetera.cluster.ClusterDataFactorygetClusterDataFactory()Get the clusterDataFactory value.MutableExecutionReportSummaryFactorygetExecutionReportSummaryFactory()Get the executionReportSummaryFactory value.CollectionPageResponse<ExecutionReportSummary>getFills(PageRequest inPageRequest)org.marketcetera.fix.MutableFixSessionFactorygetFixSessionFactory()Get the fixSessionFactory value.ExecutionReportgetLatestExecutionReportForOrderChain(OrderID inOrderId)private static BaseRpcUtil.AbstractClientListenerProxy<?,?,?>getListenerFor(Object inListener)Creates the appropriate proxy for the given listener.Collection<OrderSummary>getOpenOrders()CollectionPageResponse<OrderSummary>getOpenOrders(PageRequest inPageRequest)Map<PositionKey<Option>,BigDecimal>getOptionPositionsAsOf(Date inDate, String... inRootSymbols)Collection<String>getOptionRoots(String inUnderlying)MutableOrderSummaryFactorygetOrderSummaryFactory()Get the orderSummaryFactory value.BigDecimalgetPositionAsOf(Date inDate, Instrument inInstrument)MutableReportFactorygetReportFactory()Get the reportFactory value.CollectionPageResponse<Report>getReports(PageRequest inPageRequest)StringgetUnderlying(String inOptionRoot)org.marketcetera.admin.UserFactorygetUserFactory()Get the userFactory value.protected VersionInfogetVersionInfo()List<org.marketcetera.fix.ActiveFixSession>readAvailableFixInitiatorSessions()voidremoveSuggestionListener(SuggestionListener inSuggestionListener)voidremoveTradeMessageListener(TradeMessageListener inTradeMessageListener)InstrumentresolveSymbol(String inSymbol)SendOrderResponsesendOrder(Order inOrder)List<SendOrderResponse>sendOrders(List<Order> inOrders)voidsendOrderSuggestion(Suggestion inSuggestion)voidsetActiveFixSessionFactory(org.marketcetera.fix.MutableActiveFixSessionFactory inActiveFixSessionFactory)Sets the activeFixSessionFactory value.voidsetAverageFillPriceFactory(AverageFillPriceFactory inAverageFillPriceFactory)Sets the averageFillPriceFactory value.voidsetClusterDataFactory(org.marketcetera.cluster.ClusterDataFactory inClusterDataFactory)Sets the clusterDataFactory value.voidsetExecutionReportSummaryFactory(MutableExecutionReportSummaryFactory inExecutionReportSummaryFactory)Sets the executionReportSummaryFactory value.voidsetFixSessionFactory(org.marketcetera.fix.MutableFixSessionFactory inFixSessionFactory)Sets the fixSessionFactory value.voidsetOrderSummaryFactory(MutableOrderSummaryFactory inOrderSummaryFactory)Sets the orderSummaryFactory value.voidsetReportFactory(MutableReportFactory inReportFactory)Sets the reportFactory value.voidsetUserFactory(org.marketcetera.admin.UserFactory inUserFactory)Sets the userFactory value.-
Methods inherited from class org.marketcetera.rpc.client.AbstractRpcClient
addClientStatusListener, cancelHeartbeat, executeCall, getAsyncStub, getBlockingStub, getSessionId, isRunning, onHeartbeat, onStatusChange, removeClientStatusListener, scheduleHeartbeat, start, stop
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.marketcetera.core.BaseClient
addClientStatusListener, close, isRunning, removeClientStatusListener, start, stop
-
-
-
-
Field Detail
-
averageFillPriceFactory
private AverageFillPriceFactory averageFillPriceFactory
createsAverageFillPriceobjects
-
executionReportSummaryFactory
private MutableExecutionReportSummaryFactory executionReportSummaryFactory
createsMutableExecutionReportSummaryobjects
-
orderSummaryFactory
private MutableOrderSummaryFactory orderSummaryFactory
createsMutableOrderSummaryobjects
-
userFactory
private org.marketcetera.admin.UserFactory userFactory
createsUserobjects
-
reportFactory
private MutableReportFactory reportFactory
createsMutableReportobjects
-
clusterDataFactory
private org.marketcetera.cluster.ClusterDataFactory clusterDataFactory
createsClusterDataobjects
-
activeFixSessionFactory
private org.marketcetera.fix.MutableActiveFixSessionFactory activeFixSessionFactory
createsActiveFixSessionobjects
-
fixSessionFactory
private org.marketcetera.fix.MutableFixSessionFactory fixSessionFactory
createsFixSessionobjects
-
APP_ID_NAME
private static final String APP_ID_NAME
The client's application ID: the application name.
-
APP_ID_VERSION
private static final VersionInfo APP_ID_VERSION
The client's application ID: the version.
-
APP_ID
private static final org.marketcetera.util.ws.tags.AppId APP_ID
The client's application ID: the ID.
-
symbolCache
private final com.google.common.cache.Cache<String,Instrument> symbolCache
symbol to instrument cache
-
rootOrderIdCache
private final com.google.common.cache.Cache<OrderID,OrderID> rootOrderIdCache
root order ID cache
-
listenerProxiesById
private final com.google.common.cache.Cache<String,BaseRpcUtil.AbstractClientListenerProxy<?,?,?>> listenerProxiesById
holds report listeners by their id
-
listenerProxies
private final com.google.common.cache.LoadingCache<Object,BaseRpcUtil.AbstractClientListenerProxy<?,?,?>> listenerProxies
holds listener proxies keyed by the listener
-
-
Constructor Detail
-
TradeRpcClient
public TradeRpcClient(TradeRpcClientParameters inParameters)
Create a new TradeRpcClient instance.- Parameters:
inParameters- aTradeRpcClientParametersvalue
-
-
Method Detail
-
addTradeMessageListener
public void addTradeMessageListener(TradeMessageListener inTradeMessageListener)
- Specified by:
addTradeMessageListenerin interfaceTradeMessagePublisher
-
removeTradeMessageListener
public void removeTradeMessageListener(TradeMessageListener inTradeMessageListener)
- Specified by:
removeTradeMessageListenerin interfaceTradeMessagePublisher
-
addSuggestionListener
public void addSuggestionListener(SuggestionListener inSuggestionListener)
- Specified by:
addSuggestionListenerin interfaceTradeClient
-
removeSuggestionListener
public void removeSuggestionListener(SuggestionListener inSuggestionListener)
- Specified by:
removeSuggestionListenerin interfaceTradeClient
-
findRootOrderIdFor
public OrderID findRootOrderIdFor(OrderID inOrderId)
- Specified by:
findRootOrderIdForin interfaceTradeClient
-
getPositionAsOf
public BigDecimal getPositionAsOf(Date inDate, Instrument inInstrument)
- Specified by:
getPositionAsOfin interfaceTradeClient
-
getAllPositionsAsOf
public Map<PositionKey<? extends Instrument>,BigDecimal> getAllPositionsAsOf(Date inDate)
- Specified by:
getAllPositionsAsOfin interfaceTradeClient
-
getOptionPositionsAsOf
public Map<PositionKey<Option>,BigDecimal> getOptionPositionsAsOf(Date inDate, String... inRootSymbols)
- Specified by:
getOptionPositionsAsOfin interfaceTradeClient
-
resolveSymbol
public Instrument resolveSymbol(String inSymbol)
- Specified by:
resolveSymbolin interfaceTradeClient
-
getOpenOrders
public CollectionPageResponse<OrderSummary> getOpenOrders(PageRequest inPageRequest)
- Specified by:
getOpenOrdersin interfaceTradeClient
-
getReports
public CollectionPageResponse<Report> getReports(PageRequest inPageRequest)
- Specified by:
getReportsin interfaceTradeClient
-
getFills
public CollectionPageResponse<ExecutionReportSummary> getFills(PageRequest inPageRequest)
- Specified by:
getFillsin interfaceTradeClient
-
getAveragePriceFills
public CollectionPageResponse<AverageFillPrice> getAveragePriceFills(PageRequest inPageRequest)
- Specified by:
getAveragePriceFillsin interfaceTradeClient
-
getOpenOrders
public Collection<OrderSummary> getOpenOrders()
- Specified by:
getOpenOrdersin interfaceTradeClient
-
sendOrder
public SendOrderResponse sendOrder(Order inOrder)
- Specified by:
sendOrderin interfaceTradeClient
-
getLatestExecutionReportForOrderChain
public ExecutionReport getLatestExecutionReportForOrderChain(OrderID inOrderId)
- Specified by:
getLatestExecutionReportForOrderChainin interfaceTradeClient
-
sendOrderSuggestion
public void sendOrderSuggestion(Suggestion inSuggestion)
- Specified by:
sendOrderSuggestionin interfaceTradeClient
-
sendOrders
public List<SendOrderResponse> sendOrders(List<Order> inOrders)
- Specified by:
sendOrdersin interfaceTradeClient
-
addReport
public void addReport(HasFIXMessage inReport, BrokerID inBrokerID)
- Specified by:
addReportin interfaceTradeClient
-
deleteReport
public void deleteReport(ReportID inReportId)
- Specified by:
deleteReportin interfaceTradeClient
-
readAvailableFixInitiatorSessions
public List<org.marketcetera.fix.ActiveFixSession> readAvailableFixInitiatorSessions()
- Specified by:
readAvailableFixInitiatorSessionsin interfaceTradeClient
-
getOptionRoots
public Collection<String> getOptionRoots(String inUnderlying)
- Specified by:
getOptionRootsin interfaceTradeClient
-
getUnderlying
public String getUnderlying(String inOptionRoot)
- Specified by:
getUnderlyingin interfaceTradeClient
-
getClusterDataFactory
public org.marketcetera.cluster.ClusterDataFactory getClusterDataFactory()
Get the clusterDataFactory value.- Returns:
- a
ClusterDataFactoryvalue
-
setClusterDataFactory
public void setClusterDataFactory(org.marketcetera.cluster.ClusterDataFactory inClusterDataFactory)
Sets the clusterDataFactory value.- Parameters:
inClusterDataFactory- aClusterDataFactoryvalue
-
getActiveFixSessionFactory
public org.marketcetera.fix.MutableActiveFixSessionFactory getActiveFixSessionFactory()
Get the activeFixSessionFactory value.- Returns:
- a
MutableActiveFixSessionFactoryvalue
-
setActiveFixSessionFactory
public void setActiveFixSessionFactory(org.marketcetera.fix.MutableActiveFixSessionFactory inActiveFixSessionFactory)
Sets the activeFixSessionFactory value.- Parameters:
inActiveFixSessionFactory- aMutableActiveFixSessionFactoryvalue
-
getFixSessionFactory
public org.marketcetera.fix.MutableFixSessionFactory getFixSessionFactory()
Get the fixSessionFactory value.- Returns:
- a
MutableFixSessionFactoryvalue
-
setFixSessionFactory
public void setFixSessionFactory(org.marketcetera.fix.MutableFixSessionFactory inFixSessionFactory)
Sets the fixSessionFactory value.- Parameters:
inFixSessionFactory- aMutableFixSessionFactoryvalue
-
getOrderSummaryFactory
public MutableOrderSummaryFactory getOrderSummaryFactory()
Get the orderSummaryFactory value.- Returns:
- a
MutableOrderSummaryFactoryvalue
-
setOrderSummaryFactory
public void setOrderSummaryFactory(MutableOrderSummaryFactory inOrderSummaryFactory)
Sets the orderSummaryFactory value.- Parameters:
inOrderSummaryFactory- aMutableOrderSummaryFactoryvalue
-
getUserFactory
public org.marketcetera.admin.UserFactory getUserFactory()
Get the userFactory value.- Returns:
- a
UserFactoryvalue
-
setUserFactory
public void setUserFactory(org.marketcetera.admin.UserFactory inUserFactory)
Sets the userFactory value.- Parameters:
inUserFactory- aUserFactoryvalue
-
getReportFactory
public MutableReportFactory getReportFactory()
Get the reportFactory value.- Returns:
- a
MutableReportFactoryvalue
-
setReportFactory
public void setReportFactory(MutableReportFactory inReportFactory)
Sets the reportFactory value.- Parameters:
inReportFactory- aMutableReportFactoryvalue
-
getExecutionReportSummaryFactory
public MutableExecutionReportSummaryFactory getExecutionReportSummaryFactory()
Get the executionReportSummaryFactory value.- Returns:
- an
MutableExecutionReportSummaryFactoryvalue
-
setExecutionReportSummaryFactory
public void setExecutionReportSummaryFactory(MutableExecutionReportSummaryFactory inExecutionReportSummaryFactory)
Sets the executionReportSummaryFactory value.- Parameters:
inExecutionReportSummaryFactory- anMutableExecutionReportSummaryFactoryvalue
-
getAverageFillPriceFactory
public AverageFillPriceFactory getAverageFillPriceFactory()
Get the averageFillPriceFactory value.- Returns:
- an
AverageFillPriceFactoryvalue
-
setAverageFillPriceFactory
public void setAverageFillPriceFactory(AverageFillPriceFactory inAverageFillPriceFactory)
Sets the averageFillPriceFactory value.- Parameters:
inAverageFillPriceFactory- anAverageFillPriceFactoryvalue
-
getBlockingStub
protected TradeRpcServiceGrpc.TradeRpcServiceBlockingStub getBlockingStub(io.grpc.Channel inChannel)
-
getAsyncStub
protected TradeRpcServiceGrpc.TradeRpcServiceStub getAsyncStub(io.grpc.Channel inChannel)
-
executeLogin
protected BaseRpc.LoginResponse executeLogin(BaseRpc.LoginRequest inRequest)
-
executeLogout
protected BaseRpc.LogoutResponse executeLogout(BaseRpc.LogoutRequest inRequest)
-
executeHeartbeat
protected BaseRpc.HeartbeatResponse executeHeartbeat(BaseRpc.HeartbeatRequest inRequest)
-
getAppId
protected org.marketcetera.util.ws.tags.AppId getAppId()
-
getVersionInfo
protected VersionInfo getVersionInfo()
-
getListenerFor
private static BaseRpcUtil.AbstractClientListenerProxy<?,?,?> getListenerFor(Object inListener)
Creates the appropriate proxy for the given listener.- Parameters:
inListener- anObjectvalue- Returns:
- an
AbstractListenerProxy<?,?,?>value
-
-