Zipmex code challenge
Run with docker
docker build -t boblancer-zipmex .
docker run boblancer-zipmex:latest
- Mocha, Sinon (Testing)
- sorted-btree (B+ tree for internal storage)
- Input file is https://github.com/boblancer/exchange/blob/main/tests/matching_engine/input.json
- output file is https://github.com/boblancer/exchange/blob/main/tests/matching_engine/output.json
to debug the application you may add console log to the new test function
taken from tests/matching_engine/order_book.ts:30
describe('OrderBook local integration(input.json output.json)', function() {
const input: {[key: string]: any} = require('./input.json');
const output: {[key: string]: any} = require('./output.json');
it('input 1 from input.json return correct output.json', function() {
let book = new OrderBook();
createOrderFromJson(input[0].orders, book)
const expected: OrderBookResponse = output[0]
let result = JSON.stringify(book.listOrder())
console.log(result)
assert.equal(result, JSON.stringify(expected));
});
it('input 2 from input.json return correct output.json', function() {
let book = new OrderBook();
createOrderFromJson(input[1].orders, book)
const expected: OrderBookResponse = output[1]
let result = JSON.stringify(book.listOrder())
assert.equal(result, JSON.stringify(expected));
});
it('input 3 from input.json return correct output.json', function() {
let book = new OrderBook();
createOrderFromJson(input[2].orders, book)
const expected: OrderBookResponse = output[2]
let result = JSON.stringify(book.listOrder())
assert.equal(result, JSON.stringify(expected));
});
it('input 4 from input.json return correct output.json', function() {
let book = new OrderBook();
createOrderFromJson(input[3].orders, book)
const expected: OrderBookResponse = output[3]
let result = JSON.stringify(book.listOrder())
assert.equal(result, JSON.stringify(expected));
});
});
});
Operation | Cost | Used In |
---|---|---|
Insert | O(log n) |
_createNewOrder() |
Delete(Root) | O(t log n) |
_fillOrder() |
Find(Root) | O(1) |
_fillOrder() & _processOrder() |