This is an orderbook implementation written purely in Rust. It includes full support for market and limit orders, a FIFO matching engine, an account system, and a fully functional and interactive terminal UI that can be seen here:
-
Limit and Market Orders: Create both limit orders (specify a price) and market orders (execute immediately at the best available price).
-
FIFO Matching Engine: Executes orders at the best available price. Orders on the same price level are processed on a first-in, first-out basis.
-
Account System: Keeps track of balances, active and historical orders for each user.
-
Interactive Terminal UI: A dynamic, real-time user interface right in your terminal, displaying the state of the order book, user balances, and more.
-
Macros for Test Data: Macros to populate the orderbook with random distributions of orders to trade against.
IMPORTANT: these commands will only work in the orderbook CLI, which will be at the bottom of the terminal once cargo run
successfully executes (see below for setup)
[buy/sell] [osmo/usd] [market/limit] [amount] [price if limit]
buy osmo limit 10 0.40
sell osmo market 10000
Pressing TAB
will run a macro that generates and places thousands of small orders that fall on roughly a normal distribution around the midpoint of the terminal screen. This can be run as many times as needed to get sufficient depth to trade against.
Ensure you have Rust and Cargo installed on your system. If not, you can install them using rustup.
git clone https://github.com/AlpinYukseloglu/orderbook.git
cd orderbook
cargo build
-
Launch the terminal UI:
cargo run
-
Interact with the terminal UI to place orders, view balances, and more (using the commands described above):
[buy/sell] [osmo/usd] [market/limit] [amount] [price if limit]