Getting to millions of orders per second is fairly trivial. Io is normally a bigger problem.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Btw when working in it (algo trading not market but same data). I used an array list for order book (insertion sort) tried lots of other fancy stuff but couldnt beat it for actual data almost everything you care about and 90+% of orders happen in the top 5 or so positions.
There used to be a pretty good spec and writeup of a reasonable problem + data structure here for a university competition called quantcup.
The site is gone but the way back machine remembers the spec:
http://web.archive.org/web/20110310171841/http://www.quantcup.org/home/spec
The winning entry is still available:
https://dl.dropboxusercontent.com/u/3001534/engine.c
The code is illustrative at best. Mr T points out some issues but the plethora of order cancellation, replace and rejection logic take a lot of care to get right.
A good resource for the states/transitions are contained in the FIX protocol documentation appendices but even they are incomplete and exchanges and brokers tend to deviate so YMMV.
Cheers,
Darach.
Order books tend to be cache sensitive since the actual instructions involved are usually pretty cheap. So anything you can do to minimize how much data is touched and/or improve locality will help nicely. Some basic things for java would be use intrusive pointers rather than wrapper objects, avoid java generics (e.g. don't use jdk array list and the like), try to keep code devirtualized unless you verify that JIT does it for you in the way you want, minimize type hierarchy of objects involved, use object pools rather than letting GC manage order book objects, etc. This is one of those things where the individually little inefficiencies that java adds really add up, so keeping abstraction to a minimum helps (unfortunately java has some weak spots in terms of zero cost abstractions).
I agree with Greg that most activity in an order book is centralized around the top, and so you can use that knowledge to keep things simpler and faster for common case.
sent from my phone
Sorry, meant to include this link for you: https://web.archive.org/web/20110314042933/http://howtohft.wordpress.com/. There's an overview of a design there that's a good start.
sent from my phone