A fast, stateful, event-driven Order Matching Engine written in core Java. It features a live "Binance-style" dark-mode UI, Price-Time priority matching, TCP-based distributed order ingestion, and real-time SQLite persistence.
- Live Order Book UI: A Java Swing dashboard featuring a dark theme, real-time quantity updates, order removal, and live search filtering.
- Price-Time Priority Engine: Matches Bids and Asks natively using fast Priority Queues.
- O(1) Order Cancellations: Uses a backing HashMap (
orderLookup) to pluck cancelled orders out of the book instantly. - TCP Socket Ingestion: Accepts concurrent TCP connections from multiple remote
NodeClientinstances. - Sequence Buffering: Handles network jitter by re-ordering incoming packets sequentially before passing them to the engine.
- Asynchronous Persistence: Uses a background
StorageLayerthread to batch-save executedTradeRecords to an SQLite database without blocking the matching engine. - Historical Data Loading: Automatically loads previous trade history into the UI on startup.
- Java Development Kit (JDK): Java 8 or higher installed.
- SQLite JDBC Driver: Required for saving trades to the database.
You need to download the .jar file to allow Java to talk to SQLite.
- Go to the Xerial SQLite-JDBC Releases page: https://github.com/xerial/sqlite-jdbc/releases
- Download the latest jar (e.g.,
sqlite-jdbc-3.45.2.0.jar). - For the commands below, place the downloaded
.jarfile directly into your project folder alongside your.javafiles.
Open your terminal and navigate to the project folder.
Compile all .java files while linking the SQLite JDBC jar in the classpath.
(Note: Replace sqlite-jdbc-3.45.2.0.jar with your exact downloaded filename if different).
Terminal 1:
javac -cp ".;sqlite-jdbc-3.53.0.0.jar" *.java
java -cp ".;sqlite-jdbc-3.53.0.0.jar" MatchingEngineServer
Terminal 2:
java NodeClient Node-1 200
Terminal 3:
java NodeClient Node-2 200