Trading Engine Model
This is a simple toy trading engine. Orders stream in on STDIN and fulfilled trades stream out on STDOUT. The engine supports arbitrary commodities.
Note: Times are always in ISO-8601 UTC (eg "2013-12-01T03:15:13Z")
Orders are tab-delimted lines consisting of the following fields:
- Order time.
- Order Type. Currently supported orders are BUY and SELL
- Symbol. A string consisting of any characters except newline and tab.
- Price. A string matching the following regex:
- Quantity. A string matching the regex
Results are tab-delimited lines consisting of the following fields:
- Buy order time
- Sell order time
- hash of order books, one per commodity
- order book is a pair of rb tree maps, one for buy and one for sell
- Parse order
- Insert order into appropriate order book
- Check order book for a match at the top
- If there is a match, remove top orders from both buy and sell and print trade