使用 Python Quickfix 读取自定义消息中的重复组
我正在尝试使用 Python 和 Quickfix 从 FIX 引擎中读取数据,并设法通过修改所使用的数据字典(带有必要的消息组)使引擎识别自定义消息。
我现在面临的问题是从自定义消息中读取重复组。 quickfix 文档 显示以下内容:
import quickfix
import quickfix42
noMDEntries = quickfix.NoMDEntries()
message.getField(noMDEntries)
group = quickfix42.MarketDataSnapshotFillRefresh.NoMDEntries()
MDEntryType = quickfix.MDEntryType()
MDEntryPx = quickfix.MDEntryPx()
MDEntrySize = quickfix.MDEntrySize()
orderID = quickfix.OrderID();
message.getGroup(1, group);
group.getField(MDEntryType);
group.getField(MDEntryPx);
group.getField(MDEntrySize);
group.getField(orderID);
...这很好用于修复消息。当我尝试像这样引用我的自定义消息时:
group = quickfix.CustomMessage.NoMDEntries()
...我收到属性错误。
关于如何读取自定义消息中的重复组有什么想法吗?
编辑1:
我发现了一个黑客,但我确信有更好的方法来做到这一点......
for i in range(int(message.getField(NoMDEntries):
group = quickfix.Group(int(message.repeatingField), int(message.delimField))
message.getGroup(i+1, group)
print group.getField(MDEntryPx)
#do something with repeating fields etc
...有人有想法吗?
I am trying to read from a FIX engine using Python and Quickfix, and have managed to get the engine to recognize custom messages by modifying the data dictionary used (with necessary message groups).
The problem I am now facing is reading repeating groups from the custom messages. The quickfix documentation shows the following:
import quickfix
import quickfix42
noMDEntries = quickfix.NoMDEntries()
message.getField(noMDEntries)
group = quickfix42.MarketDataSnapshotFillRefresh.NoMDEntries()
MDEntryType = quickfix.MDEntryType()
MDEntryPx = quickfix.MDEntryPx()
MDEntrySize = quickfix.MDEntrySize()
orderID = quickfix.OrderID();
message.getGroup(1, group);
group.getField(MDEntryType);
group.getField(MDEntryPx);
group.getField(MDEntrySize);
group.getField(orderID);
...which is fine for FIX messages. When i try and reference my custom message like so:
group = quickfix.CustomMessage.NoMDEntries()
...I get an attribute error.
Any ideas on how to read repeating groups in custom messages?
Edit 1:
i found a hack, but am certain there is a better way of doing this...
for i in range(int(message.getField(NoMDEntries):
group = quickfix.Group(int(message.repeatingField), int(message.delimField))
message.getGroup(i+1, group)
print group.getField(MDEntryPx)
#do something with repeating fields etc
...ideas anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您提供的 Python 存根,但我发现可能有问题。
在这里,您获得 MarketDataSnapshotFullRefresh 对象内的内部类对象(您可能拼错了 MarketDataSnapshotFillRefresh)对象。
这里你可能得到的是重复组内重复组的数量(计数),而不是类对象。
Quickfix 提供了 getGroup 方法来浏览组成员,因此请使用它而不是自己执行。
Not sure about the Python stub you supplied, but I see maybe a problem.
Here you get the inner class object inside the MarketDataSnapshotFullRefresh(you probably have misspelt it MarketDataSnapshotFillRefresh) object.
Here you probably get is the number(count) of repeating groups inside the repeating group, instead of the class object.
Quickfix provides the getGroup method to browse through the group members, so use it rather than doing it yourself.
请删除您文档中的以下代码:
message.getField(noMDEntries)
那么它将很好地获取您想要的值。
please delete the below codes in your documents:
message.getField(noMDEntries)
then it will work well to get the value that you want.