1
$\begingroup$

I am looking for a service that can be deployed locally or connected to it and would emulate the order matching system of exchange (a.k.a matching core).

I remember, that I have seen on GitHub repo, with software, which allows simulating NYSE or NASDAQ exchange ECN behavior. So I could send orders to it, and check how they could be executed by the trading system. Of course it's not 100% the exact copy of exchange core, but it allows to simulate different behavior.

I guess I am not the only one with this problem, so I am looking for advice. Could someone remind me or share their own expirience for emulating order-matching behavior?

$\endgroup$

1 Answer 1

3
$\begingroup$

I am not aware of any such service but simulating exchange behavior for backtest is very challenging given irregular order arrival and their impact and hidden orders. Even the paper trading service’s order execution is very simple and has limitations (if you send a limit order it will get filled by price-touch-limit and size is irrelevant). Even if you find some Execution Management Service to install locally you would still need data and a time series database to use them. Below are some considerations if you want to build your own tool.

A good order execution system should take into account market order, limit order, slippage, latency and calculating average fill price and size for both market and limit orders.

If a simplified option satisfies your needs, you can implement it by yourself. You would need historical order book data up to N level (snapshot or update both are fine). When you send a market order of a certain size you go down the orderbook and keep reducing size until the final size is zero. By doing so you can calculate the average fill price (weighted by size at that price) and slippage. When you send a limit order, you can check if a better fill is available or not. If yes then you can proceed like market order but the tricky part is when you reach limit price and remaining size is greater than zero (You can assume fill or partial-fill). Depending on granularity of your order book data you can implement some logic to take latency into account.

[EDIT] For advanced use cases you can refer to following open source repo: https://github.com/exchange-core/exchange-core

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.