从市场数据增量刷新获取价值时出错

error when get value from marketdataincremental refresh

我的 quickfixj 应用程序出错。首先,我收到这样的错误:

Out of order repeating group members

之后,我将这段文字添加到我的 initiator.config:

ValidateUserDefinedFields=N
ValidateIncomingMessage=N

但现在我的申请中又出现了另一个错误:

quickfix.FieldNotFound: Field was not found in message, field=55
        at quickfix.FieldMap.getField(FieldMap.java:223)
        at quickfix.FieldMap.getString(FieldMap.java:237)
        at com.dxtr.fastmatch.marketdatarequestapps.TestMarketdataRequest.fromApp(TestMarketdataRequest.java:38)
        at quickfix.Session.fromCallback(Session.java:1847)
        at quickfix.Session.verify(Session.java:1791)
        at quickfix.Session.verify(Session.java:1862)
        at quickfix.Session.next(Session.java:1047)
        at quickfix.Session.next(Session.java:1204)
        at quickfix.mina.SingleThreadedEventHandlingStrategy$SessionMessageEvent.processMessage(SingleThreadedEventHandlingStrategy.java:163)
        at quickfix.mina.SingleThreadedEventHandlingStrategy.block(SingleThreadedEventHandlingStrategy.java:113)
        at quickfix.mina.SingleThreadedEventHandlingStrategy.lambda$blockInThread(SingleThreadedEventHandlingStrategy.java:145)
        at quickfix.mina.SingleThreadedEventHandlingStrategy$ThreadAdapter$RunnableWrapper.run(SingleThreadedEventHandlingStrategy.java:267)
        at java.lang.Thread.run(Thread.java:748)

我获取符号值的代码是:

public void fromApp(quickfix.Message message, SessionID sessionID)
            throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
         try {
                String symbol = message.getString(Symbol.FIELD);
                    System.out.println(" FromApp " + message);
                    message.getString(TransactTime.FIELD);
//                  String seqNo = message.getString(MsgSeqNum.FIELD);
                    double bid = message.getDouble(MDEntryPx.FIELD);
                    double ask = message.getDouble(MDEntryPx.FIELD);


//                  System.out.println(seqNo + " " + message);


            } catch (FieldNotFound fieldNotFound) {
                fieldNotFound.printStackTrace();
            }
        }

我也用过这个代码

    public void onMessage (MarketDataIncrementalRefresh message, SessionID sessionID) throws FieldNotFound{
     try
       {
           MDReqID mdreqid = new MDReqID();
           SendingTime sendingtime = new SendingTime();
           NoMDEntries nomdentries = new NoMDEntries();
           quickfix.fix42.MarketDataIncrementalRefresh.NoMDEntries group
               = new quickfix.fix42.MarketDataIncrementalRefresh.NoMDEntries();
           MDUpdateAction mdupdateaction = new MDUpdateAction();
           DeleteReason deletereason = new DeleteReason();
           MDEntryType mdentrytype = new MDEntryType();
           MDEntryID mdentryid = new MDEntryID();
           Symbol symbol = new Symbol();
           MDEntryOriginator mdentryoriginator = new MDEntryOriginator();
           MDEntryPx mdentrypx = new MDEntryPx();
           Currency currency = new Currency();
           MDEntrySize mdentrysize = new MDEntrySize();
           ExpireDate expiredate = new ExpireDate();
           ExpireTime expiretime = new ExpireTime();
           NumberOfOrders numberoforders = new NumberOfOrders();
           MDEntryPositionNo mdentrypositionno = new MDEntryPositionNo();

           message.getField(nomdentries);
           message.getField(sendingtime);

           message.getGroup(1, group);

           int list = nomdentries.getValue();
           for (int i = 0; i < list; i++)
           {
               message.getGroup(i + 1, group);
               group.get(mdupdateaction);
               if (mdupdateaction.getValue() == '2')
                System.out.println("Enter");
               group.get(deletereason);
               group.get(mdentrytype);
               group.get(mdentryid);
               group.get(symbol);
               group.get(mdentryoriginator);
               if (mdupdateaction.getValue() == '0')
                   group.get(mdentrypx);
               group.get(currency);
               if (mdupdateaction.getValue() == '0')
                   group.get(mdentrysize);
           }

           System.out.printf("Got Symbol {0} Price {1}", 
       symbol.getValue(), mdentrypx.getValue());

}catch (Exception ex)
       {
    System.out.println("error" + ex);

}

但我也遇到这样的错误

quickfix.FieldNotFound: Field was not found in message, field=55
        at quickfix.FieldMap.getField(FieldMap.java:223)
        at quickfix.FieldMap.getString(FieldMap.java:237)
        at com.dxtr.fastmatch.marketdatarequestapps.TestMarketdataRequest.fromApp(TestMarketdataRequest.java:39)
        at quickfix.Session.fromCallback(Session.java:1847)
        at quickfix.Session.verify(Session.java:1791)
        at quickfix.Session.verify(Session.java:1862)
        at quickfix.Session.next(Session.java:1047)
        at quickfix.Session.next(Session.java:1204)
        at quickfix.mina.SingleThreadedEventHandlingStrategy$SessionMessageEvent.processMessage(SingleThreadedEventHandlingStrategy.java:163)
        at quickfix.mina.SingleThreadedEventHandlingStrategy.block(SingleThreadedEventHandlingStrategy.java:113)
        at quickfix.mina.SingleThreadedEventHandlingStrategy.lambda$blockInpacket_write_wait: Connection to 3.13.235.241 port 22: Broken pipe

这是我在 message.log 中检查的值 8=FIX.4.2^A9=0217^A35=X^A34=7291^A49=Fastmatch1^A52=20200401-10:47:59.833^A56=MDValueTrade2UAT1^A262=VT_020^A268=02^A279=2^A55=GBP/CHF^A269=0^A278=1140851192^A270=1.19503^A271=02000000^A279=0^A55=GBP/CHF^A269=0^A278=1140851194^A270=1.19502^A271=06000000^A10=114^A 我的经纪人已将价格等发给我 我的问题是:如何通过这段代码解决我的问题?

First, I got an error like this:

Out of order repeating group members

您的数据字典与交易对手的不匹配。 解决这个问题,这个问题就会消失。

After that, I added this text into my initiator.config:

ValidateUserDefinedFields=N
ValidateIncomingMessage=N

这并没有解决任何问题——它隐藏了您的实际问题,让您看到一个新的假问题。

您需要做的事情:

你的配置有这个吧?

UseDataDictionary=Y
DataDictionary=path/to/FIXnn.xml
# or if FIX5:
AppDataDictionary=path/to/FIX5n.xml
TransportDataDictionary=path/to/FIXT.xml

找到您的交易对手的文档,并确保您的 xml 文件的消息和字段与他们所说的将要发送给您的内容相符。确保所有重复组具有相同的字段且顺序相同

这里 some documentation 关于数据字典 xml 文件的结构。很简单。