3

I'm try to implement creating FIX message to create manually MarketDataIncrementalRefresh. When I convert created message to String then convert it to MarketDataIncrementalRefresh from this String - I'm getting another MarketDataIncrementalRefresh.

I cann't understand what is wrong with my code.

import static org.testng.Assert.assertEquals;

import org.testng.annotations.Test;

import quickfix.ConfigError;
import quickfix.DataDictionary;
import quickfix.InvalidMessage;
import quickfix.field.MDEntryPx;
import quickfix.field.MDEntrySize;
import quickfix.field.MDEntryType;
import quickfix.field.MDUpdateAction;
import quickfix.field.Symbol;
import quickfix.fix44.MarketDataIncrementalRefresh;
import quickfix.fix44.MarketDataSnapshotFullRefresh;

public class TradeEventToFixMessageConverterTest2 {

    private static final DataDictionary dataDictionary;

    static {
        try {
            dataDictionary = new DataDictionary(TradeEventToFixMessageConverterTest2.class.getResourceAsStream("/conf/FIX44-CUSTOM.xml"));
        } catch (ConfigError configError) {
            throw new ExceptionInInitializerError(configError);
        }
    }

    @Test
    public void rawTest() throws InvalidMessage {
        MarketDataIncrementalRefresh fixMessage = new MarketDataIncrementalRefresh();
        MarketDataSnapshotFullRefresh.NoMDEntries group = new MarketDataSnapshotFullRefresh.NoMDEntries();
        group.setField(new MDUpdateAction(MDUpdateAction.NEW));
        group.setField(new MDEntryType(MDEntryType.TRADE));
        group.setField(new Symbol("123456"));
        group.setField(new MDEntryPx(12345L));
        group.setField(new MDEntrySize(1234.0));
        fixMessage.addGroup(group);

        String fixString = fixMessage.toString();
        System.out.println(fixString);

        MarketDataIncrementalRefresh reversed = createMarketDataRequest(fixString);
        System.out.println(reversed.toString());

        assertEquals(reversed.toString(), fixString);
    }


    private MarketDataIncrementalRefresh createMarketDataRequest(String fixString) throws InvalidMessage {
        MarketDataIncrementalRefresh message = new MarketDataIncrementalRefresh();
        message.fromString(fixString, dataDictionary, true);
        return message;
    }

FIX Dictionary is based on standart FIX44 and looks like

<message name="MarketDataIncrementalRefresh" msgtype="X" msgcat="app">
    <field name="MDReqID" required="N"/>
    <group name="NoMDEntries" required="Y">
        <field name="MDUpdateAction" required="Y"/>
        <field name="MDEntryType" required="N"/>
        <field name="MDEntryID" required="N"/>
        <field name="Symbol" required="Y"/>
        <field name="MDEntryPx" required="N"/>
        <field name="MDEntrySize" required="N"/>
    </group>
</message>

When I try to run such convertation with real FIX server I got error

2018-04-23 14:59:54.508 +0000 ERROR [QFJ Message Processor] quickfixj.errorEvent - FIX.4.4:1/Quote->QUICKFIX: Reject sent for Message 2: Out of order repeating group members:269

What I've missed? Any help will be useful.

UPDATED

It was typo in my code - I construct MarketDataIncrementalRefresh but add MarketDataSnapshotFullRefresh.NoMDEntries to it.I changed it to MarketDataIncrementalRefresh.NoMDEntries and everything is OK.

Yuriy Alevohin
  • 941
  • 7
  • 18

1 Answers1

2

Check out your fixstring that results from toString(). I suspect that it may not actually match your custom DataDictionary, but instead is built using field orderings from the default vanilla FIX44.xml dictionary.

At no point in the construction of your message do you pass in your custom DD. That probably means it's not using it.

Unfortunately, my QF/j experience is rusty, and I can't figure out how or where to inject that DD into the message construction process. I looked at the API, and I just don't see a function for it.

(Of course, my general advice for all QF users is to regenerate and rebuild your code from your custom DD, and then you'll never have this problem.)

Grant Birchmeier
  • 17,809
  • 11
  • 63
  • 98
  • 1
    Thank you very much for your help! I've check twice everything and found problem. It was typo in my code - I construct `MarketDataIncrementalRefresh` but add `MarketDataSnapshotFullRefresh.NoMDEntries` to it.I changed it to `MarketDataIncrementalRefresh.NoMDEntries` and everything is OK. – Yuriy Alevohin Apr 24 '18 at 06:41
  • Ah, nice. Good catch. – Grant Birchmeier Apr 24 '18 at 18:42