# go-auction **Repository Path**: jkuang/go-auction ## Basic Information - **Project Name**: go-auction - **Description**: prototype of Match Engine in golang - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-04-12 - **Last Updated**: 2022-05-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # go-auction prototype of Match Engine in golang try avl tree and rb tree for orderbook ## test [![asciicast](https://asciinema.org/a/489807.svg)](https://asciinema.org/a/489807) ### test for avl orderBook
make test
make bench
### test for btree orderBook
make btest
make bbench
### test for redblack tree orderBook
make rbtest
make rbbench
## performance Benchmark Cross/Continue match (avl tree for orderBook) Cross for 2 million orders, buy/sell half/half
goos: linux
goarch: amd64
pkg: github.com/kjx98/go-auction
cpu: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
BenchmarkMatchCrossOld-4        	       6	 200054236 ns/op
BenchmarkMatchCross-4           	      10	 102986946 ns/op
BenchmarkMatchTradeContinue-4   	 1503540	       724.0 ns/op
PASS
Benchmark Cross/Continue match (btree for orderBook) Cross for 2 million orders, buy/sell half/half
goos: linux
goarch: amd64
pkg: github.com/kjx98/go-auction
cpu: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
BenchmarkMatchCrossOld-4        	      10	 104763648 ns/op
BenchmarkMatchCross-4           	      21	  63319538 ns/op
BenchmarkMatchTradeContinue-4   	 1826527	       620.3 ns/op
PASS
ok  	github.com/kjx98/go-auction	8.910s
Benchmark w/ continue trading (btree for orderBook)
04-29 09:35:08  ▶ INFO  Read Data/long.txt orders cost 0.578 seconds
04-29 09:35:08  ▶ INFO  Insert 1000000 orders cost 0.396 seconds
04-29 09:35:09  ▶ INFO  Read Data/short.txt orders cost 0.619 seconds
04-29 09:35:09  ▶ INFO  Insert 1000000 orders cost 0.384 seconds
04-29 09:35:09  ▶ INFO  Load 1000000 long orders 1000000 short orders cost 1.977 seconds, 1011519.59 O/s
Before auction, bid QLen: 1000000, ask QLen: 1000000
Auction Algo 1 match 2000000 orders cost 44.400 ms, 45045257.08 Ops
CallAuction Price: 50500, Volume: 2753442, Remain Volume: 25718
Build deal reports cost: 181.296 ms
After auction, bid QLen: 499392, ask QLen: 499164
04-29 09:35:11  ▶ INFO  Feed/Trade rand 2000000 orders cost 1535.599 ms, 1302422.94 O/s
Trading continuous, bid QLen: 238121, ask QLen: 238277
matchs in continuous trading: 4974898
[![asciicast TC](https://asciinema.org/a/490902.svg)](https://asciinema.org/a/490902)