比较 QuickFIXJ 中的两个 FixMessage
我需要在 QuickFIXJ 中比较两个修复消息(例如两个执行报告)。
我们将它们称为 er1
和 er2
现在,我比较它们的意思是一堆字段必须相同。 例如我关心标签 55、标签 207、标签 1 是否相同。 但其他人则不然。
在我看来,唯一的方法就是写一些像这样昂贵(性能方面)的东西:
public static boolean compare(ExecutionReport er1,ExecutionReport er2)
{
StringField sf1 = new StringField(55);
StringField sf2 = new StringField(55);
er.getField(sf1);
er.getField(sf2);
if (sf1.getValue().equals(sf2.getValue())==false) return false;
... // continue with all of the other fields
... // in the same way
}
我错过了什么吗? 有人可以建议更好/更快的方法吗?
I need to compare two fix messages (say two ExecutionReports) in QuickFIXJ.
Let's call them er1
and er2
Now, what I mean by comparing them is that a bunch of fields must be identical.
for instance I care that tag 55, tag 207, tag 1 are the same.
but not others.
It seems to me that the only way to do so is to write something as expensive (performance-wise) as this:
public static boolean compare(ExecutionReport er1,ExecutionReport er2)
{
StringField sf1 = new StringField(55);
StringField sf2 = new StringField(55);
er.getField(sf1);
er.getField(sf2);
if (sf1.getValue().equals(sf2.getValue())==false) return false;
... // continue with all of the other fields
... // in the same way
}
Am I missing something ?
can somebody suggest a better/faster approach ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
API 中似乎没有比较两个修复消息的功能。但最好不要比较整个消息字段,而是仅比较那些必填字段。如果您完全确定这些字段会出现在 FIX 消息中,则可以进行扩展。
另一种选择是在与发送和接收消息的会话不同的线程中进行比较。如果不知道执行报告下游发生了什么,或者如果执行报告匹配,您将采取什么操作,则很难决定是否需要在同一线程中比较消息。
There is no function to compare two fix messages in the API, it seems. But instead of comparing the whole message fields, the best would be to compare only those fields which are mandatory. An extension would be if you are dead sure those fields would be present in the FIX message.
Another option would be to compare in a thread different than the one for the session where you are sending and receiving messages. It would be hard to decide if the messages need to be compared in the same thread, without knowing what happens downstream with the Execution reports or what are your actions if the Execution reports match.
基于
quickfix.Message.toXML()
迭代逻辑的实现。比较的结果是组合键(如果字段是组的一部分)和“之前”和“之后”状态对的排序映射。
Implementation based on
quickfix.Message.toXML()
iteration logic.Result of the comparison is sorted map of composite key (if field is part of the group) and pair of 'before' and 'after' state.