I'm trying to implement a multileg order using Quickfix/n 4.2, 4.3 should be used instead but that isn't possible due to broker limit.
In the docs they say to set message type (tag 45) to AB (NEW_ORDER_MULTILEG) and that's not a problem.
The problem is related to all the other necessary repeated tags that we need to send to compose the multileg order. For example in our case we need to send these tags repeated:
new LegSymbol(symbol),
new LegCFICode(futureOption.OptionRight == OptionRight.Call? "OCXXXX" : "OPXXXX"),
new LegRatioQty(ml.Quantity),
new LegSide(ml.TradeDirection.ToFixSide()),
new LegStrikePrice(futureOption.StrikePrice),
new LegMaturityDate(futureOption.ExpiryDate.ToString(LEG_EXPIRY_FORMAT)),
So we need six specific tags to be repeated two times. By default the library overrides every tag with the last value, so it is not possible to add duplicated tags with different values.
How to implement a code centric solution in order to send this type of order? What is the simple way to make it clean and working?
With "code centric" I mean without necessity of rebuild library or other similar solutions.
I see that Quickfix/n 4.2 supports Group class but I'm not able to find any docs about how to use it.
The solution is to use Group class creating as many groups as the tags to repeat
var group = new Group(555, 600);
group.SetField(new LegSymbol(symbol));
group.SetField(new LegCFICode(futureOption.OptionRight == OptionRight.Call? "FCO" : "FPO"));
group.SetField(new LegRatioQty(ml.Quantity));
group.SetField(new LegSide(ml.TradeDirection.ToFixSide()));
group.SetField(new LegStrikePrice(futureOption.StrikePrice));
group.SetField(new LegMaturityDate(futureOption.ExpiryDate.ToString(LEG_EXPIRY_FORMAT)));
then simply add then with AddGroup() to your order.
The docs are showing fix 4.4 example but if you don't want to import also 4.4 dependency that is the solution.