Market Data request handling

Market Data request handling allows the acceptor (the exchange) to register the request from an initiator who's willing to trade a given symbol. Once this request is received, the acceptor starts streaming the price updates to the initiator. Let's have a look at the following code:

def onMarketDataRequest(self, message, sessionID):
requestID = quickfix.MDReqID()
try:
message.getField(requestID)
except Exception as e:
raise quickfix.IncorrectTagValue(requestID)

try:
relatedSym = self.fixVersion.MarketDataRequest.NoRelatedSym()
symbolFix = quickfix.Symbol()
product = quickfix.Product()
message.getGroup(1, relatedSym)
relatedSym.getField(symbolFix)
relatedSym.getField(product)
if product.getValue() != quickfix.Product_CURRENCY:
self.sendMarketDataReject(requestID, " product.getValue() != quickfix.Product_CURRENCY:", sessionID)
return

# bid
entryType = self.fixVersion.MarketDataRequest.NoMDEntryTypes()
message.getGroup(1, entryType)

# ask
message.getGroup(2, entryType)

symbol = symbolFix.getValue()
subscription = self.subscriptions.get(symbol)
if subscription is None:
self.sendMarketDataReject(requestID, "Unknown symbol: %s" % str(symbol), sessionID)
return

subscription.addSession(sessionID)
except Exception as e:
print e,e.args
self.sendMarketDataReject(requestID, str(e), sessionID)

As shown in the preceding code, the onMarketDataRequest callback that's handling the market data request does the following:

  • Gets the request ID: The exchange will check whether the request ID has not already been processed.
  • Gets the symbol ID: The symbol updates that are linked to this symbol will be sent to the initiator.
  • Gets the product: The exchange checks whether the product that was requested is in the system. If the product isn't, a rejection message will be sent to the initiator.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.140.151