tag:blogger.com,1999:blog-147565332024-03-08T11:55:30.367+01:00Strobaek's BlogKarsten Strøbæk's thoughts about the FIX protocol, mission critical systems and high frequency trading in general.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.comBlogger25125tag:blogger.com,1999:blog-14756533.post-86720677945676995832010-08-03T07:29:00.002+02:002010-08-03T07:30:00.388+02:00Blog MovedMy blog has moved. Please follow me at http://blog.strobaek.org. Thank you.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-91896829570575099352009-08-19T21:04:00.002+02:002009-08-20T12:28:28.719+02:00Masterclass on TDD<span class="Apple-style-span" style=" line-height: 19px; font-family:'Lucida Sans Unicode', 'Lucida Grande', 'Bitstream Vera Sans', 'Trebuchet MS', Geneva, Arial, sans-serif;font-size:12px;"><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><span class="Apple-style-span" style="font-size: medium;">UPDATE: Seems like the original text did not pass the unit test. Paragraph at the end added.</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><span class="Apple-style-span" style="font-size: medium;">Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (</span><a href="http://www.artofunittesting.com/" style="color: rgb(40, 80, 144); "><span class="Apple-style-span" style="font-size: medium;">http://www.artofunittesting.com/</span></a><span class="Apple-style-span" style="font-size: medium;">), a leading tdd & unit testing book; he maintains a blog at </span><a href="http://iserializable.com/" style="color: rgb(40, 80, 144); "><span class="Apple-style-span" style="font-size: medium;">http://iserializable.com</span></a><span class="Apple-style-span" style="font-size: medium;"> (which amoung other things has critiqued tests written by Microsoft for </span><a href="http://asp.net/" style="color: rgb(40, 80, 144); "><span class="Apple-style-span" style="font-size: medium;">asp.net</span></a><span class="Apple-style-span" style="font-size: medium;"> MVC - check out the testreviews category) and has recently been on the Scott Hanselman podcast (</span><a href="http://bit.ly/psgYO" style="color: rgb(40, 80, 144); "><span class="Apple-style-span" style="font-size: medium;">http://bit.ly/psgYO</span></a><span class="Apple-style-span" style="font-size: medium;">) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy's style, be sure to also check out Roy's talk at the recent Norwegian Developer's Conference (</span><a href="http://bit.ly/NuJVa" style="color: rgb(40, 80, 144); "><span class="Apple-style-span" style="font-size: medium;">http://bit.ly/NuJVa</span></a><span class="Apple-style-span" style="font-size: medium;">).</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><span class="Apple-style-span" style="font-size: medium;"><span class="Apple-style-span" style="font-size: -webkit-xxx-large; "><span class="Apple-style-span" style="font-size: medium;">Full Details here: </span><span class="Apple-style-span" style="font-size: medium;"><a href="http://bbits.co.uk/tddmasterclass" style="color: rgb(40, 80, 144); ">http://bbits.co.uk/tddmasterclass</a></span></span></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 1.2em; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; "><span class="Apple-style-span" style="font-size: medium;"><span class="Apple-style-span" style="font-family: Verdana; line-height: normal; ">bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth £2395!) you MUST paste this text, including all links, into your blog and email <a href="mailto:Ian@bbits.co.uk">Ian@bbits.co.uk</a> with the url to the blog entry. The draw will be made on September 1st and the winner informed by email and on bbits.co.uk/blog</span></span></p></span>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-34893207109620690812009-01-24T16:47:00.002+01:002009-01-24T16:51:16.122+01:00Mac is BackI may not be Mr. Newman, but I have just re-entered the financial sector and man have I missed it. As I said in my farewell post, then this has never been a very active blog, but I hope this will change.<div>As always I plan on writing about the wonderful world of high-frequency trading, multi-threaded programming and what ever other subject that springs to mind.</div><div>Happy New Year to all.</div><div><br /></div>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-44198724727514211212008-09-07T16:00:00.002+02:002009-01-24T16:51:16.123+01:00Over and OutNot that this blog has been very active for a very long time, but now that I've left the financial sector, it will most likely die altogether - or at least change the subject.<div><br /></div><div>Thanks to my few readers.</div><div><br /></div><div>Karsten</div>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-87699963874553953392007-09-30T11:08:00.000+02:002007-10-19T19:13:35.889+02:00FPL Foreign Exchange Breakfast BriefingThursday October 18th, FPL is having a breakfast briefing on foreign exchange in London. I will be part of the panel. It is free, so show up if you have the time.<br /><br />Program can be viewed <a href="http://www.fixprotocol.org/documents/3588/Web%20Information.pdf">here</a>.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-14875566412906080632007-08-09T14:38:00.000+02:002007-08-09T14:39:54.657+02:00Layout and LablesI've changed the layout of the blog slightly, and added lables (or tags as they are know elsewhere) to most of the posts, a concept that Blogspot has finally adapted.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-6318907960196632882007-08-09T11:35:00.000+02:002007-08-09T13:48:57.628+02:00European Financial Information Summit 2007I've been invited to speak on the <a href="http://www.financialinformationsummit.com/EU/">European Financial Information Summit 2007</a> which will be held in London on the 16th October.<br /><br />The conference will assess and evaluate the current developments of market and reference data management in the banking sector in Europe.<br /><br />Subject for the speak will be: Is the Terminal dead? - Terminals vs. direct feeds.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-63248289439636111782007-07-21T16:42:00.000+02:002007-08-09T13:56:53.845+02:00Inside Market DataThe interview/article below appeared in the last issue of <a href="http://www.insidemarketdata.com">Inside Market Data</a>.<br /><br><br />----<br /><br><br />Saxo Bank Plans FAST Data for Q4<br /><br><br />Danish investment bank Saxo Bank will develop a proprietary feed handler to capture data via the FAST (FIX Adapted for Streaming data) protocol before the end of this year, and will also decide whether to use FAST for outbound distribution of quote data from its trading platform to clients, officials say.<br />Saxo is developing the new FAST feed handler to support the upcoming launch of FAST-format feeds from Nordic exchange operator OMX and the Chicago Mercantile Exchange. "We have direct connections to both OMX and the CME, so ... it would be to consume data from these sources," says Karsten Strøbæk, lead developer with Saxo. With the CME set to roll out a FAST-enabled feed later this year, the bank is planning to deploy its handler in Q4, Strøbæk says.<br />By developing a FAST feed handler, Saxo will be able to draw in both exchanges' data via the same interface - though both exchanges will maintain other versions of their feeds. OMX will roll out its FAST feed later this year alongside a new consolidated feed being built by technology partner Cicada (IMD, April 30), and the CME will maintain its proprietary RLC feed until the end of 2008 (IMD, Feb. 19).<br />Saxo does not yet have any FAST software in production, but has begun an initial test to evaluate how the protocol would fit into its architecture. However, the bank plans to allocate more development resources to the project once CME and OMX are closer to launching their feeds, and expects to complete all development work on the handler in-house. "We built our own FIX library for the message parsing and handling messages," says Strøbæk, who also serves on the Market Data Optimization Group of the FIX protocol's governing body.<br />Saxo intends to redistribute the data from the exchanges' FAST feeds to internal applications using its own proprietary data distribution platform. "We've built our own push-based system. [The data] is pushed into a central publishing system, so [any] subsystem can then subscribe to it. Everything is [stored] in-memory," Strøbæk says.<br />Once the FAST feed handler goes live, Saxo will then examine the possibility of distributing its own market data from the bank's trading platforms for equities, foreign exchange, contracts for difference and futures, using the FAST protocol. "We've built our own B2B server that supports trading in several different asset classes ... [so] one possibility would be to use FAST to distribute quotes from the platform," says Strøbæk.<br /><br><br />Jean-Paul CarbonnierStrobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-19255144108174739642007-07-01T22:59:00.000+02:002007-07-01T23:00:40.913+02:00Working from homeThe following has nothing to do with FIX or trading for anything like that, at least not directly.<br /><br />In one of the blogs I read, I came across some guidelines of what to do if you are so lucky that you can work from home. It is a good thing to work from home. You save the transportation, you can spend the morning with your kids and open the door for the plumber, should she decide to swing by.<br /><br />So here is a list of ten things you want to avoid if you are in fact working from home:<br /><br />1. Do not leave your cell phone at home if you leave the house to go shopping or eat lunch.<br />2. Pick up your phone – also if you are in the bathroom.<br />3. Arrange some short phone meetings with people at work. They hate your guts because you are working from home and this will show them your commitment to your work – also when you are working from home.<br />4. Avoid long and complex mail threads with your boss to early in the day as this may result in a call where you have to answer the question of where you are (even if you have been granted permission to work from home, then do not remind your boss of this).<br />5. Do not drink alcohol early in the day, just because you are home. This also includes beer for lunch.<br />6. Remember to send the long e-mail with lots of attached spreadsheets that your colleagues have been waiting several weeks for. This serves two purposes: 1) It demonstrates that you are in fact doing something and 2) You can be sure no one will react to what you have sent. It is far to complex and takes to much time to read so you get some peace and quiet.<br />7. Do not leave your Elvis Costello album playing on the stereo with the volume turned to full throttle when you talk on the phone to your colleagues.<br />8. Do not take the phone when you sleep. Let it wake you up. Splash then some cold water in your face. Then call back and say you were in the middle of something important. It may well be your colleagues are looking straight through you, but it was worth the try.<br />9. Try to reach your boss very late in the day, but be absolutely sure he has left the office. This is the kind of attitude a boss likes. You are so engaged in your work, that you did not consider your boss might have left for the day when you called.<br />10. Dress properly – do not work in your underwear. People will know. No one knows why, but people know if you are talking to them only wearing your undies or g-string.<br /><br />Advice here-by forwarded …Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-35044704836827777972007-06-19T04:47:00.000+02:002007-08-09T13:47:53.102+02:00Testing your FIX parserIf you want to know something about testing, you should read my friend Mark’s <a href="http://blogs.msdn.com/ploeh/rss.xml">blog</a>. He has forgotten more about all aspects of testing, than most people will ever learn. In my previous <a href="http://strobaek.blogspot.com/2007/06/quickfix.html">blog</a> I mentioned, that my group at Saxo Bank has build a test framework that allows us perform various test of our B2B server. This post will try to elaborate a little more on this test framework, but please keep in mind that this is not a post on general test guidelines. I will, as I’ve done in the past, kindly refer you to Mark for this.<br /><br />First some background to define the setting. We build our B2B server early last year. The initial offering was FX trading on streaming quotes, RFQ and orders. The testing was done by modifying an existing STP service, which we use towards our own external liquidity providers. This was easily done and enabled us to do all the required tests (unit tests, integration tests, load tests and so on).<br /><br />Since then a number of changes have been made, but mainly in the configuration of client setup, so the “old” test client did the trick quite nicely. 2 weeks ago we released a major new version of the B2B server. It now also supports CFD DMA, as well as equities and futures. As this is all something we do not market make ourselves, we had to ensure that orders placed through this new channel were routed to our existing brokers. A new interface was defined between the B2B server and the main trading system (if you are interesting in the general architecture of our main trading system, drop me a mail and I’ll reply directly; it is somewhat out-of-scope for this blog) and the B2B server was of course extended to now also “speak” exchange traded products.<br /><br />On the FIX level we did not have to do that much. As previously described we have our own FIX library which already supported all the requirements we had. However, the B2B server still had to be extended to accept the Order – Single messages (and the Amends and Cancels), and more importantly send the correct Execution Reports back, containing all the correct information and tags.<br /><br />Also, we had to extend the automated test system we have created. We call it the SAFT (Saxo Bank Automated FIX Testing) system. It allows our clients to test 24/7 (well 5.5 since we are closed from Friday evening to Sunday evening). Depending of what you send the system, you will get a pre-defined response back. This way you can test when you want to, during your own hours if you are located in another time zone, without being dependent on support from us.<br /><br />For example, should you place an order in an instrument beginning with the letter “A”, e.g. Apple, which has the symbol AAPL, it will generate the following sequence.<br /><br /><span style="font-family:courier new;">Client (C) Saxo Bank (S)<br />C New Order<br />S Execution Report (39=New, 150=New)<br />S Execution Report (39=Filled, 150=Trade)<br /></span><br />You will get the same sequence placing an order in AAL (), but should you select the symbol CBRY (Cadbury Schweppes) the flow is the following<br /><br /><br /><span style="font-family:courier new;">Client (C) Saxo Bank (S)<br />(C) New Order<br />(S) Execution Report (39=New, 150=New)<br />(C) Amend Request<br />(S) Execution Report (39=Replaced, 150=Replace)<br />(S) Execution Report (39=Filled, 150=Trade)<br /></span><br />This is where the test framework came in handy. It allowed us to test our own code/messages as well as the SAFT system. Have you seen the (bad) movie <a href="http://www.imdb.com/title/tt0244244/">Swordfish</a> with Hugh Jackman, John Travolta and Halle Berry. There is a scene where Stanley Jobson (played by Mr. Jackman) moves some blocks around to hack into a computer system. We are still working on the user interface, but this is actually how the test framework works. You can define you “test” by assembling a number of “blocks” to define the message flow, e.g. Place, New, PartFill, Fill. Or Place, New, Amend, PartFill, Replaced, Filled. Or …<br /><br />As we know before hand what the correct message looks like, we can ensure that when we add new functionality, a message is not suddenly missing a tag or the value of a specific tag is suddenly not correct any longer.<br /><br />We take the message generated by the system and compare it to the “answer”. Of course tags containing values like date and time, sequence numbers or message length will vary, but the important part is as such static<br /><br />As mentioned in my last blog we used QuickFIX to build the test framework instead of our own FIX library. This was partly done to get some knowledge of QuickFIX as a number of clients are using it, but also to test if it could replace our own down the line.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-66957425381931982302007-06-12T11:50:00.000+02:002007-08-09T13:49:05.632+02:00Screen Events in StockholmI did a presentation on FIX.5.0 in Stockholm last month (May 16th).<br /><br />The <a title="blocked::http://www.screenmarkets.com/sp_getfile.asp?v1=" href="http://www.screenmarkets.com/sp_getfile.asp?v1=17&v2=1287343" v2="1287343">presentation</a> has been put on the web for those interested.<br /><br />The focus was on the following topic areas:<br /><br />The FIX Protocol: Essential for Maximising Electronic Trading Opportunities<br /><ul><li>The benefits of electronic trading and the use of a standards</li><li>The application of electronic trading and the FIX Protocol across the Equities, Fixed Income, Derivative and Foreign Exchange asset classes </li><li>The FIX Protocol, providing messaging support within additional stages of the trade-lifecycle to streamline business practices </li><li>FIX as a Solution for MiFID </li><li>FIX 5.0, advanced functionality for an ever advancing industry </li></ul><p> </p>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-11458490190620996822007-06-08T23:07:00.000+02:002007-08-09T13:48:15.471+02:00QuickFIXIn Saxo Bank we have developed our own FIX library, instead of using the commercial offerings or the open source libraries available. From a historical perspective it was mainly due to two separate reasons: the commercial products very vastly expensive and there really was no open source libraries at the time we entered the FIX world 6 or 7 years ago, at least not of a production quality.<br /><br />There are many advantages to having build your own FIX library to handle the message parsing and the session layer, the main one being flexibility. Apart from our B2B server, which is – needless to say – using the FIX protocol, we are most often the client side in the client-server relation ship and must as much adhere to whatever “interpretation” of the protocol the server side has seemed fit to implement. In a separate post I will try to elaborate on some of the more horrifying examples of protocol violations, but we have pretty much seen it all: custom tags, extra tags, added repeated sections and stuff best clarified as message re-interpretation or re-definition. We have been able to handle it all and more importantly from a business perspective in a swift and efficient manner.<br /><br />With the release of FAST, FIX version 5.0 and the fact that we internally in the bank are moving away from C++ towards C#, we have considered using <a href="http://www.quickfixengine.org/">QuickFIX</a> instead. Not so much because we are tired of our own library, but resources are scares, and we would rather spend our time on areas where we can really add value to the business and not just fool around with the protocol (however satisfying that may be). By moving to QuickFIX we may get some “for free” – I know, I know, there is no such thing as a free lunch. If some other party extended the QuickFIX library to support FIX.5.0 we would not have to do it. It is as simple as that.<br /><br />The switch is, for obvious reasons, not going to happen just like that and not without an extensive test period to ensure that the flexibility and scalability is in order. We have just added support for CFDs to our B2B server. Several of our clients are using QuickFIX, so to get some experience with it we have developed a new test framework using QuickFIX and not our own FIX library. The test framework is build in such a way that we can unit and regression test the B2B Server, ensuring all is working as expected when new features are added (again a separate post on this).<br /><br />Our initial findings suggest that it is a major step in the right direction, compared to inventing the wheel (again) yourself. Nothing is perfect, and some unfortunate design decisions have made stuff more cumbersome, and require you to code around. My good colleague Sebastian Bargmann, who is our QuickFIX ninja has found the following:<br /><br /><em>On the positive side:</em><br />· A complete framework of all FIX versions from 4.0 to 4.4.<br />· Full source available in portable C++ (as portable as C++ can be that is)<br />· .NET and java wrappers.<br />· Most of the administrative messages are handled by QuickFIX (e.g. logon, logoff, heartbeat and so on).<br />· Automatic logging to file and database which is easily extendable to support any custom logging requirements.<br />· Automatic message storage (in QuickFIX’s own proprietary format).<br /><br /><em>On the negative side: </em><br />· It is a framework in the original meaning of the word. A very thin OO encapsulation of the protocol, but the abstraction is not “big” enough.<br />· The .NET code is an ultra thin wrapper around the framework. No delegates on top of the callback-events created by the C++ code.<br />· Everything is created as classes. There is really nothing wrong with this, but the simple types are still chars, int’s and so on. QuickFIX claims to be strongly types, but this claim is not really valid.<br />· The documentation is non-existing. You really need to read the C++ code (and show quite a lot of passion) to understand what is going on and how everything is connected.<br />· The configuration is done by an ini-file, which is difficult to use. Some of the stuff is even full of errors.<br />· The use of multiple sessions for e.g. FX trading – where you should have a trade session and a quote session – looks initially simple. It turns out, however, to be somewhat difficult because all messages have to pass through the same singleton instance of the connection handler. What this means is, that for each message coming in, you have to check what session is supposed to receive it.<br />· Special tags needs to be hard coded. If you for instance have a requirement that tag 50 is mandatory in the header, you need to add this to each and every message that is being send. This should really have been configutable.<br />· The supplied sample code is way to simple.<br /><br /><em>Conclusion:</em><br />A nice framework that needs some tweaking, but once this is done, you will end up with something usable.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-12462615789808331332007-06-05T20:34:00.001+02:002007-08-09T13:48:57.629+02:00FPL Americas Exchanges and ECNs Briefing 2007<p><span lang="da"><span style="font-family:Verdana;font-size:85%;">I'm going to be in The Big Apple from Sunday 17th until Thursday 21st.</span></span> </p><p><span lang="da"><span style="font-family:Verdana;font-size:85%;">Monday I will attend the FPL Americas Exchanges and ECNs Briefing 2007 conference (</span></span><a href="http://fixprotocol.org/documents/3327/FPL%20Exchanges%20ECNs%20web%20%20invitation.pdf"><span lang="da"><u><span style="font-family:Verdana;font-size:85%;color:#0000ff;">http://fixprotocol.org/documents/3327/FPL%20Exchanges%20ECNs%20web%20%20invitation.pdf</span></u></span></a><span lang="da"><span style="font-family:Verdana;font-size:85%;">) where I will moderate one session and take part in the panel of another.</span></span></p><p><span lang="da"><span style="font-family:Verdana;font-size:85%;">If anyone is attending and would like to meet for a drink, let me know.</span></span><span lang="en-us"></span> </p>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-12618464842357878452007-06-05T20:29:00.001+02:002007-06-05T20:29:18.437+02:00To Blog or Not To Blog<!-- Converted from text/rtf format --> <P><SPAN LANG="da"><FONT SIZE=2 FACE="Verdana">It has almost been a year since my last post.</FONT></SPAN> </P> <P><SPAN LANG="da"><FONT SIZE=2 FACE="Verdana">Reason? Partly I have been busy with my new house, the family and the job. Partly I just "ran dry". The poetic stream dryed out.</FONT></SPAN></P> <P><SPAN LANG="da"><FONT SIZE=2 FACE="Verdana">Well, I'm back (I hope).</FONT></SPAN> </P> <P><SPAN LANG="da"><FONT SIZE=2 FACE="Verdana">All the best</FONT></SPAN><SPAN LANG="en-us"></SPAN> </P> Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1155392279480371152006-08-12T16:15:00.000+02:002006-08-12T16:17:59.493+02:00EOD processing<p>When trading online in the fast paced word of international finances, then the actual trading system is, needless to say, important as this is the direct interface towards the clients, and if the experience, not only in terms of the actual product offering, but also in terms of stability and availability is not living up to what can be expected of such a system, then the clients will simply take their money and go somewhere else.<br /><br />A less obvious item is how the investment bank handles the EOD or End Of Day processing. The EOD process (I’ll just refer to this as the “EOD”) is, as the name indicates, all the stuff that goes on after the end of a trading day: clearing, settlement, netting, calculation of interests and fees and … the list goes on and on.<br /><br />There are many requirements to the EOD and I will focus on two on them: speed and service disruption. Let us begin with the later. It may seem obvious, that the EOD, should not cause a disruption in the service and availability of the online trading capabilities of the clients. This, unfortunately, is far from the case. I’ve worked with a lot of major banks, and – believe it or not – most of them are actually “down” for a period of time during their EOD. It may only be a few minutes and it may be as much as several hours, but they never the less have to stop servicing their clients during this interval.<br /><br />If we are talking Non-FX, and especially physical equities, the problem would not be so bad, as it would be possible to find a time during which, all the major markets were closed, notably after close of the US until the open of the Asian markets.<br /><br />If, however, we are talking FX and a lot of the future exchanges, then the trading goes on around the clock, from Monday morning at 05:00 Sydney time until Friday afternoon at 17:00 New York time. If you are interested in the specifics then they are:<br /><br /><strong>Open:</strong> Monday morning 05:00 Sydney.With northern wintertime this corresponds to: Sunday 19:00 Copenhagen (CET), 18:00 London, 18:00 UTC, 13:00 (1 pm) New York.With northern summertime this corresponds to: Sunday 21:00 Copenhagen, 20:00 London, 19:00 UTC, 15:00 (3 pm) New York.<br /><br /><strong>Close:</strong> Friday afternoon 17:00 (5 pm) New York.With northern wintertime this corresponds to: Friday 23:00 Copenhagen, 22:00 London, 22:00 UTC, Saturday morning 09:00 Sydney.In the week with EU, but not US daylight saving this corresponds to: Friday 24:00 Copenhagen, 23:00 London, 22:00 UTC, Saturday morning 08:00 Sydney.With northern summertime this corresponds to: Friday 23:00 Copenhagen, 22:00 London, 21:00 UTC, Saturday morning 07:00 Sydney.<br /><br />Who invented the concept of summer-/wintertime anyway …<br /><br />As Saxo Banks main area of operation is FX, we have always been geared towards being open for business in the above time interval. Once a day we down load all positions from the Front Office Trading system till the Back Office system to do the aforementioned EOD. As the positions had been processed they were uploaded back to the FO Trading system to be available for the viewing of the clients. Apart from a locking the actual positions during the upload, if they are netted out, the client will not suffer at all and trading can continue. We used to perform the download/upload once a day. At around 02:00 CET we would download all positions, and upload them again once processed as just mentioned. This MO, however, will in fact delay the correct trading information to the clients in the Asian region for a trade day, as they are several hours ahead of us – living in the CET-time zone. Something had to be done …<br /><br />This leads into the second (or first, depending on how you look at it) issue: speed. The processing of all the trades could take several hours. The original system had been devised when we did a few hundreds or maybe thousand trades a day. Now we do close to doing hundred thousand trades every day, and the number keeps going up.<br /><br />To solve these problems (timely reporting of account statements and continued scalability of the system) we have introduces a new Middle Office system (I must immediately say that I in no way can take the credit for devising or constructing this system – that should rightfully go to my esteemed colleagues in the BO Systems group).<br /><br />What is done is the following: every time a trade is registered in the FO system an “event” is send to the Middle Office system, hence a complete picture is keeps here of all client accounts. All BO operations is then carried out and the client is (almost) in real time able to see the correct and updated status of her account statement.<br />It may seem obvious that people/clients/institutions/banks wishing to participate in the global FX market can do so during its entire opening period, and that they, in real-time, should have access to on updated account statement. However, it turns out that this it no way obvious and unless the institution in question has thought good and hard about it, it may never happen.</p>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1151690657046347922006-06-30T20:02:00.000+02:002007-08-09T13:47:53.102+02:00FPL EMEA Q2I'll be in London 11-13 of July for the quarterly EMEA meeting in FPL.<br />Drop me a mail if anyone would like to go out for a drink.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1148156252616231662006-05-20T22:17:00.000+02:002007-08-09T13:56:53.846+02:00Trading Spot FX via FIX<!-- Converted from text/rtf format --> <P><SPAN LANG="da"><FONT FACE="Times New Roman">The following article will appear in the next issue of FIX Global (</FONT></SPAN><A HREF="file://www.fixglobal.com"><SPAN LANG="da"><U><FONT COLOR="#0000FF" FACE="Times New Roman">www.fixglobal.com</FONT></U></SPAN></A><SPAN LANG="da"><FONT FACE="Times New Roman">).</FONT></SPAN> </P> <P><SPAN LANG="da"><FONT FACE="Times New Roman">[Cut]</FONT></SPAN> </P> <P><SPAN LANG="da"><FONT FACE="Times New Roman">Trading Spot FX via FIX</FONT></SPAN> </P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">In this article, I will address trading spot FX using the FIX protocol. I’ll begin with some general views on using FIX for this purpose and will then look at two specific cases using FIX.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">The Global Technical Comittee is currently working on a gab analysis of FX trading. They will most likely settle upon using the<I> Market Data Request</I> message for trading on streaming quotes (SQ), only using the<I> Quote Request</I> message for request for quote (RFQ) trading. This is to differentiate between the two “ways” of trading. My own personal preference, is to differentiate between order placements and trading. For that reason, I favor using Quote Request methodology when trading on SQ (or RFQ), as the<I> Quote Response</I> message can be used, as opposed to the<I> Order – Single</I> message, which should be used with the Market Data Request methodology. The names of the two methodologies (quote vs. market data) also makes it easier to understand if we are talking about trading or order placement.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman"> </FONT></SPAN> <BR><SPAN LANG="en-us"><FONT FACE="Times New Roman">Please note, the Quote Response message is only available in version 4.4.</FONT></SPAN> </P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Regardless of the methodology used, best practice dictates that the trading session should be separated from the quote session. The reason for this is to avoid requesting old quotes using the</FONT><I> <FONT FACE="Times New Roman">Resend Request</FONT></I><FONT FACE="Times New Roman"> message, should one receive a sequence number that is too high. On the trade session it is paramount that all messages are received, but the same does not really apply on the quote session, as old quotes are basically useless.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Another best practice is that a trade should always trigger the send-out of a new quote (with a max trade amount). In this way, the receiving end is always aware of the amount of liquidity available for a given currency cross.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Prior to version 4.3, FIX did not really support FX trading. Saxo Bank has built their B2B FIX server around version 4.3, but will extend this to also offer support for version 4.4 in the near future. It is, however, quite possible to do FX trading over 4.2 as we will see below.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">At Saxo Bank we have around a dozen liquidity providers, most of which supply prices using their own proprietary API. A couple of them use FIX, however. We will look more closely at two that represent two quite different ways of utilizing the FIX protocol.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">So why is it interesting that liquidity providers use FIX when sending us prices? Can’t the proprietary API be just as good? The answer to the latter question is “yes.” There is nothing preventing us from bringing on a liquidity provider, just because they are not using FIX. That said, there are a number of advantages to using FIX (and assuming they are in compliance with the protocol).</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">From a development perspective, we are spared the hassle of “learning” and understand yet another way of integration., cutting down the time it takes to bring on the provider from months down to weeks. We actually had a case where a provider had been unable to begin integration work for another six months due to resource constraints. Instead, the provider moved from their own API to FIX and was then brought on three months earlier.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">We face the same issues from a support perspective. Business support and operations do not need to familiarize themselves with a bunch of new error messages, disconnect scenarios and general troubleshooting, if the API is entirely new to them. With FIX they know what do to if something does not work as expected. Time is saved resolving any problem that may arise, which given the fast pace of FX trading can mean the difference between winning or losing money. </FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Let’s take a look at the two case studies:</FONT></SPAN> </P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">One provider uses version 4.2 of the protocol. Quotes are delivered using the</FONT><I> <FONT FACE="Times New Roman">Market Data – Incremental Update</FONT></I><FONT FACE="Times New Roman"> message. The message has been modified with a custom tag to contain the QuoteID. The FIX protocol is an open standard, and there is nothing wrong with extending individual messages as long as this is done with custom tags - e.g. the QuoteID in the above should not have tag 117, but 5117. When hitting a trade, the</FONT><I> <FONT FACE="Times New Roman">New Order – Single</FONT></I><FONT FACE="Times New Roman"> message is used where the order type is set to previously quoted (40=D). Price, amount and QuoteID is also returned. If the trade is good, an Execution Report is sent back with ExecType equal to Fill (150=2) and OrderStatus equal to Filled (39=2).</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Another provider is using version 4.4 and what I refer to as the Quote Request methodology. After the initial logon a number of</FONT><I> <FONT FACE="Times New Roman">Quote Request</FONT></I><FONT FACE="Times New Roman"> messages are sent. These indicate which currency pairs and for what amounts we would like to receive quotes. Multiple bands are supported, leading to a steady stream of quote messages from the provider. Whenever we wish to trade on a quote, the</FONT><I> <FONT FACE="Times New Roman">Quote Response</FONT></I><FONT FACE="Times New Roman"> message is used, with the quote response type set to hit/lift (694=1). If the trade is good, the provider responds in an Execution Report with ExecType equal to Trade (150=F) and OrderStatus equal to Filled (39=2).</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">The amount of data being sent over the wire in the two cases is almost the same. The Quote message is slightly smaller than the Market Data message, but only by a few tags.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">As can be seen, there is nothing to stop companies from utilizing the FIX protocol for FX trading. In fact, since FIX is becoming – if not already so – the de-facto standard for all electronic trading, there is much to be gained from moving to FIX, in terms of faster time-to-market and reduced operating costs.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">--</FONT></SPAN> </P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Karsten Strøbæk is Team Lead and Lead Developer for the STP Interfaces group at Saxo Bank. The group’s responsibilities include the development, maintenance and troubleshooting of all trading connections and order routing connections out of the bank. Instead of using a commercial offering, the bank has developed its own FIX library. Karsten writes a blog on FIX and high frequency trading in general (strobaek.blogspot.com)</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">Saxo Bank is a global investment bank, based in Copenhagen, Denmark. Founded in 1992, Saxo Bank has rapidly become a well-known specialist in online trading in the international capital markets. A fully licensed, EU-regulated financial institution, the bank is recognized for its award-winning information, execution and risk management platform, the SaxoTrader, which consistently earns top prizes in significant industry survey, poll and awards events.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT FACE="Times New Roman">The Bank’s business model, which emphasizes facilitation, decidedly promotes partnerships with liquidity providers and distributors alike. As a result, Saxo Bank has emerged as a leading White Label Partner, able to accelerate licensed financial institutions’ time-to-market as providers of online trading for their client base. Saxo Bank serves clients in more than 120 countries, supports sales and service in 35 languages and offers its platform in 20 languages. </FONT></SPAN><A HREF="file://www.saxobank.com"><SPAN LANG="en-us"><U><FONT COLOR="#0000FF" FACE="Times New Roman">www.saxobank.com</FONT></U></SPAN></A><SPAN LANG="en-us"><FONT FACE="Times New Roman">.</FONT></SPAN></P> <P><SPAN LANG="en-us"><FONT COLOR="#0000FF" SIZE=2 FACE="Verdana">Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1143748132563132932006-03-30T21:47:00.000+02:002007-08-09T13:48:34.088+02:00FAST Reference Code for C++I have been asked to make the reference code for C++ for the FAST protocol. The reference code – and all other information about the FAST protocol – can be found at <a href="http://www.fixprotocol.org/fast">www.fixprotocol.org/fast</a>.<br /><br />This work will most likely be done sometime this summer.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1142975750958040822006-03-21T21:45:00.000+01:002006-03-26T21:45:12.070+02:00Lock free cachingAll developers writing multi-threaded, real-time mission critical systems has encountered the problem of reading from a cache and updating it at the same time. This is something that should be avoided as it will generally lead to exceptions, but how do you get your cache updated without introducing concurrency problems in your code?<br /><br />The following will address this problem and give a (well known) design to solve it. The small code samples are in C++, but any language will do. I will also show a way to check for updates without reading all values (we here assume, that the values are stored in a database), hence keeping the load on the database to a minimum.<br /><br />Please add the usual disclaimers about not being production coded, that you have to add error checking, &c. I must also apologize for the layout; when I have more time, I will create a template/style to accommodate code snippets.<br /><br />Assume that you have a map of some sort.<br /><br /><span style="font-family:courier new;color:#6600cc;">typedef std::map<key,value> CMapCollection;<br />CMapCollection m_colMyMap[2];<br />long m_lMapCacheIdx;<br /></span><br />As can be seen we declare an array of two maps. This is to hold the active and passive map. The <span style="font-family:courier new;color:#6600cc;">m_lMapCacheIdx</span> will hold the index of the active cache, so when we wish to look up a key in the map, we do the following:<br /><br /><span style="font-family:courier new;color:#6600cc;">CMapCollection::iterator it = m_colMyMap[m_lMapCacheIdx].find(theKey);</span><br /><br />We can now do our lookups in the active map, and update the passive map without introducing concurrency problems in the form of locks.<br /><br />My UpdateCache() function will connect to a database, retrieve a recordset and update the cache accordingly.<br /><br /><span style="font-family:courier new;color:#6600cc;">bool CMyClass::UpdateCache( void )<br />{<br />bool bRet = m_pConnection->AccessDatabase(...);<br /><br />// Find the passive cache<br />const long lPassiveIdx = m_lMapCacheIdx ? 0 : 1;<br /><br />// Clear the passive cache<br />m_colMyMap[lPassiveIdx].clear();<br /><br />// Loop around the recordset returned by the call to AccessDatabase(...) and<br />// update the, just cleared, passive cache.<br /><br />// Switch active cache<br />if ( bUpdateOk )<br />{<br />m_lMapCacheIdx = lPassiveIdx;<br />}<br /><br />return true;<br />}</span><br /><br />We periodically want to check for new values, so we have a worker thread timing out with a given interval, here 1000 ms.<br /><br /><span style="font-family:courier new;color:#6600cc;">unsigned long CMyClass::_WorkerThread ( CMyClass *pThis )<br />{<br />HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);<br />if (hRes != S_OK) ErrorExit( _T("CoInitializeEx failed"), hRes );<br /><br />unsigned long ulRes = pThis->WorkerThread();<br /><br />CoUninitialize(); // Closes the COM library on the current thread, unloads all DLLs loaded by the thread, frees any other resources that the thread maintains, and forces all RPC connections on the thread to close<br /><br />return ulRes;<br />}<br /><br />unsigned long CMyClass::WorkerThread()<br />{<br />while ( true )<br />{<br />unsigned long ulEvent = WaitForSingleObject(m_hEvent, 1000); // Timeout every sec<br />switch (ulEvent)<br />{<br />case WAIT_TIMEOUT:<br />UpdateCache();<br />break;<br />case WAIT_OBJECT_0: // Something in queue or stop flag set<br />if (m_bStopFlag)<br />{<br />return ThreadExitCleanUp(0);<br />}<br />break;<br />default:<br />return ThreadExitCleanUp(-1);<br />break;<br />} // end switch on ulEvent<br />} // end while true<br />}<br /></span><br />To ease readability I will reduce my UpdateCache function to the following:<br /><br /><span style="font-family:courier new;color:#6600cc;">bool CMyClass::UpdateCache( void )<br />{<br />bool bRet = m_pConnection->AccessDatabase(...);<br />// Do the update stuff<br />return true;<br />}</span><br /><br />I've declared my UpdateCahce function as a bool; old habit as we do not yet use the return value; it might as well have been declared as void.<br /><br />So every second we call our UpdateCache() function. However, we may not want to actually check for updates this frequently.<br /><br />We will add some more code to UpdateCache. Assume the following:<br /><br /><span style="font-family:courier new;color:#6600cc;">m_llUpdateTime</span> is declared as <span style="font-family:courier new;color:#6600cc;">__int64</span>. This is the time stamp for the last update.<br /><span style="font-family:courier new;color:#6600cc;">UtcTimeNow()</span> is a helper function that sets the UTC time (always use UTC when doing anything with time and you want to ensure it is working over different time zones).<br /><br /><span style="font-family:courier new;color:#6600cc;">bool CMyClass::UpdateCache( void )<br />{<br />__int64 tNow;<br />UtcTimeNow(&tNow);<br /><br />if ( (tNow < m_llUpdateTime ¦¦<br />(tNow - m_ llUpdateTime)/TSW_SECONDS_TO_NANOSEC >= 900))<br />{<br />m_pConnection->AccessDatabase(...);<br />// Do the update stuff<br />m_ llUpdateTime = tNow;<br />}<br />return true;<br />}</span><br /><br />We now only access the database every 15 minutes (900 seconds), but we still do it regardless of whether any rows in the database has been updated or not. If we are reading in large amounts of data this is really a waste of resources.<br /><br />To accommodate this last requirement, I will use a design pattern of first checking a timestamp in another (small) table and only if this timestamp is more recent than when I last read my data, I will access the data base. The database schema for the TableUpdates table is: TableName (varchar), Timestamp (datetime).<br /><br />The member variable <span style="font-family:courier new;color:#6600cc;">m_TableUpdate</span> is a pointer to a class maintaining a connection to the database. It also has two helper functions: <span style="font-family:courier new;color:#6600cc;">CheckForTableUpdate()</span> and <span style="font-family:courier new;color:#6600cc;">AcceptTableUpdate()</span>. <span style="font-family:courier new;color:#6600cc;">CheckForTableUpdate()</span> takes a table name as input and returns a bool if the time stamp for that table has been updated since last time we checked. <span style="font-family:courier new;color:#6600cc;">AcceptTableUpdate()</span> sets an internal timer for when the last update was read. This design allows us to use the same class for checking multiple tables for updates.<br /><br />Update our UpdateCache() function to the following:<br /><br /><span style="font-family:courier new;color:#6600cc;">bool CMyClass::UpdateCache( void )<br />{<br />LPTSTR TableUpdateTag = _T("Exchanges");<br />__int64 tNow;<br />UtcTimeNow(&tNow);<br /><br />if ( (tNow < m_llUpdateTime ¦¦<br />(tNow - m_ llUpdateTime)/TSW_SECONDS_TO_NANOSEC >= 900))<br />{<br />bool bIsUpdated = false;<br />if ( !m_TableUpdate.CheckForTableUpdate(TableUpdateTag, &bIsUpdated) )<br />{<br />bIsUpdated = true; // We force a read if the check failed<br />// Some error logging<br />}<br /><br />if ( bIsUpdated )<br />{<br />if ( !m_TableUpdate.AcceptTableUpdate(TableUpdateTag) )<br />{<br />// Some more error logging<br />}<br />m_pConnection->AccessDatabase(...);<br />// Do the update stuff<br />m_ llUpdateTime = tNow;<br />}<br />}<br />return true;<br />}</span><br /><br />We have now achieved what we wanted, namely to only read the (map)values from the database when they have been updated.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1142247510724320422006-03-13T11:54:00.000+01:002006-03-31T19:58:53.750+02:00Mark Seemann has a blogMy good friend (and former colleague back when I did consultancy work in the happy dot-com era) Mark has a <a href="http://blogs.msdn.com/ploeh/">blog</a> about .NET design and programming. Read it! Mark is a lot better writer that I am, and he knows this stuff. Personally I don't understand half of what he is writing about, but that is more an issue with my lack of .NET knowledge that the quality of the contributions.<br /><br />We actually meet each other back when both of us studied economics at the University of Copenhagen. If I remember correctly it was a class in game theory, and as usual Mark had to explain the finer details to me.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com1tag:blogger.com,1999:blog-14756533.post-1142200829276694612006-03-12T22:43:00.000+01:002007-08-09T13:47:53.103+02:00The FAST Protocol<p>The Market Data Optimization Working Group (aka MDOWG) under FLP has recently released the first version of the FAST protocol. And it really seems like FAST is fast. The initial POCs show improvements of up to 70% compared to “nativeâ€� FIX.<br /><br />But what is FAST (Fix Adapted for STreaming) and how will it influence the existing FIX session? This blog entry will try to elaborate on these questions. I have looked at the material supplied at the FAST Technical Summit held at the London Stock Exchange back in January.<br /><br />The FAST protocol consists to two specifications: <em>FAST Field Encoding Specification</em> (FAST CODEC) and <em>FAST Serialization Specification</em> (FAST SERDES). The first has to do with sending fewer tags, and hence less data over the wire, the second has to do with compression of the shorter message before sending it.<br /><br />There are two approaches to implementing FAST: as an integrated part of the FIX session or as a separate FAST session layer. It is recommended to use the later as this will have a minimal or no impact on the existing applications. An illustration of the message stack could be the following:<br /><br />Business application<br />FIX message parsing<br />FAST Field encoding/decoding<br />FAST Wire format encoding/decoding<br />TCP<br />IP<br /><br />But why FAST at all? We have in the last few years seen dramatically increased market data volumes leading to high band width and processing costs, and there is no doubt that this trend will continue, as the different exchanges add more and more new products to their offerings. It is then easy to see, that if FAST offer up to 70% better utilization of your existing line capacity, you may well be able to stick with the T1 line you have, and not invest in a new T3 line.<br /><br />If we should look at the details of the FAST protocol we could begin by looking at the basic feature set making up the protocol.<br /><br />First of all it has been designed and optimized for message streams. This does not mean that FAST can not be used for other purposes, e.g. order routing as we shall see later. FAST is content aware. This requires knowledge about the different messages structures, which on one hand leads to less flexibility, but on the other hand to a much more efficient protocol. FAST uses a byte-oriented binary representation and variable-length fields. It has been defined that each message must contain at least one or more fields, hence no fields, no message, nothing to send. The last feature is the use of a presence map which enables efficient use of default values.<br /><br />A basic FAST Implementation consists of the following:<br /></p><ul><li>A simple configuration in which the Sender encodes the data and the Receiver decodes the data. </li><li>No additional session management is needed </li><li>FAST-encoded data is sent directly over the native transport. </li><li>Templates are sent out-of-band or statically downloaded. </li><li>Templates are defined in a simple, human-readable format </li></ul><p align="left"><br />At this point we have to define a Template. We need to understand how they are defined and used by FAST.<br /><br />In general, a template is used to specify the structure, data types, and field operations of a message type. It specifies all fields included in a message as well as the sequence of those fields. If required it may also support repeating groups which allow a single message to efficiently convey multiple instructions: bids, asks, trades, etc.<br /><br />When planning to encode a data feed the user should begin by converting standard message formats to temples, as all message types must be expressed in the proper template format.<br /><br />When the template is defined, FAST uses it in a number of ways. First of all it provides the required content-awareness as described in the basic feature set. It allows FAST to encode and decode on a field by field basis and it provides critical information for both field encoding and serialization operations. The field encoding instructions given in the template are conveyed to FAST which performs the appropriate field encoding operations. Last data type descriptions are specified in the template which informs the Serializer whether a field is a string, an integer or a decimal value.<br /><br />Templates can be defined using two different notations known as the <em>Compact</em> notation and the <em>XML</em> notation. I will only look at the former.<br /><br />The structure of the Compact Notation is<br /><br /><span >((tag number)(data type)(field encoding operator))</span><br /><br />Please note, that this is not an extensible solution and has known limitations, which is why the XML format is also proposed. I just prefer the compact notation as it is a straightforward way to define a template.<br /><br />A summary of the Field Encoding Operators is given below:<br /><br />! : Default Coding – default value per template<br />= : Copy Coding – copy prior value<br />+ : Increment Coding – increment prior value<br />- : Delta Coding – numeric or string differential<br />@ : Constant Value Coding – constant value specified in template<br />* : Implicit Value Coding – implies field values<br /><br />The Data Type Descriptors is defined as:<br /><br />s : string<br />u : unsigned integer<br />U : Unsigned integer supporting a NULL value<br />I : Signed integer<br />i : Signed integer supporting a NULL value<br />F : Scaled number<br /><br />An example is in order to see how this works. Let us look at an Order – Single (35=D), just to stress the point that FAST can be used for other purposes than market data. Please note that only the logical result of the field encoding is shown. The serialization will compact the message even further and produce the physical message to be sent.<br /><br />“<span style="font-family:courier new;">[0]</span>â€� represents a basic field delimiter.<br />The template on compact form is the following:<br /><br /><span style="font-family:courier new;">8s@FIX.4.2[0]9u[0]35s@D[0]49s=[0]56s=[0]34u[0]52s-[0]11s-[0]54s=[0]38u=[0]40s=[0]21s=[0]55s=[0]44F=[0]10u</span><br /><br />We want to place a Limit order to Buy 100 Microsoft (MSFT.OQ) at the price of 24.75. This will result in the following order as FIX. To ease readability we only identify the instrument by tag 55 (Symbol) and not the usual tag 22 (IDSource), tag 48 (SecurityID), and tag 100 (ExDestination):<br /><br /><span style="font-family:courier new;">8=FIX4.2[0]9=108[0]35=D[0]49=SENDER[0]56=TARGET[0]34=7[0]52=20060312-21:53:05[0]11=12345678[0]54=1[0]38=100[0]40=2[0]21=1[0]55=MSFT.OQ[0] [0]44=24.75[0]10=120[0]</span><br /><br />If we FAST field encode the above, we will save around 41% before serialization:<br /><br /><span style="font-family:courier new;">[0]108[0][0]SENDER[0]TARGET[0]7[0]20060312-21:53:05[0]12345678[0]1[0]100[0]2[0]1[0]MSFT.OQ[0]24.74[0]120</span><br /><br />The second order we want to place is a Limit to Sell 100 Apple (AAPL.OQ) at 12.55. This will give the following FIX order:<br /><br /><span style="font-family:courier new;">8=FIX4.2[0]9=108[0]35=D[0]49=SENDER[0]56=TARGET[0]34=8[0]52=20060312-21:53:15[0]11=12345679[0]54=2[0]38=100[0]40=2[0]21=1[0]55=AAPL.OQ[0][0]44=12.55[0]10=129[0]</span><br /><br />When we FAST field encode the second order we save 73% before serialization:<br /><br /><span style="font-family:courier new;">[0]105[0][0][0][0]8[0]15[0]9[0]2[0][0][0][0]AAPL.OQ[0]12.55[0]129</span><br /><br />We can likewise give the template for the corresponding execution report message. On compact form it can be written as:<br /><br /><span style="font-family:courier new;">8s@FIX.4.2[0]9u[0]35s@8[0]49s=[0]56s=[0]34u[0]52t-[0]11s-[0]54s=[0]38u=[0]40s=[0]55s=[0]44F=[0]37s-[0]17s-[0]20s=[0]39s=[0]150s=[0]59s=[0]31F=[0]32u=[0]14u=[0]6F=[0]151u=[0]60s-[0]58s=[0]10u</span><br /><br />The accept message - Execution Report (New) - for our order place request for the Microsoft equities is as FIX:<br /><br /><span style="font-family:courier new;">8=FIX.4.2[0]9=204[0]35=8[0]49=TARGET[0]56=SENDER[0]34=6[0]52=20060312-21:53:05[0]11=12345678[0]54=1[0]38=100[0]40=2[0]55=MSFT.OQ[0]44=24.75[0]37=OrderID001[0]17=ExecID1[0]20=0[0]39=0[0]150=0[0]59=0[0]31=0[0]32=0[0]14=0[0]6=0[0]151=100[0]60=20060312-21:53:06[0]58=New order[0]10=033[0]</span><br /><br />Again we will FAST field encode the FIX message. This will give us a saving of 39% before serialization<br /><br /><span style="font-family:courier new;">[0]204[0][0]TARGET[0]SENDER[0]6[0]20060312-21:53:05[0]12345678[0]1[0]100[0]2[0]MSFT.OQ[0]24.75[0]OrderID001[0]ExecID1[0]0[0]0[0]0[0]0[0]0[0]0[0]0[0]0[0]100[0]20060312-21:53:06[0]New order[0]033</span><br /><br />The accept message of the second order as FIX is:<br /><br /><span style="font-family:courier new;">8=FIX.4.2[0]9=204[0]35=8[0]49=TARGET[0]56=SENDER[0]34=7[0]52=20060312-21:53:15[0]11=12345679[0]54=2[0]38=100[0]40=2[0]55=AAPL.OQ[0]44=12.55[0]37=OrderID002[0]17=ExecID2[0]20=0[0]39=0[0]150=0[0]59=0[0]31=0[0]32=0[0]14=0[0]6=0[0]151=100[0]60=20060312-21:53:18[0]58=New order[0]10=043[0]</span><br /><br />As was the case for the actual place order request, it is for the second execution report that we really see the advantage of FAST. If we field encode the second response we save around 78% before serialization.<br /><br /><span style="font-family:courier new;">[0]204[0][0][0][0]7[0]15[0]1[0]2[0][0][0]AAPL.OQ[0]12.55[0]4[0]2[0][0][0][0][0][0][0][0][0][0]18[0][0]043</span><br /><br />After this nobody should be in doubt about the strength of the FAST protocol and the enormous potential it holds to optimize the existing FIX session.</p>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1139868311511322432006-02-13T22:55:00.000+01:002007-08-09T13:47:53.103+02:00FIX for Streaming Quotes: version 4.3 vs. 4.4<p>When using FIX for trading FX Spot on streaming quotes one must choose between the two latest versions of FIX: 4.3 or 4.4. Version 4.2 does not really support spot trading, as several of the required messages are not defined. I've come across some solutions where the <em>MarketData</em> message was modified to contain e.g. a <em>QuoteID</em>. This does work, but one can not really claim to be compliant with the protocol as custom tags have to be introduced. FIX4.2 is really for order routing and that's it.<br /><br />Should one then go for FIX4.3 or FIX4.4? Our own B2B FIX server is build around FIX4.3. This is mainly because it seemed to be the most commonly used version at the time development began, and it works quite well, but if I should start today, I would definitely got for FIX4.4 as it is much more elegant for spot trading. I will try to quantify that statement below.<br /><br />Both versions support the <em>QuoteRequest</em> and <em>Quote</em> messages, hence the subscription to and receiving of the quotes are the same. The difference lay in the way you trade on these quotes.<br /><br />For FIX4.3 you use version 4.2 syntax using the <em>Order - Single</em> message (35=D), with the OrdType set to <em>Previously quoted</em> (40=D).<br /><br />An example of an Order - Single message if you wanted to Buy 5.000.000 EUR/USD @ 1.3364 could be (tag 117 is the QuoteID):<br /><br /><span style="font-family:courier new;"><br />[Standard Header]<br />11=1702843[0]64=20060209[0]21=1[0]55=EUR/USD[0]460=4[0]54=1[0] 60=20060207-10:00:29[0]38=5000000[0]40=D[0]44=1.3363[0]117=STE-EURUSD-2006-2-7:10.0.28:45-5000000<br />[Standard Trailer]<br /></span><br />[0] used to represent the basic field delimiter.<br /><br />Note, that I have included tag 460 to identify the Product as Currency (4). This is pretty basic stuff really, if you come from the cash equities or fixed income world.<br /><br />If you were to trade FX on streaming quotes using FIX4.4 you would use the <em>QuoteResponse</em> message (35=AJ) - you could in principle also still use the FIX4.2 syntax described above. The advantage of using this syntax is, that apart from not being confused whether you were placing an order or making a trade is, that you are able to unsubscribe to a quote stream. The tag <em>QuoteRespType</em> (694) should be set to "1" if you want to Hit or Lift the quote and to "6" if you want to Pass on it, that is stop the stream.<br /><br />A QuoteResponse message could look like the following:<br /><br /><span style="font-family:courier new;"><br />[Standard Header]<br />693=2476010[0]117=STE-EURUSD-2006-2-7:10.0.28:45-5000000[0]694=1[0]11=2476010[0]55=EUR/USD[0]54=1[0]38=5000000[0]44=1.3363<br />[Standard Trailer]</span></p><br /><br /><p>As can be seen, then the QuoteResponse message is also slightly more compact that the Order - Single message.</p><p></p>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1138142635560358462006-01-24T23:43:00.000+01:002007-08-09T13:50:21.892+02:00ResendRequest<p><span style="font-family:Times New Roman;">One of the problems with the FIX protocol is the handling of missing messages. If you receive a message with a sequence number higher than expected, the protocol dictates that you should send a ResendRequest, requesting the messages from the missing message (to infinity). As the messages are to be handled sequentially all process of incoming messages should stop, until the gap has been filled.</span></p><p><span style="font-family:Times New Roman;">This modus operandi works fine for trade and order related messages and executions, but what about quotes? Or market data? Are you really interested in receiving a bunch of old quotes that you can't trade on anyway, because they are ... old?</span></p><p><span style="font-family:Times New Roman;">To overcome this, we have adopted the following best practice for our own B2B Server: we use two FIX sessions, one for the quotes and one for the trades. The benefit of this is that the client does not have to request missing messages on the quote session, but can simply accept the incoming sequence number as being the next in line, even if it is too high according to his or her own book keeping. At the same time, we will not send out old quotes, but simply a SessionReset(GapFill) should we receive a ResendRequest. Obviously ResendRequests should be made on the trade session.</span></p><p><span style="font-family:Times New Roman;"></p><br /></span>Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1137963021264143302006-01-22T21:50:00.000+01:002007-08-09T13:47:22.486+02:00FIX PrimerI've been asked to write a FIX primer. What versions to use for order routing or FX spot trading, best practices concerning the inner workings of the protocol, number of sessions to use in different scenarios and so on.<br /><br />As this is not a simple task, I will try to post "chapters" here when I'm done along with general views on high frequency trading and order routing. Stuff from my day to day life others may find useful. I've integrated with more than 20 financial institutions and exchanges. Some have done a really good job, others not quite so. This blog is also about these connections and my experiences.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0tag:blogger.com,1999:blog-14756533.post-1122150346866691012005-07-23T22:25:00.000+02:002006-01-20T09:06:06.426+01:00First EntryOK. We are ON. First blog from me.Strobaek's Bloghttp://www.blogger.com/profile/17280307721253409079noreply@blogger.com0