def get_quote(self, message, sessionID, security): print "OnMessage %s" % message msgType = fix.MsgType() message.getHeader().getField(msgType) if (msgType.getValue() == "X"): print "MarketDataIncrementalRefresh %s" % message noMDEntries = fix.NoMDEntries() message.getField(noMDEntries) if (noMDEntries.getValue() != 1): print "NoMDEntries in MarketDataIncrementalRefresh is not 1!" return group = fix44.MarketDataIncrementalRefresh.NoMDEntries() message.getGroup(1, group) entryID = fix.MDEntryID()
def onMessage(self, message, sessionID): print("OnMessage %s" % message) msgType = fix.MsgType() message.getHeader().getField(msgType) if (msgType.getValue() == "X"): print("MarketDataIncrementalRefresh %s" % message) noMDEntries = fix.NoMDEntries() message.getField(noMDEntries) if (noMDEntries.getValue() != 1): print("NoMDEntries in MarketDataIncrementalRefresh is not 1!") return group = fix44.MarketDataIncrementalRefresh.NoMDEntries() message.getGroup(1, group) entryID = fix.MDEntryID() group.getField(entryID) action = fix.MDUpdateAction() group.getField(action) actionvalue = action.getValue() # 0=New, 1=Update, 2=Delete) if (actionvalue == '2'): # delete if entryID.getValue() in securities: del securities[entryID.getValue()] return security = SECURITY() security.MDEntryID = entryID.getValue() security.MDUpdateAction = action.getValue() symbol = fix.Symbol() if (group.isSetField(symbol)): group.getField(symbol) security.Symbol = symbol.getValue() entryType = fix.MDEntryType() if (group.isSetField(entryType)): group.getField(entryType) security.MDEntryType = entryType.getValue() price = fix.MDEntryPx() if (group.isSetField(price)): group.getField(price) security.MDEntryPx = price.getValue() size = fix.MDEntrySize() if (group.isSetField(size)): group.getField(size) security.MDEntrySize = size.getValue() qty = fix.MinQty() if (group.isSetField(qty)): group.getField(qty) security.MinQty = qty.getValue() inc = MinInc() if (message.isSetField(inc)): message.getField(inc) security.MinInc = inc.getValue() br = MinBr() if (message.isSetField(br)): message.getField(br) security.MinBR = br.getValue() ytm = YTM() if (message.isSetField(ytm)): message.getField(ytm) security.YTM = ytm.getValue() ytw = YTW() if (message.isSetField(ytw)): message.getField(ytw) security.YTW = ytw.getValue() print(security) securities[entryID.getValue()] = security
def onMessage(self, message, sessionID): # print("OnMessage %s" % message) msgType = fix.MsgType() message.getHeader().getField(msgType) if msgType.getValue() == "X": # print("MarketDataIncrementalRefresh %s" % message) noMDEntries = fix.NoMDEntries() message.getField(noMDEntries) if (noMDEntries.getValue() != 1): # print("NoMDEntries in MarketDataIncrementalRefresh is not 1!") return group = fix44.MarketDataIncrementalRefresh.NoMDEntries() message.getGroup(1, group) entryID = fix.MDEntryID() group.getField(entryID) action = fix.MDUpdateAction() group.getField(action) security = LAST_TRADE() security.MDEntryID = entryID.getValue() security.MDUpdateAction = action.getValue() symbol = fix.Symbol() if (group.isSetField(symbol)): group.getField(symbol) security.Symbol = symbol.getValue() entryType = fix.MDEntryType() if (group.isSetField(entryType)): group.getField(entryType) security.MDEntryType = entryType.getValue() price = fix.MDEntryPx() if (group.isSetField(price)): group.getField(price) security.MDEntryPx = price.getValue() size = fix.MDEntrySize() if (group.isSetField(size)): group.getField(size) security.MDEntrySize = size.getValue() qty = fix.MinQty() if (group.isSetField(qty)): group.getField(qty) security.MinQty = qty.getValue() fire(self.callback, "OnTradeUpdated", **{"trade": security}) if msgType.getValue() == 'W': book = BOOK() Symbol = fix.Symbol() message.getField(Symbol) book.symbol = Symbol.getValue() noMDEntries = fix.NoMDEntries() message.getField(noMDEntries) group = fix44.MarketDataSnapshotFullRefresh.NoMDEntries() MDEntryType = fix.MDEntryType() MDEntryPx = fix.MDEntryPx() MDEntrySize = fix.MDEntrySize() for i in range(1, noMDEntries.getValue()): message.getGroup(i, group) group.getField(MDEntryType) group.getField(MDEntryPx) group.getField(MDEntrySize) if MDEntryType.getValue() == '0': book.bid.append(MDEntryPx.getValue()) book.bid_size.append(MDEntrySize.getValue()) if MDEntryType.getValue() == '1': book.ask.append(MDEntryPx.getValue()) book.ask_size.append(MDEntrySize.getValue()) fire(self.callback, "OnBookUpdated", **{"book": book})