<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML dir=ltr><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=unicode">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV id=idOWAReplyText55230 dir=ltr>
<DIV dir=ltr><FONT face=Arial color=#000000 size=2>You're welcome!&nbsp; I have 
to say that I don't quite understand why you'd want to use FIX for logging or 
IPC.&nbsp; The protocol layer of FIX has some pretty complicated retransmission 
logic and although it's not as bad as XML, it's not a very compact format.&nbsp; 
Recovering from a sequence number mismatch between the two sides of a FIX 
connection can be a real headache.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial size=2>However, to answer your other questions, it 
is possible to deal with arbitrary FIX messages, but not if they have repeating 
groups.&nbsp; It would be very painful to try to encode&nbsp;all your data 
without using repeating groups, so I don't think that helps you.&nbsp; 
The&nbsp;syntax of FIX is really fairly simplistic.&nbsp;&nbsp;It's either a 
simple&nbsp;tag =&gt; value or it's a repeating group.&nbsp; Repeating groups 
can be nested, although the code I&nbsp;pasted below won't&nbsp;quite handle 
this case.&nbsp; Repeating groups always have a starting tag that represents the 
count of elements in the group.&nbsp; Confusingly, the FIX documentation always 
uses the&nbsp;prefix "No"&nbsp;for number in the mnemonic (e.g., 
NoCounterParties, which means "number of counter parties", not that there are no 
counter parties).&nbsp; Anyway, following the starting tag, there's the contents 
of the repeating group, one instance after another, as tag =&gt; value pairs (or 
nested repeating groups).&nbsp; Without telling the parser which tags start 
repeating groups, and what the contents of the repeating group will be, there 
can be parsing ambiguities.&nbsp; Note, also, the verbosity here; every tag gets 
duplicated for every instance of a repeating group.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial size=2>I know the FIX protocol organization has 
been working on something called FAST (FIX Adapted for Streaming) that would 
resolve some of these issues, but I think it's still in the proof-of-concept 
phase.&nbsp; Anyway,&nbsp;under that model, you would certainly need to describe 
your message structure&nbsp;in detail to both sides of the 
connection.</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial size=2>Hope that helps...</FONT></DIV>
<DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV dir=ltr><FONT face=Arial size=2>Ben</FONT></DIV></DIV>
<DIV dir=ltr><BR>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> Montgomery Conner 
[mailto:montgomery.conner@gmail.com]<BR><B>Sent:</B> Sat 12/2/2006 11:21 
PM<BR><B>To:</B> Holzman, Benjamin<BR><B>Cc:</B> 
banking-pm@pm.org<BR><B>Subject:</B> Re: [Banking-pm] FIX: Financial Information 
eXchange<BR></FONT><BR></DIV>
<DIV>Thank you for you very complete response! <BR><BR>A few 
questions...<BR><BR>There's been a lot of talk at my job about using FIX to 
standardize the application infrastructure (logging, some kinds of IPC, etc. ), 
in which case many of these tags would likely be in the range of FIX tags that 
are reserved for vendor communications and are thus 
undocumented/undefined.&nbsp; For a case such as this, in your experience, is 
there any simple (yet robust) way respond to tags that have not been encountered 
before?&nbsp; That is, do you think that such a parser might need a more 
complete grammar specification than a simple hash, or is FIX itself simple 
enough that certain default responses could be engineered for ranges of tags 
regardless of whether they already resided in a local specification hash? 
<BR><BR><BR><BR>Thanks again, your insight has been very 
helpful,<BR>Montgomery<BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 12/2/06, <B class=gmail_sendername>Holzman, 
Benjamin</B> &lt;<A href="mailto:BHolzman@iseoptions.com"> 
BHolzman@iseoptions.com</A>&gt; wrote:</SPAN> 
<BLOCKQUOTE class=gmail_quote 
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">&gt; 
  I would have assumed that FIX is so large that any generic <BR>&gt; 
  implementation of it is likely to be incomplete.<BR><BR>Yes and no, I 
  think.&nbsp;&nbsp;My experience with FIX has been that 
  the<BR>application-level messages tend to be domain-specific, but 
  the<BR>protocol-level is quite stable.&nbsp;&nbsp;I have built FIX interfaces 
  to allow <BR>order entry and market data for our parimutuel matching 
  engine.&nbsp;&nbsp;I did<BR>it using the quickfix open source FIX engine 
  (actually C++ libraries) to<BR>handle the protocol and wrote a minimal C++ 
  bridge that shuttles FIX <BR>application messages back and forth to a perl 
  process over a socket.<BR><BR>I then parse the FIX messages in perl with a 
  custom FixMessage base<BR>class, run all of my application logic there, 
  creating FixMessage<BR>objects as responses and then turn them back into a 
  string to send back <BR>to the C++ bridge.&nbsp;&nbsp;I store the FIX messages 
  as a hash mapping the fix<BR>tag number to the value.&nbsp;&nbsp;I then have 
  accessor methods named after the<BR>mnemonic for each tag number.&nbsp;&nbsp;I 
  actually just have a hash (%tagMapping) <BR>in my base class with the mapping 
  and use an AUTOLOAD to create the<BR>accessors on demand.&nbsp;&nbsp;Parsing 
  the FIX message is as simple as this 
  code:<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;sub fromString 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $string = 
  shift;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my($class, 
  %tags); <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;foreach my $field 
  (split /\001/, $string) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my($tag, 
  $value) = split /=/, $field, 
  2;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($tag == 
  $tagMapping{'MsgType'}) 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$class 
  = 
  $msgType_2_class{$value};<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;next 
  if defined 
  $isHeaderTag{$tag};<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$tags{$tag} 
  = 
  $value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 
  $class-&gt;new(\%tags);<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>I have sub-classes 
  of FixMessage for each MsgType that I handle; the <BR>%msgType_2_class hash 
  has the mapping.<BR><BR>Actually, there's an additional complication to handle 
  repeating groups;<BR>the value of a repeating group is an array ref with one 
  element for each<BR>instance of the group; because tag order in repeating 
  groups matters, <BR>each instance is represented with an array consisting of 
  tag<BR>number/value pairs.&nbsp;&nbsp;Something like this: [ [ 42 =&gt; 
  'value', 165 =&gt;<BR>'another value' ], [ 42 =&gt; 'value2', 165 =&gt; 'yet 
  another' ], ... ].&nbsp;&nbsp;So <BR>my actual fromString function has more 
  logic to handle this.<BR><BR>Anyway, converting an object back to a string 
  isn't too hard; the only<BR>tricky parts are including the body length in the 
  header and computing<BR>the checksum for the trailer.&nbsp;&nbsp;My code looks 
  like this: <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;sub toString 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $this = 
  shift;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $header = 
  "8=FIX.4.4\0019=";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $body 
  = join("\001", "35=$class_2_msgType{ref 
  $this}",<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  map _toString($_, $this-&gt;{$_}), keys %$this) . 
  <BR>"\001";<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $msg = 
  $header . length($body) . 
  "\001$body";<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my $cksum 
  = 0;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cksum += ord($_) for 
  split //, $msg;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$cksum 
  = sprintf "%03d", $cksum %256; 
  <BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $msg . 
  "10=$cksum\001";<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;sub 
  _toString {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;my($key, 
  $value) = @_;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (ref 
  $value eq 'ARRAY') 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return unless 
  @$value;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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sp;&nbsp;&nbsp;&nbsp;&nbsp;return 
  "$key=$value";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} else 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>That's 
  pretty much my whole FIX message base class.&nbsp;&nbsp;The constructor 
  <BR>allows objects to be constructed from a string or from tag mnemonic 
  =&gt;<BR>value pairs.<BR><BR>I don't know if this helps you, but at least you 
  see how simple it is to<BR>handle parsing and generation of FIX messages. 
  <BR><BR>Benjamin Holzman<BR></BLOCKQUOTE></DIV><BR></DIV></BODY></HTML>