StreamInsight: Can We Build An ECN?
Eurex is an example of an ECN. Given that my Market Strategy Engine (MSE) effective provide agent style strategy execution, the next logical question is whether an ECN Proof Of Concept (POC) can be build with StreamInsight. I suspect most ECN’s are not using CEP engines, but custom built C++/Java applications, but given this is a POC idea its worth seeing how far I can push StreamInsight.
Obviously for this POC I need some market rules. We’ll start simple, and use the following:
- We need to provide Depth of Market
- If new order, if there is a direct opposite order, then we can fill the order and generate a trade
- We might want to support Partial orders and time dependant orders (we can use StreamInsight Edge events for this)
- Orders need to be filled based on time, i.e. oldest first
- Price differences on order fills are not allowed – obvious
- We probably want to decide on how an order will be filled as there are many ways to fill an order if there isn’t a direction 1:1 with a buy/sell. For example, if we have a 100 buy, the fill might be a 50, 30 and 20 sell (i.e. 3 sell orders)

you will also need to deal with orders which go through the book (i.e. cross multiple levels) and ensure price and time validity (as well as multiply different prices in the resulting executions to the aggressive order.
partial orders are pretty much a must have I would think…
Depending on the market you may have to deal with downward size modifications which maintain priority as well but that’s likely an edge case for a POC
oh and dealing with orders which cross some of the other side of the book but not all of it, thus remaining as passive limit orders.
Ensuring the distinction between aggressive and passive is quite important in any market with differing cost models but absolutely vital for any market with a rebate model.
Re: Price differences on order fills are not allowed – obvious
Not quite obvious.
How would you handle (only) 2 orders in the book:
1. Buy 10 @ 100
2. Sell 10 @ 80
Would the trade happen at the price of 100, thus benefiting the seller or the other way around?
I know a few exchanges where the trade happens at the higher price at it results in higher fees
Or you could play fair and make it an avg price of 90. Or use the price of the first order…