gpt4 book ai didi

python - 如何在 QuickFix DataDictionary 中嵌套重复组?

转载 作者:行者123 更新时间:2023-11-30 23:19:23 29 4
gpt4 key购买 nike

我正在将 QuickFix 与 Python 绑定(bind)结合使用,并连接到提供历史数据下载的交易对手。为了解析传入的消息,我需要能够读取嵌套重复组。

我在这里找到了一个带有嵌套重复组的数据字典的示例:http://quickfix-j.364392.n2.nabble.com/Nested-repeating-group-error-tag-appears-more-than-once-fwd-td7578213.html

我尝试在此示例中对我的 DD 进行建模,但我不断收到相同的错误:条件必填字段缺失:3210。该字段3210正是新的(嵌套的)组定义,称为NoChartData。

我仔细研究了DD,没有发现任何问题。同样,我也进行了三次检查,确保每个标签都已定义,并且所有标签的可能值也已定义。

有什么想法吗?错误是我的错吗?这可能是 QF 错误吗?

编辑:对方给了我一个预先批准的数据字典样本来尝试,但它不起作用(导致了相同的错误)。看来DD并没有错。这是 QuickFix C++ 版本中的错误吗?

<message name="MarketDataSnapshotFullRefresh" msgtype="W" msgcat="app">
<field name="MDReqID" required="N" />
<field name="Symbol" required="N" />
<field name="SecurityType" required="N" />
<field name="MaturityMonthYear" required="N" />
<field name="MaturityDay" required="N" />
<field name="PutOrCall" required="N" />
<field name="StrikePrice" required="N" />
<field name="OptAttribute" required="N" />
<field name="SecurityID" required="N" />
<field name="SecurityStatus" required="N" />
<field name="SecurityAltID" required="N" />
<field name="SecurityExchange" required="N" />
<field name="SettlType" required="N" />
<field name="TotalVolumeTraded" required="N" />
<field name="Currency" required="N" />
<field name="PriceFeedStatus" required="N" />
<field name="DeliveryTerm" required="N" />
<field name="ExecInst" required="N" />
<field name="ChartType" required="N" />
<field name="TradeDateStart" required="N" />
<field name="TradeDateEnd" required="N" />
<field name="SessionStartTime" required="N" />
<field name="SessionEndTime" required="N" />
<field name="DataFormat" required="N" />
<field name="EncodedTextCRC" required="N"/>
<field name="EncodedTextLen" required="N" />
<field name="EncodedText" required="N" />
<group name="NoMDEntries" required="Y">
<field name="MDEntryType" required="Y" />
<field name="TradeDate" required="N" />
<field name="MDEntryID" required="N" />
<field name="MDEntryPx" required="N" />
<field name="MDEntrySize" required="N" />
<field name="MDEntryTime" required="N" />
<field name="TickDirection" required="N" />
<field name="TradeCondition" required="N" />
<field name="ExecInst" required="N" />
<field name="MDEntryLevel" required="N" />
<field name="ChartType" required="N" />
<field name="MDEntryPositionNo" required="N" />
<field name="SecondaryOrderID" required="N" />
<field name="MDEntryState" required="N" />
<field name="AggressorSide" required="N" />
<field name="MDEntrySizeType" required="N" />
<field name="NumberOfOrders" required="N" />
<field name="ExactNumOrdersIndicator" required="N" />
<field name="TrdType" required="N" />
<field name="TradeVolume" required="N" />
<group name="NoChartData" required="N" >
<field name="Change" required="N" />
<field name="Numerator" required="N" />
<field name="Denominator" required="N" />
<field name="PriceCode" required="N" />
<field name="TickValue" required="N" />
<field name="TradeDateCharts" required="N" />
<field name="MarketModeTime" required="N" />
<field name="MarketMode" required="N" />
<field name="SettlementTime" required="N" />
<field name="Settlement" required="N" />
<field name="HeldSettlementTime" required="N" />
<field name="HeldSettlement" required="N" />
<field name="OpenInterestTime" required="N" />
<field name="OpenInterest" required="N" />
<field name="ClearedVolumeTime" required="N" />
<field name="ClearedVolume" required="N" />
<field name="VWAPTime" required="N" />
<field name="VWAP" required="N" />
<field name="QuoteTime" required="N" />
<field name="BidTicks" required="N" />
<field name="BidRealVolume" required="N" />
<field name="BidImpliedVolume" required="N" />
<field name="OfferTicks" required="N" />
<field name="OfferRealVolume" required="N" />
<field name="OfferImpliedVolume" required="N" />
<field name="TPOStartTime" required="N" />
<field name="TPOTicks" required="N" />
<field name="TPOVolume" required="N" />
<field name="TPOVolumeAtBid" required="N" />
<field name="TPOVolumeAtOffer" required="N" />
<field name="TPOIsOpening" required="N" />
<field name="TPOIsClosing" required="N" />
<field name="TradeTime" required="N" />
<field name="TradedVolume" required="N" />
<field name="TradeTickValue" required="N" />
<field name="TotalTradedVolume" required="N" />
<field name="DueToSpread" required="N" />
<field name="AtBidOrOffer" required="N" />
<field name="BarStartTime" required="N" />
<field name="BarCloseTime" required="N" />
<field name="BarOpenTicks" required="N" />
<field name="BarHighTicks" required="N" />
<field name="BarLowTicks" required="N" />
<field name="BarCloseTicks" required="N" />
<field name="BarVolume" required="N" />
<field name="BarBidVolume" required="N" />
<field name="BarOfferVolume" required="N" />
<field name="BarTradeCount" required="N" />
<field name="BarTradesAtBid" required="N" />
<field name="BarTradesAtOffer" required="N" />
<field name="TickChangeStartTime" required="N" />
<field name="TickChangeCloseTime" required="N" />
<field name="TickChangeVolume" required="N" />
<field name="TickChangeBidVolume" required="N" />
<field name="TickChangeOfferVolume" required="N" />
<field name="TickChangeTradeCount" required="N" />
<field name="TickChangeTradesAtBid" required="N" />
<field name="TickChangeTradesAtOffer" required="N" />
<field name="RFQTime" required="N" />
<field name="BuySell" required="N" />
<field name="Volume" required="N" />
</group>
</group>
</message>

更新这是我尝试解析的实际消息的开头:

(8=FIX.4.2☺9=8233☺35=W☺34=2☺49=CTS☺56=XXXX☺52=20140929-20:11:48.480☺262=k-0 ☺55=YM☺48=XCME_E YM(Z14)☺207=CME_E☺965=16☺3200=20140903☺3201=20140904☺3202=15:1 1:48.465☺3203=15:11:48.465☺3204=3☺3205=2☺ 268=2 ☺269=Y☺75=20140904☺ 3210=41 ☺ 3212=6☺ 3211=20140904☺3212=4☺3216=20140903-21:43:06.701☺3217=16990☺3212=3☺3213=20140903- 21:45:09.402☺3214=1☺3212=3☺3213=20140903-22:00:00.126☺3214=2☺3212=4☺3216=2014090 3-23:06:29.533☺3217=16990☺3212=5☺3254=20140903-22:00:00.000☺3255=20140903-22:30: 34.364☺3256=16990☺3257=16990☺3258=16990☺3259=16990☺3260=2☺3261=0☺3262=2☺3263=2☺3 264=0☺3265=2☺3212=5☺3254=20140903-23:00:00.000☺3255=20140903-23:17:00.207☺3256=1 6984☺3257=16984☺3258=16984☺3259=16984☺3260=1☺3261=1☺3262=0☺3263=1☺3264=1☺3265=0☺ 3212=5☺3254=20140904-00:00:00.000☺3255=20140904-00:35:19.271☺3256=16986☺3257=169 86☺3258=16986☺3259=16986☺3260=1☺3261=0☺3262=1☺3263=1☺3264=0☺3265=1☺3212=11☺3225= 20140904-06:09:38.473☺3226=1430☺3212=12☺3222=20140904-06:09:38.473☺3223=4957☺321 2=5☺3254=20140904-01:00:00.000☺3255=20140904-01:04:44.936☺3256=16984☺3257=16984☺ 3258=16984☺3259=16984☺3260=3☺3261=0☺3262=3☺3263=2☺3264=0☺3265=2☺3212=5☺3254=2014 0904-04:00:00.000☺3255=20140904-04:25:20.988☺3256=16985☺3257=16985☺3258=16985☺32

这是我用来解析的代码:

if '3210' in tags: 
group = fix.Group(3210, 3212)
ncd = int(str(message.getField(FIX['3210']))[5:-1])

(FIX 是标签:值对的字典。)然后我尝试迭代 NoChartData 组。

考虑到格兰特的回复,我似乎需要改变我的逻辑来处理嵌套组。

最佳答案

有条件的必填字段缺失:3210

这不是 DD 错误;这是您的应用中的逻辑错误。

您正在尝试提取不存在的可选字段。您正在调用 msg.GetField(3210) (或其他),但消息(或组)不包含标签 3210。QF 假设您知道自己在做什么,并且该字段是应该在那里,所以它会像发件人犯了错误一样继续。

但是 QF 很乐观; 可能犯了错误。 (除非发件人确实应该包含 3210。)

使用 if(msg.HasField(3210)) (或任何正确的函数名称)包装 GetField 调用。不要提取可选字段,除非您知道它们存在或者除非您强制发件人应发送它们。

关于python - 如何在 QuickFix DataDictionary 中嵌套重复组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26108569/

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