Island ECN logo

Island ECN 10th Birthday Source Code Release!

In honor of Island's tenth birthday, I am releasing the source code to the Foxpro matching engine as it appeared on 12/15/2003. This was the last version before the Java migration. While the Java version is some *very* nice code, and ran several orders of magnitude faster - this code it particularly interesting precisely because it ran on such a slow platform and is so easy to read, highlighting the idea that it is usually the architecture and algorithms that matter more then raw platform speed.

You can view the full source code here, but the only part that really matters is that actual matching engine, which is the enter2order procedure. To paraphrase...

  1. See if there was a record from a recently canceled order that we can reuse for this new order. This is hugely important because that record will likely still be in the cache and using it will be *much* faster than making a new one.
  2. Generate the sequence number and timestamp for the new order.
  3. If a minimum quantity was specified, check to see if this order could potentially be filled. If not, skip the matching part and give a U R Out.
  4. If this is a round lot only order, again check if it could possibly be filled and give a U R Out if not.
  5. Start matching! Starting at the top of the book until we either run out of shares or orders to match against.
  6. Give a U R Out for any unexecuted shares.

That's it! The while thing is less than a page long, and is twice as long as necessary because the buy and sell paths are repeated for clarity. No magic here - simple is best.


Q: But wait, what about all the messaging and sequencing and indexing?
A: This code is only the matching engine, which sits on top of plenty of other support software. All the networking and message sequencing code is written in hard code C and ASM. Any place you see INT97that is a call down to this code. But that is just plumbing. This also depends on FoxPro's ISAM indexing engine which uses a B*tree and is still impressive in its performance and reliability even 20 years later. Any place you see a SEEK, that is a call down to the FoxPro indexer.

Q: What the hell kind of code is that?
A: FoxPro for DOS version 2.6! Make fun if you want, but neither Linux nor Windows can hold a candle to MSDOS for reliability. I had DOS machines that were running continuously from 1992 until 2010. When I finally shut them down to move them to virtual machines, I found out that their hard drives and BIOS batteries were long dead, but that didn't stop them! See how long a Windows or Linux machine can run with a dead hard drive...

Q: 10th birthday? How are you counting?
A: I am counting from the day that Island2 went live with real stocks. Island2 was the second design of the matching engine and was different than Island1 (at the time just Island) because the first design was built on top of NASDAQ's SelectNet system. BTW, the first version wen live on 2/9/96.

Q: How is this code fault tolerant?
A: It isn't. The fault tolerance came from the fact there were always (at least) two copies of this program in different places on physically separate networks. If one machine (or network, or data center) died, you'd just promote the other one and everything would continue on from where it left off. I am a big fan of this shared-nothing strategy and am shocked at how many systems in the world say they are fault tolerant when they really are just moving the single point of failure somewhere else.


4/22/2011: I just saw an old friend who now works at NASDAQ and he told me that the "Jerkboy" messages still come up in NASDAQ's error logs!!!!! The code lives after 15+ years!

9/22/2011: Added an old logo image I found.