Warm tip: This article is reproduced from serverfault.com, please click

quickfix-QuickFixN:如何在 QuoteRequest 消息中按特定顺序设置字段?

(quickfix - QuickFixN: How to set fields in a specific sequence on a QuoteRequest message?)

发布于 2021-02-18 12:21:04

我们要求按照设置的顺序发送消息的前 3 个字段,即 QuoteReqID、OnBehalfOfCompID、Account。但是,当它们添加到消息中时,它们会按数字升序重新排序,即 Account、OnBehalfOfCompID、QuoteReqID。通过组,我们可以定义字段顺序,但我看不到为消息执行此操作的选项。有谁知道我们如何实现这一目标?

            var message = new QuoteRequest();
            int[] fieldOrder = new[] {Tags.Currency, Tags.Symbol, Tags.SecurityType, Tags.CFICode, Tags.NoLegs, Tags.LegQty, Tags.LegFutSettDate, Tags.LegSecuritySubType};

            message.SetField(new QuoteReqID(stream.QuoteRequestId));
            message.SetField(new OnBehalfOfCompID(_compId));
            message.SetField(new Account(_accountId));
            var group = new Group(Tags.NoRelatedSym, 0, fieldOrder);
            group.SetField(new Currency(stream.Ccy));
            group.SetField(new Symbol(stream.Ccy1 + "/" + stream.Ccy2));
            group.SetField(new SecurityType("FOR"));
            group.SetField(new CFICode("FORWARD"));
            group.SetField(new NoLegs(1));
            group.SetField(new LegQty(stream.Amount));
            group.SetField(new LegFutSettDate(stream.FutSettDate));
            group.SetField(new LegSecuritySubType("TOD"));

            message.AddGroup(group);

            QuickFix.Session.SendToTarget(message, _ratesSession.SessionId);
Questioner
Lewis Hamill
Viewed
0
Grant Birchmeier 2021-02-18 23:47:49

这绝对不是 FIX 协议被指定的行为方式。在规范中,正文中不在重复组内的字段可以按任何顺序排列。你的交易对手要求不符合 FIX 的行为(我看不出有什么好处)。

因此,QuickFIX/n 不支持这一点,因为... QF/n 实现了 FIX,而不是你的交易对手想要的这种愚蠢的非 FIX 行为。

我很抱歉地告诉你这个,但你必须以某种方式破解引擎才能实现这一点。

还有一个警告: OnBehalfOfCompID是标题字段,而不是正文字段。QF/n 将它添加到传出消息的正文应该不会有问题,但它可能会在传入时拒绝此类消息。(感谢@ciaran-mchale 的回答指出了这一点。)