quickfix - 修复重复组以重用相同标签

标签 quickfix fix-protocol quickfixj

FIX 协议(protocol)是否允许在消息和重复组中重复使用相同的标记? IE。我可以有类似的东西

        <message name='Quote' msgtype='S' msgcat='app'>
            <field name='Price' required='Y'/><!-- i.e. total price for the whole quote-->
    ...
            <group name='NumLegs' required='Y'>
                <field name='Price' required='Y'/><!-- i.e. leg price -->
    ...
                <group name='NumLegDetails' required='Y'>
                    <field name='Price' required='Y'/><!-- i.e. leg component price -->
    ...
                </group>
    ...
            </group>
        </message>

最佳答案

TL;DR

在标记值编码中不允许
(但在 FIXML 中是这样)

一些解释

我最初的误解来自于FIX标记值规范中的这个声明:see here, search for "Field presence"

A tag (field) must appear at most once in a message, except when the tag appears within a repeating group.

但据我所知,这是指消息的有线格式,而不是消息的定义

而 FIX5.0SP2 规范第 1 卷引用了消息的定义并指出:

A tag number (field) should only appear in a message once. If it appears more than once in the message it should be considered an error with the specification document.

与此同时,我什至在查看 NestedParties 组件时发现 FIXimate 中提到了它(强调我的):( link to NestedParties component in FIXimate )

The NestedParties component block is identical to the Parties Block. It is used in other component blocks and repeating groups when nesting will take place resulting in multiple occurrences of the Parties block within a single FIX message.. Use of NestedParties under these conditions avoids multiple references to the Parties block within the same message which is not allowed in FIX tag/value syntax.

顺便说一句,还有组件NestedParties2NestedParties3NestedParties4来解决这个问题。

来自FIX交易社区论坛的信息

这里可以访问该线程,但据我所知,只有当您是 FIX TC 成员(member)时才能访问它:FIX TC forum

FIX专家Hanno Klein给出了以下信息:

The quote from the refactored online spec refers to the wire format of any instance of a message encoded in tagvalue syntax. It means that inside the wire format of a single repeating group a tag (field) may appear more than once.

FIXML 没有此限制:

The restriction is actually limited to the tagvalue encoding. For example, the parties component is “Pty” for all instances in FIXML, the XML syntax/encoding of FIX. This is due to the fact that the XML syntax has an unambiguous structure with a distinct path to every occurrence of a component or field. The XML names only need to be unique within the same element.

标签值的作用:

For tagvalue, a parser needs to know when a repeating group starts and ends. The NoXXX field marks the starting point and a field that is not part of the group marks the ending point. There are no explicit delimiters for repeating groups in tagvalue and components (non-repeating) are not visible in the wire format at all. Technically, you are probably right that a Price tag could exist in two distinct repeating groups without causing a parser issue but I do not see the benefit to allow this exception to the rule. You cannot allow it for two adjacent levels, e.g. root + nesting level 1 or nesting level x + nesting level y.


原始答案中的这部分仍然适用

另一方面,在定义您自己的重复组时,请使用符号 NoXXX 来表示重复组,因为这是官方建议。 see here, search for "NumInGroup field"

It is recommended that NumInGroup fields be named NoXXX, e.g. NoContraBrokers(382).

但是,按照 44/Price 的示例,您通常会看到 566/LegPrice 用作单个腿的价格,因为两者的使用方式不同。前者是用于执行订单的价格,后者是在定义策略的边时使用的价格。

所以简而言之,在定义消息结构和重复组时,您应该真正考虑该标签的含义对于消息中所有出现的标签 是否都相同,以及使用正文和重复组中的标签完全相同。 清晰度应该是第一位的。


原始答案的不正确(删除线)部分

起初我认为这是不允许的,但主要是因为我从未见过它出现在真实消息中的某个地方。但实际上我找不到不应该允许的理由。规范只说:see here, search for "Field presence"

A tag (field) must appear at most once in a message, except when the tag appears within a repeating group.

A tag (field) must appear at most once per repeating group instance.

关于quickfix - 修复重复组以重用相同标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64660451/

相关文章:

java - 如何从quickfixj FIX.4.2执行报告中检索标签值

java - 如果另一个线程尚未完成,则让另一个线程处理进程

Quickfixj 客户端登录时立即收到注销信息

c++ - quickfix 给出的总线错误

fix-protocol - QuickFIX/N 是否支持包含两个组件且每个组件具有相同名称的消息?

quickfix - Quick Fix 基于 Java 的 Fix 客户端 - 发送消息和接收响应是否都需要套接字发起者和接受者

java - QuickFIX/J 启动器 - 在登录时设置用户名和密码

java - 在类路径上使用 (SAXON-HE) 进行 JAXB 解码非常慢

python - 使用 quickfix python 和 twisted

python - 使用 Python Quickfix 读取自定义消息中的重复组