如何使用 QuickFixJ 将字符串 FIX 消息转换为 FIX FIX50SP2 格式

Riv*_*ivu 5 java quickfix fix-protocol

需要快速帮助。我是 QuickFixJ 的新手。我的 txt 文件中有一条 FIX 消息。我需要将其转换为 FIX50SP2 格式。我附上代码片段。

String fixMsg = "1128=99=25535=X49=CME34=47134052=20100318-03:21:11.36475=20120904268=2279=122=848=336683=607400107=ESU2269=1270=140575271=152273=121014000336=2346=521023=1279=122=848=336683=607401107=ESU2269=1270=140600271=206273=121014000336=2346=681023=210=159";

System.out.println("FixMsg String:"+fixMsg);
Message FIXMessage = new Message();
DataDictionary dd = new DataDictionary("FIX50SP2.xml");
FIXMessage.fromString(fixMsg, dd, false);
System.out.println("FIXMessage Output:" + FIXMessage.toString()); // Print message after parsing
MsgType msgType = new MsgType();
System.out.println(FIXMessage.getField(msgType));
Run Code Online (Sandbox Code Playgroud)

这是输出:

FixMsg String:1128=99=15835=X49=CME34=47164052=2012090312102051175=20120904268=1279=122=848=336683=607745107=ESU2269=1270=140575271=123273=121020000336=2346=501023=110=205
FIXMessage Output:9=6135=X34=47164049=CME52=2012090312102051175=20120904268=110=117
quickfix.FieldNotFound: Field [35] was not found in message.
    at quickfix.FieldMap.getField(FieldMap.java:216)
    at quickfix.FieldMap.getFieldInternal(FieldMap.java:353)
    at quickfix.FieldMap.getField(FieldMap.java:349)
    at MainApp.main(MainApp.java:52)
Run Code Online (Sandbox Code Playgroud)

我想提取 MsgType 字段(字段 35)。你能告诉我我错在哪里吗?我观察到的是,解析为 FIX50SP2 格式后,转换 FIX 消息缺少许多数据元素(有关详细信息,请参阅输出)

谢谢

Mik*_*ert 1

我不熟悉 FIX 消息和 QuickFixJ,但浏览一下 Javadoc 似乎您应该使用该identifyType方法:

String fixMsg = "1128=99=25535=X49=CME34=47134052=20100318-03:21:11.36475=20120904268=2279=122=848=336683=607400107=ESU2269=1270=140575271=152273=121014000336=2346=521023=1279=122=848=336683=607401107=ESU2269=1270=140600271=206273=121014000336=2346=681023=210=159";
MsgType msgType = Message.identifyType(fixMsg);
Run Code Online (Sandbox Code Playgroud)