Ultra-fast matching engine written in Java based on LMAX Disruptor, Eclipse Collections, Real Logic Agrona, OpenHFT, LZ4 Java, and Adaptive Radix Trees.
Ultra-fast matching engine written in Java based on LMAX Disruptor, Eclipse Collections, Real Logic Agrona, OpenHFT, LZ4 Java, and Adaptive Radix Trees.
Exchange-core is an open source market exchange core based on LMAX Disruptor, Eclipse Collections (ex. Goldman Sachs GS Collections), Real Logic Agrona, OpenHFT Chronicle-Wire, LZ4 Java, and Adaptive Radix Trees.
Exchange-core includes:
Designed for high scalability and pauseless 24/7 operation under high-load conditions and providing low-latency responses:
Single order book configuration is capable to process 5M operations per second on 10-years old hardware (Intel® Xeon® X5690) with moderate latency degradation:
| rate | 50.0% | 90.0% | 95.0% | 99.0% | 99.9% | 99.99% | worst |
|---|---|---|---|---|---|---|---|
| 125K | 0.6µs | 0.9µs | 1.0µs | 1.4µs | 4µs | 24µs | 41µs |
| 250K | 0.6µs | 0.9µs | 1.0µs | 1.4µs | 9µs | 27µs | 41µs |
| 500K | 0.6µs | 0.9µs | 1.0µs | 1.6µs | 14µs | 29µs | 42µs |
| 1M | 0.5µs | 0.9µs | 1.2µs | 4µs | 22µs | 31µs | 45µs |
| 2M | 0.5µs | 1.2µs | 3.9µs | 10µs | 30µs | 39µs | 60µs |
| 3M | 0.7µs | 3.6µs | 6.2µs | 15µs | 36µs | 45µs | 60µs |
| 4M | 1.0µs | 6.0µs | 9µs | 25µs | 45µs | 55µs | 70µs |
| 5M | 1.5µs | 9.5µs | 16µs | 42µs | 150µs | 170µs | 190µs |
| 6M | 5µs | 30µs | 45µs | 300µs | 500µs | 520µs | 540µs |
| 7M | 60µs | 1.3ms | 1.5ms | 1.8ms | 1.9ms | 1.9ms | 1.9ms |
Benchmark configuration:
mvn installpom.xml:<dependency>
<groupId>exchange.core2</groupId>
<artifactId>exchange-core</artifactId>
<version>0.5.3</version>
</dependency>Alternatively, you can clone this repository and run the example test.
Create and start empty exchange core:
…Create new symbol:
…Create new users:
// create user uid=301
future = api.submitCommandAsync(ApiAddUser.builder()
.uid(301L)
.build());
// create user uid=302
future = api.submitCommandAsync(ApiAddUser.builder()
.uid(302L)
.build());Perform deposits:
// first user deposits 20 LTC
future = api.submitCommandAsync(ApiAdjustUserBalance.builder()
.uid(301L)
.currency(currencyCodeLtc)
.amount(2_000_000_000L)
.transactionId(1L)
.build());
// second user deposits 0.10 BTC
future = api.submitCommandAsync(ApiAdjustUserBalance.builder()
.uid(302L)
.currency(currencyCodeXbt)
.amount(10_000_000L)
.transactionId(2L)
.build());Place orders:
…Request order book:
future = api.requestOrderBookAsync(symbolXbtLtc, 10);GtC orders manipulations:
// first user moves remaining order to price 1.53 LTC
future = api.submitCommandAsync(ApiMoveOrder.builder()
.uid(301L)
.orderId(5001L)
.newPrice(15_300L)
.symbol(symbolXbtLtc)
.build());
// first user cancel remaining order
future = api.submitCommandAsync(ApiCancelOrder.builder()
.uid(301L)
.orderId(5001L)
.symbol(symbolXbtLtc)
.build());Check user balance and GtC orders:
Future<SingleUserReportResult> report = api.processReport(new SingleUserReportQuery(301), 0);Check system balance:
// check fees collected
Future<TotalCurrencyBalanceReportResult> totalsReport = api.processReport(new TotalCurrencyBalanceReportQuery(), 0);
System.out.println("LTC fees collected: " + totalsReport.get().getFees().get(currencyCodeLtc));Exchange-core is an open-source project and contributions are welcome!
No open issues yet, or sync has not completed.