3

When processing a QuickFix44.NewOrderMultileg message in C#, how do you extract the details of the legs?

The only documentation I've found so far seems to apply only to market data and/or be wildly out of date: http://www.quickfixengine.org/quickfix/doc/html/csharp/repeating_groups_2.html

Eric
  • 11,392
  • 13
  • 57
  • 100

1 Answers1

3

Same as you have done in the application, but you have to go a little deeper.

NewOrderMultileg -> InstrumentLeg/LegSipulations and other groups and fields.

Get the count of legs present in the message by reading NoLegs. Then iterate over the message reading the groups one by one.

The components in the message may be in a group or single. Whenever you find the suffix Grp expect multiple groups. Refer here for clarification.

Do not write the same piece of code multiple times, make a loop. You don't know how many groups are there in the message.

for (int i = 1; i <= groupCount; ++i)
{
    message.getGroup(i, group);
    group.get(MDEntryType);
    group.get(MDEntryPx);
    group.get(MDEntrySize);
    group.get(orderID);
    /* Do other stuff */
}

For components in the message, one for each leg, read the component in that loop as well.

DumbCoder
  • 5,696
  • 3
  • 29
  • 40
  • What is the declaration of `group` in your example? And what if the order has, say, both a LegOrdGrp and an UndInstrmtGrp, how do you distinguish between them? – Eric Jul 26 '11 at 11:52
  • @Eric - group is NewOrderMultileg::NoLegs, this is the group,**not the number of legs**. For 2nd question, you iterate over the **full message after reading the number of groups** for the specific groups i.e. NewOrderMultileg::NoUnderlyings. – DumbCoder Jul 26 '11 at 13:28
  • +1 for your answer. However, if I'm not wrong, repeating groups are not zero-based (unfortunately), then your loop must go in [1, groupCount] – Luca Martini Jul 27 '11 at 07:04
  • @Luca Martini - Yes it should be 1, I overlooked the fact. Thanks, rectified it. – DumbCoder Jul 27 '11 at 07:49
  • @DumbCoder - The class `QuickFix.NoLegs` derives from `IntField` and (in the case of my 2-leg order) has the value 2. So it seems like I should write `groupCount = order.getNoLegs().Value`. But I don't see any method that returns a `Group`, nor any nested type within NewOrderMultiLeg that derives from `Group`, and the constructors for `Group` are opaque. So how do I get something to use as the second argument for `getGroup`? Could you expand your example to be a full function, say `PrintLegRefIds( NewOrderMultiLeg order ) { /* print out LegRefId for each leg */ }` ? – Eric Jul 27 '11 at 20:38
  • @DumbCoder - Ah, I see now. You get `groupCount` by calling `var groupCount = order.getNoLegs().getValue()`. Meanwhile, you get `group` by allocating with `var group = new NewOrderMultiLeg.NoLegs();`. It's confusing because the names are so similar. – Eric Jul 27 '11 at 20:53