gpt4 book ai didi

python - Quickfix 读取自定义重复组

转载 作者:太空狗 更新时间:2023-10-30 01:36:16 24 4
gpt4 key购买 nike

我有这个从我的服务提供商那里得到的示例响应。他们定义了已经定义的标签(我已经从 FIXimate 中检查过)。

8=FIXT.1.19=108135=IB49=NSECM56=MTBM34=1924=1115=21828=61826=Nifty CPSE1815=2294.51816=2310.151817=2286.551818=2276.751819=2294.21820=1967852601488651821=262231822=257851823=0.771824=2799.551825 =2139.51827=-1826=Nifty GrowSect 151815=7037.751816=7070.351817=7023.651818=6990.61819=7042.91820=7768216282514231821=782041822=750561823=0.751824=7354.551825=5942.151827= 1826=Nifty50 Value 201815=5444.71816=5465.61817=5417.41818=5413.61819=5425.91820=1.90667550936387E +151821=1348851822=1341791823=0.231824=5563.81825=4171.651827=-1826=Nifty Mid Liq 151815=4133.551816=4206.551817=4133.551818=4107.21819=4205.41820=1573956262705091821=428041822=442911823=2.391824=4677.051825=3770.551827=-1826=Nifty Pvt Bank1815= 15385.21816=15415.51817=15339.751818=15248.81819=15377.71820=9015155094048031821=589741822=592681823=0.851824=16152.151825=13298.31827=+1826=NIFTY MIDCAP 1001815=19184.851816=19326.31817=19184.851818=19046.551819=19314.251820=7127426889917151821=1858871822=1884631823=1.411824=21840 .851825=17700.91827=-10=174

问题是我无法读取重复组。我将自定义组创建为

 noIndexRecords = int(message.getField(1828))
if noIndexRecords > 0:
group = fix.Group(1828, 1826, )
message.getGroup(num=1, group=group)

但这显示了一个 FieldNotFound 错误。我已将规范文件 FIX50SP2.xml 更改为:

添加的字段:

<field number='1815' name="OpenIndex" type="PRICE"/>
<field number='1816' name="HighIndex" type="PRICE"/>
<field number='1817' name="LowIndex" type="PRICE"/>
<field number='1818' name="CloseIndex" type="PRICE"/>
<field number='1819' name="IndexValue" type="PRICE"/>
<field number='1820' name="MarketCapitalization" type="DOUBLE"/>
<field number='1821' name="NoOfDownMoves" type="INT"/>
<field number='1822' name="NoOfUpMoves" type="INT"/>
<field number='1823' name="PercentageChange" type="DECIMAL"/>
<field number='1824' name="YearlyHigh" type="PRICE"/>
<field number='1825' name="YearlyLow" type="PRICE"/>
<field number='1826' name="IndexName" type="STRING"/>
<field number='1827' name="NetChangeIndicator" type="CHAR"/>
<field number='1828' name="NumberOfRecords" type="INT"/>
<field number='8288' name='NoIndexRecords' type='NUMINGROUP'/>

已添加消息类别:

<message name='IndexBroadcast' msgtype="IB" msgcat="app">
<field name="NumberOfRecords" required="N"/>
<component name="NoIndexRecord" required="N"/>

组件定义为:

<component name="NoIndexRecord">
<group name='NoIndexRecords' required='N'>
<field name='IndexName' required='Y'/>
<field name='SecurityID' required='N'/>
<field name='OpenIndex' required='N'/>
<field name='HighIndex' required='N'/>
<field name='LowIndex' required='N'/>
<field name='CloseIndex' required='N'/>
<field name='IndexValue' required='N'/>
<field name='MarketCapitalization' required='N'/>
<field name='NoOfDownMoves' required='N'/>
<field name='NoOfUpMoves' required='N'/>
<field name='PercentageChange' required='N'/>
<field name='YearlyHigh' required='N'/>
<field name='YearlyLow' required='N'/>
<field name='NetChangeIndicator' required='N'/>
</group>
</component>

我经历了不同的讨论和论坛,但无法找到解决方案。类似的问题是 unanswered .

感谢任何帮助。谢谢

最佳答案

I have made changes to specifications file FIX50SP2.xml

我假设您指的是文件 spec/FIX50SP2.xmlQuickFIX C++ Fix Engine Library .为此,我认为您需要 recompile the quickfix-engine .除非您正在 fork QuickFix 引擎项目,否则这可能不是您想要的。

尝试定义您的字段 like this :

import quickfix

class MarketCapitalizationField(quickfix.DoubleField):
number = 1820

def __init__(self, data=None)
args = (self.number,) if data is None else (self.number, data)
super(MarketCapitalizationField, self).__init__(*args)

class IndexNameField(quickfix.StringField):
number = 1826

def __init__(self, data=None)
args = (self.number,) if data is None else (self.number, data)
super(IndexNameField, self).__init__(*args)

class NumberOfRecordsField(quickfix.IntField):
number = 1828

def __init__(self, data=None)
args = (self.number,) if data is None else (self.number, data)
super(NumberOfRecordsField, self).__init__(*args)

...然后像这样阅读您的消息:

noIndexRecords = int(message.getField(NumberOfRecords.number))
for idx in range(1, noIndexRecords+1):
message.getGroup(i, group)
group.getField(MarketCapitalizationField.number)
group.getField(IndexNameField.number)

关于python - Quickfix 读取自定义重复组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52367660/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com