<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>RPRF Road Trip</title>
    <link>http://www.rprf.co.uk/</link>
    <description>The RPRF Road Trip</description>
    <language>en</language>
    <atom:link href="http://www.rprf.co.uk/rss.php" rel="self" type="application/rss+xml" />
    <item>
      <title>State of the Nation</title>
      <link>http://www.rprf.co.uk/article.php?id=9376074</link>
      <description>Well, that&#039;s about it for the weekend...<br />
<br />
The FIX part seems reasonably robust, but still isn&#039;t doing much validation. The network part is fairly basic, but works. The exchange... well... it&#039;s OK for a single client, but seems to have some issues with concurrency and can occasionally deadlock.<br />
<br />
I&#039;ve had two clients trading with each other, and I&#039;ve learned a lot about the protocol - and been surprised by how little documentation is available for some of this. Which is as much as I could have hoped for in a weekend, really.<br />
<br />
The biggest tasks still to handle are:<br />
* Validation of the FIX messages<br />
* The remainder of the FIX4.0 standard<br />
* A proper multithreaded exchange<br />
* Rearranging the code into subpackages<br />
* Implementing the FIX4.1 and 4.2 protocols<br />
<br />
<br />
As promised, the code - such as it is - is available here. I&#039;ve decided to call it FIXME as a pun on the protocol and the state of the code. I&#039;m releasing it as public domain, so if - God forbid - anyone wants the code, they can have it without attribution.</description>
      <pubDate>Sun, 08 Feb 2009 21:49:51 +0000</pubDate>
      <guid>http://www.rprf.co.uk/article.php?id=9376074</guid>
    </item>
    <item>
      <title>Order entry</title>
      <link>http://www.rprf.co.uk/article.php?id=2786801</link>
      <description>Well, the client can now put orders (New Order - Single, message type &quot;D&quot;) into the exchange... sadly this is a bit useless as it&#039;s only able to trade against itself at the moment.<br />
<br />
Next step is to put in execution reports (type &quot;8&quot;, spammed to all clients) and we should be getting somewhere.</description>
      <pubDate>Sun, 08 Feb 2009 18:53:41 +0000</pubDate>
      <guid>http://www.rprf.co.uk/article.php?id=2786801</guid>
    </item>
    <item>
      <title>... as the client said to the server!</title>
      <link>http://www.rprf.co.uk/article.php?id=9599566</link>
      <description>Today I&#039;ve spent quite a lot of time trying to make the repeated groups work neatly, and it&#039;s just about there now.<br />
<br />
Far more importantly, I&#039;ve integrated the FIX stuff with the network stuff and have a working logon sequence:<br />
<br />
Constructing FIX engine: CLIENT<br />
About to send: 8=FIX.4.0|9=42|35=A|49=CLIENT|56=SERVER|34=1|98=0|108=30|10=186|<br />
Got a message of type A<br />
Handling logon message<br />
BeatingHeart constructor(delay = 4 seconds)<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=2|10=142|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=3|10=143|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=4|10=144|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=5|10=145|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=6|10=146|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=7|10=147|<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=8|10=148|<br />
Got a message of type 0<br />
About to send: 8=FIX.4.0|9=30|35=0|49=CLIENT|56=SERVER|34=9|10=149|<br />
About to send: 8=FIX.4.0|9=31|35=0|49=CLIENT|56=SERVER|34=10|10=190|<br />
<br />
That output is currently missing 52 (SendingTime) tags, but that&#039;s easy enough to put in. There are two heartbeat threads running - one giving the server a kick (message type &quot;0&quot;) every 4 seconds, and one doing the same to the client every 30, as specified by the logon (&quot;A&quot;) messages.<br />
<br />
So, now to connect this to my order book...</description>
      <pubDate>Sun, 08 Feb 2009 17:14:18 +0000</pubDate>
      <guid>http://www.rprf.co.uk/article.php?id=9599566</guid>
    </item>
    <item>
      <title>Exchanging Places</title>
      <link>http://www.rprf.co.uk/article.php?id=1449078</link>
      <description>Woo! After some rather fiddly code, I now have an order book working.<br />
<br />
Most of the problems seemed to come about from having to handle (near-)empty bid/offer lists at the start of the day&#039;s trading - if your first orders are a market-buy and a market-sell, at what price do you match them?<br />
<br />
So, anyway, I&#039;ve got an order book class for a single stock, which supports market/limit/stop/stop-limit order types and (I hope) correctly handles priority with unblocking stop orders.<br />
<br />
For time, I&#039;ve decided to use a (lock-protected) serial number: every order that comes in locks/increments/unlocks the timer, forcing serialisation of requests. None of this two-orders-the-same-age business!<br />
<br />
Obviously generalising this to a full exchange is as simple as creating a collection of order books - load balancing isn&#039;t an issue when cheating at toy problems ;-)<br />
<br />
So, about the biggest thing I&#039;m missing now is the session - the network layer is there, as is the FIX engine, and now the server-side (and even some basic client-side) of the trades. Time to glue it all together!<br />
<br />
<br />
I figure there&#039;s now about a month&#039;s work on my &quot;TO DO&quot; list just to get this stuff up to a decent standard, but my goal for the weekend was to have a couple of clients making random trades on a toy exchange, which is certainly looking plausible.</description>
      <pubDate>Sat, 07 Feb 2009 22:10:15 +0000</pubDate>
      <guid>http://www.rprf.co.uk/article.php?id=1449078</guid>
    </item>
    <item>
      <title>Round trip!</title>
      <link>http://www.rprf.co.uk/article.php?id=4373108</link>
      <description>OK, so now I&#039;ve got messages doing round trips between strings and my internal data model (in fact, string -&gt; data -&gt; string -&gt; data -&gt; string for verification). Yay!<br />
<br />
The string in question is:<br />
&quot;8=FIX.4.0|9=65|35=A|49=SERVER|56=CLIENT|34=177|52=20090107-18:15:16|98=0|108=30|10=060|&quot;<br />
with the |s replaced by SOH (\u0001) characters.<br />
<br />
I&#039;ve implemented all 139 field types (1~140, with 101 undefined) in the FIX4.0 specification, using a type hierarchy derived from the 5.0SP1 spec, though only for basic static checking - almost no validation yet. Dynamic checking (e.g. &quot;tag 64 required when tag 63=6 or 63=8, but optional otherwise&quot;) will add a fair chunk of work, so I&#039;m leaving that for now. Repeated groups are supported but need a little tidying up in the parser.<br />
<br />
Next big tasks on the horizon are the session model (logon, heartbeats, responding to requests, termination) and implementing an order book for the exchange.<br />
<br />
But, for now, I&#039;m having a beer. Black Sheep - Riggwelter (5.7% abv), in fact.</description>
      <pubDate>Sat, 07 Feb 2009 14:30:46 +0000</pubDate>
      <guid>http://www.rprf.co.uk/article.php?id=4373108</guid>
    </item>
  </channel>
</rss>
