Class ExsimFeedModule
- java.lang.Object
-
- org.marketcetera.module.Module
-
- org.marketcetera.marketdata.exsim.ExsimFeedModule
-
- All Implemented Interfaces:
MarketDataModuleMXBean,DataEmitter
public class ExsimFeedModule extends Module implements DataEmitter, MarketDataModuleMXBean
Supplies market data from the Marketcetera Exchange Simulator.- Since:
- $Release$
- Version:
- $Id$
- Author:
- Colin DuPlantis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classExsimFeedModule.AbstractRequestDataProvides common behavior for data flow requests.private static classExsimFeedModule.FeedStatusRequestDataHolds data relevant to a feed status request as part of a module data flow.private classExsimFeedModule.FixApplicationProvides an API to the FIX connection to the exchange simulator.private classExsimFeedModule.FixMessageProcessorProcess incoming FIX messages received from the exchange simulator.private static classExsimFeedModule.MarketDataRequestDataHolds data relevant to a market data request as part of a module data flow.private static classExsimFeedModule.MessageWrapperContains a received message and meta information about that message.private static classExsimFeedModule.OrderBookKeyServes as the unique key for a cached order book.
-
Field Summary
Fields Modifier and Type Field Description private ExsimFeedModule.FixApplicationapplicationmanages the FIX connection to the exchangeprivate ExsimFeedConfigexsimFeedConfigconfiguration used to connect to the exchangeprivate longfeedAvailableTimeoutnumber of milliseconds to wait for the feed to become available if a request is made while it is offlineprivate FeedStatusfeedStatuscurrent status of the feedprivate com.google.common.cache.Cache<DataFlowID,ExsimFeedModule.FeedStatusRequestData>feedStatusRequestDataByDataFlowIdholds feed status requests by data flow idprivate ExsimFeedModule.FixMessageProcessorfixMessageProcessorprocesses incoming FIX messagesprivate AtomicLongidCounterused to assign unique event idsprivate MarketDataServicemarketDataServiceprovides access to market data servicesprivate FIXMessageFactorymessageFactorymessage factory for the specified FIX versionprivate com.google.common.cache.LoadingCache<ExsimFeedModule.OrderBookKey,OrderBook>orderBooksByInstrumentevent order books keyed by instrumentprivate Map<DataFlowID,ExsimFeedModule.MarketDataRequestData>requestsByDataFlowIdholds market data request info by data flow idprivate Map<String,ExsimFeedModule.MarketDataRequestData>requestsByRequestIdholds data request info keyed by request idprivate quickfix.SessionIDsessionIdsession ID value that the module will use to connectprivate quickfix.SocketInitiatorsocketInitiatorhandles physical connection to the simulated exchangeprivate static Set<AssetClass>supportedAssetClassessupported asset classes for this providerprivate static Set<Capability>supportedCapabilitiessupported capabilities for this providerprivate SymbolResolverServicesymbolResolverServiceresolves symbols to instruments
-
Constructor Summary
Constructors Modifier Constructor Description protectedExsimFeedModule(ModuleURN inInstanceUrn)Create a new ExsimFeedModule instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel(DataFlowID inFlowId, RequestID inRequestID)private voidcancelMarketDataRequest(ExsimFeedModule.MarketDataRequestData inMarketDataRequestData)Cancel the market data request with the given id.voiddisconnect()private voiddoFeedStatusRequest(FeedStatusRequest inPayload, DataRequest inRequest, DataEmitterSupport inSupport)Execute a feed status request with the given attributes.private voiddoMarketDataRequest(MarketDataRequest inPayload, DataRequest inRequest, DataEmitterSupport inSupport)Perform the market data requestprivate longgetAskIdFor(OrderBook inOrderbook, int inLevel)Get the message id used for the event at the given level of the ask book.Set<AssetClass>getAssetClasses()private longgetBidIdFor(OrderBook inOrderbook, int inLevel)Get the message id used for the event at the given level of the bid book.Set<Capability>getCapabilities()private List<Event>getEvents(ExsimFeedModule.MessageWrapper inMessageWrapper, boolean inIsSnapshot)Get the market data events from the given message.StringgetFeedStatus()private OrderBookgetOrderBookFor(Instrument inInstrument, String inRequestId, String inExchange)Get the order book for the given instrument.protected voidpreStart()protected voidpreStop()private voidpublishEvents(Deque<Event> inEvents, String inRequestId)Publish the given events to the data flow associated with the given id.voidreconnect()voidrequestData(DataRequest inRequest, DataEmitterSupport inSupport)private voidupdateFeedStatus(FeedStatus inNewStatus)Update the feed status to the new given value.-
Methods inherited from class org.marketcetera.module.Module
getCreated, getLastStartFailure, getLastStopFailure, getStarted, getState, getStopped, getURN, isAutoCreated, isAutoStart
-
-
-
-
Field Detail
-
fixMessageProcessor
private ExsimFeedModule.FixMessageProcessor fixMessageProcessor
processes incoming FIX messages
-
sessionId
private quickfix.SessionID sessionId
session ID value that the module will use to connect
-
socketInitiator
private quickfix.SocketInitiator socketInitiator
handles physical connection to the simulated exchange
-
messageFactory
private FIXMessageFactory messageFactory
message factory for the specified FIX version
-
application
private ExsimFeedModule.FixApplication application
manages the FIX connection to the exchange
-
exsimFeedConfig
@Autowired private ExsimFeedConfig exsimFeedConfig
configuration used to connect to the exchange
-
symbolResolverService
@Autowired private SymbolResolverService symbolResolverService
resolves symbols to instruments
-
marketDataService
@Autowired private MarketDataService marketDataService
provides access to market data services
-
feedAvailableTimeout
private long feedAvailableTimeout
number of milliseconds to wait for the feed to become available if a request is made while it is offline
-
feedStatus
private volatile FeedStatus feedStatus
current status of the feed
-
feedStatusRequestDataByDataFlowId
private final com.google.common.cache.Cache<DataFlowID,ExsimFeedModule.FeedStatusRequestData> feedStatusRequestDataByDataFlowId
holds feed status requests by data flow id
-
orderBooksByInstrument
private final com.google.common.cache.LoadingCache<ExsimFeedModule.OrderBookKey,OrderBook> orderBooksByInstrument
event order books keyed by instrument
-
idCounter
private final AtomicLong idCounter
used to assign unique event ids
-
requestsByRequestId
private final Map<String,ExsimFeedModule.MarketDataRequestData> requestsByRequestId
holds data request info keyed by request id
-
requestsByDataFlowId
private final Map<DataFlowID,ExsimFeedModule.MarketDataRequestData> requestsByDataFlowId
holds market data request info by data flow id
-
supportedAssetClasses
private static final Set<AssetClass> supportedAssetClasses
supported asset classes for this provider
-
supportedCapabilities
private static final Set<Capability> supportedCapabilities
supported capabilities for this provider
-
-
Constructor Detail
-
ExsimFeedModule
protected ExsimFeedModule(ModuleURN inInstanceUrn)
Create a new ExsimFeedModule instance.- Parameters:
inInstanceUrn- aModuleURNvalue
-
-
Method Detail
-
getFeedStatus
public String getFeedStatus()
- Specified by:
getFeedStatusin interfaceMarketDataModuleMXBean
-
reconnect
public void reconnect()
- Specified by:
reconnectin interfaceMarketDataModuleMXBean
-
disconnect
public void disconnect()
- Specified by:
disconnectin interfaceMarketDataModuleMXBean
-
getCapabilities
public Set<Capability> getCapabilities()
- Specified by:
getCapabilitiesin interfaceMarketDataModuleMXBean
-
getAssetClasses
public Set<AssetClass> getAssetClasses()
- Specified by:
getAssetClassesin interfaceMarketDataModuleMXBean
-
requestData
public void requestData(DataRequest inRequest, DataEmitterSupport inSupport) throws RequestDataException
- Specified by:
requestDatain interfaceDataEmitter- Throws:
RequestDataException
-
cancel
public void cancel(DataFlowID inFlowId, RequestID inRequestID)
- Specified by:
cancelin interfaceDataEmitter
-
preStart
protected void preStart() throws ModuleException- Specified by:
preStartin classModule- Throws:
ModuleException
-
preStop
protected void preStop() throws ModuleException- Specified by:
preStopin classModule- Throws:
ModuleException
-
doFeedStatusRequest
private void doFeedStatusRequest(FeedStatusRequest inPayload, DataRequest inRequest, DataEmitterSupport inSupport)
Execute a feed status request with the given attributes.- Parameters:
inPayload- aFeedStatusRequestvalueinRequest- aDataRequestvalueinSupport- aDataEmitterSupportvalue
-
doMarketDataRequest
private void doMarketDataRequest(MarketDataRequest inPayload, DataRequest inRequest, DataEmitterSupport inSupport) throws quickfix.FieldNotFound, quickfix.SessionNotFound
Perform the market data request- Parameters:
inPayload- aMarketDataRequestvalueinRequest- aDataRequestvalueinSupport- aDataEmitterSupportvalue- Throws:
quickfix.FieldNotFound- if the request could not be builtquickfix.SessionNotFound- if the message could not be sent
-
cancelMarketDataRequest
private void cancelMarketDataRequest(ExsimFeedModule.MarketDataRequestData inMarketDataRequestData) throws quickfix.FieldNotFound, quickfix.SessionNotFound
Cancel the market data request with the given id.- Parameters:
inMarketDataRequestData- aStringvalue- Throws:
quickfix.FieldNotFound- if the market data request cancel cannot be constructedquickfix.SessionNotFound- if the cancel message cannot be sent
-
updateFeedStatus
private void updateFeedStatus(FeedStatus inNewStatus)
Update the feed status to the new given value.- Parameters:
inNewStatus- aFeedStatusvalue
-
getOrderBookFor
private OrderBook getOrderBookFor(Instrument inInstrument, String inRequestId, String inExchange)
Get the order book for the given instrument.- Parameters:
inInstrument- anInstrumentvalueinRequestId- aStringvalueinExchange- aStringvalue- Returns:
- an
OrderBookvalue
-
getEvents
private List<Event> getEvents(ExsimFeedModule.MessageWrapper inMessageWrapper, boolean inIsSnapshot) throws quickfix.FieldNotFound
Get the market data events from the given message.- Parameters:
inMessageWrapper- aMessageWrappervalueinIsSnapshot- abooleanvlue- Returns:
- a
List<Event>value containing the constructed events - Throws:
quickfix.FieldNotFound- if an expected field cannot be found
-
getAskIdFor
private long getAskIdFor(OrderBook inOrderbook, int inLevel)
Get the message id used for the event at the given level of the ask book.- Parameters:
inOrderbook- anOrderBookvalueinLevel- anintvalue- Returns:
- a
longvalue
-
getBidIdFor
private long getBidIdFor(OrderBook inOrderbook, int inLevel)
Get the message id used for the event at the given level of the bid book.- Parameters:
inOrderbook- anOrderBookvalueinLevel- anintvalue- Returns:
- a
longvalue
-
-