Reading Repeating Groups in Custom Messages using

2019-07-16 01:54发布

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?

1条回答
倾城 Initia
2楼-- · 2019-07-16 02:28

Not sure about the Python stub you supplied, but I see maybe a problem.

group = quickfix42.MarketDataSnapshotFillRefresh.NoMDEntries()

Here you get the inner class object inside the MarketDataSnapshotFullRefresh(you probably have misspelt it MarketDataSnapshotFillRefresh) object.

group = quickfix.CustomMessage.NoMDEntries()

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.

查看更多
登录 后发表回答