I connect to several APIs that all use FXI4.2 but now I wish to connect to another that uses its own version of FIX4.4.
I have an router app that send orders to the various APIs and it would appear that I need to duplicate all my methods (e.g. the OnMessage(), NewSingleOrder etc) to cope with the 2 FIX protocols.
Is there a smarter way to do this to avoid this duplication?
Moderators: I know this is a little open now, but I will add some code snippets once I get some initial feedback.
public void OnMessage(QuickFix.FIX42.MarketDataIncrementalRefresh message, SessionID sessionID)
{
int count = message.NoMDEntries.getValue();
QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup repeatingMDItem = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup();
DateTime sourceDT = DateTime.ParseExact(message.Header.GetField(52), "yyyyMMdd-HH:mm:ss.fff", ci);
DateTime dt = TimeZoneInfo.ConvertTimeToUtc(sourceDT, utcZone);
DateTime nowUTC = TimeZoneInfo.ConvertTime(DateTime.UtcNow, utcZone, utcZone);
TimeSpan diffToUK = nowUTC - dt;
for (int i = 1; i <= count; i++)
{
message.GetGroup(i, repeatingMDItem);
String symbol = repeatingMDItem.GetField(55);
int tickBandNoDecPlaces = int.Parse(repeatingMDItem.GetField(5071));
masterForm.MDATA.AddData(symbol, tickBandNoDecPlaces, sourceDT);
}
}
Question: Will FIX44 accept all previous FIX?
How can I make this agnostic about which FIX version?
public void OnMessage(QuickFix.FIX42.MarketDataSnapshotFullRefresh message, SessionID sessionID)
{
OnMessageAgnostic(message, sessionID);
}
public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh message, SessionID sessionID)
{
OnMessageAgnostic(message, sessionID);
}
public int FixVersion(QuickFix.Message message)
{
switch (message.GetString(8)) // BeginString
{
case Values.BeginString_FIX42:
return 42;
case Values.BeginString_FIX44:
return 44;
default:
throw new NotSupportedException("This version of FIX is unsupported");
}
}
public void OnMessageAgnostic(QuickFix.Message message, SessionID sessionID)
{
int count;
if (FixVersion(message)==44)
{
count = ((QuickFix.FIX44.MarketDataSnapshotFullRefresh)message).NoMDEntries.getValue();
}
}