简体   繁体   English

FIX 4.4 FieldNotFound:未找到字段

[英]FIX 4.4 FieldNotFound: Field not found

I receive the following message from counterparty:我收到来自交易对手的以下消息:

8=FIX.4.4|9=219|35=W|34=4|49=id|52=20200618-14:34:20.738|56=id1|42=20200618-14:34:20.688|55=EUR/USD|262=1|268=2|269=0|270=1.12083|271=500000|269=1|270=1.12084|271=500000|10094=2020.06.18 14:34:20.688|10=141| 8=FIX.4.4|9=219|35=W|34=4|49=id|52=20200618-14:34:20.738|56=id1|42=20200618-14:34:20.688|55=EUR/美元|262=1|268=2|269=0|270=1.12083|271=500000|269=1|270=1.12084|271=500000|10094=2020.06.18 14:34:20.688|10=141|

The message contains the field 268 = 2, and both groups begin with the field 269, and I am trying to extract fields 270. My code looks like this:该消息包含字段 268 = 2,两个组都以字段 269 开头,我正在尝试提取字段 270。我的代码如下所示:

message= quickfix.Message('8=FIX.4.4\x019=219\x0135=W\x0134=4\x0149=id\x0152=20200618-14:34:20.738\x0156=id1\x0142=20200618-14:34:20.688\x0155=EURUSD\x01262=1\x01268=2\x01269=0\x01269=1\x01270=1.12083\x01270=1.12084\x01271=500000\x01271=500000\x0110094=2020.06.18 14:34:20.688\x0110=141\x01')

group = quickfix44.MarketDataSnapshotFullRefresh.NoMDEntries()

fix_no_entries = quickfix.NoMDEntries()
message.getField(fix_no_entries)
no_entries = fix_no_entries.getValue() # print = 2 as expected

message.getGroup(1, group)

However, when running the getGroup line, I get the error:但是,在运行 getGroup 行时,出现错误:

FieldNotFound: Field not found FieldNotFound:未找到字段

Any idea on what is going wrong?关于出了什么问题的任何想法?

Thank you again guys!再次感谢各位!

Quickfix doesn't know about your message structure, so you need to provide some info about how to parse the message, otherwise it's just a bunch of fields without groups. Quickfix 不知道你的消息结构,所以你需要提供一些关于如何解析消息的信息,否则它只是一堆没有组的字段。

<message>
  <header>
    <field number="8"><![CDATA[FIX.4.4]]></field>
    <field number="9"><![CDATA[183]]></field>
    <field number="35"><![CDATA[W]]></field>
    <field number="34"><![CDATA[4]]></field>
    <field number="49"><![CDATA[id]]></field>
    <field number="52"><![CDATA[20200618-14:34:20.738]]></field>
    <field number="56"><![CDATA[id1]]></field>
  </header>
  <body>
    <field number="42"><![CDATA[20200618-14:34:20.688]]></field>
    <field number="55"><![CDATA[EURUSD]]></field>
    <field number="262"><![CDATA[1]]></field>
    <field number="268"><![CDATA[2]]></field>
    <field number="269"><![CDATA[0]]></field>
    <field number="269"><![CDATA[1]]></field>
    <field number="270"><![CDATA[1.12083]]></field>
    <field number="270"><![CDATA[1.12084]]></field>
    <field number="271"><![CDATA[500000]]></field>
    <field number="271"><![CDATA[500000]]></field>
    <field number="10094"><![CDATA[2020.06.18 14:34:20.688]]></field>
  </body>
  <trailer>
    <field number="10"><![CDATA[182]]></field>
  </trailer>
</message>

Quickfix data dictionaries are the way to configure the message parser. Quickfix 数据字典是配置消息解析器的方式。 Quickfix already comes along with some pre-configured dictionaries, you can customize it according with your needs. Quickfix 已经附带了一些预配置的字典,您可以根据需要对其进行自定义。

data_dictionary = quickfix.DataDictionary("quickfix/FIX44.xml")
message= quickfix.Message('...', data_dictionary, True)
print(message.toXML())

Now the message is structured and it's possible to retrieve groups data:现在消息是结构化的,可以检索组数据:

<message>
  <header>
    <field number="8"><![CDATA[FIX.4.4]]></field>
    <field number="9"><![CDATA[183]]></field>
    <field number="35"><![CDATA[W]]></field>
    <field number="34"><![CDATA[4]]></field>
    <field number="49"><![CDATA[id]]></field>
    <field number="52"><![CDATA[20200618-14:34:20.738]]></field>
    <field number="56"><![CDATA[id1]]></field>
  </header>
  <body>
    <field number="42"><![CDATA[20200618-14:34:20.688]]></field>
    <field number="55"><![CDATA[EURUSD]]></field>
    <field number="262"><![CDATA[1]]></field>
    <field number="268"><![CDATA[2]]></field>
    <field number="10094"><![CDATA[2020.06.18 14:34:20.688]]></field>
    <group>
      <field number="269"><![CDATA[0]]></field>
    </group>
    <group>
      <field number="269"><![CDATA[1]]></field>
      <field number="270"><![CDATA[1.12083]]></field>
    </group>
    <group>
      <field number="270"><![CDATA[1.12084]]></field>
      <field number="271"><![CDATA[500000]]></field>
    </group>
    <group>
      <field number="271"><![CDATA[500000]]></field>
    </group>
  </body>
  <trailer>
    <field number="10"><![CDATA[182]]></field>
  </trailer>
</message>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM