Member-only story

Building a Trading Engine in Rust: Part 1

Tomas Svojanovsky
5 min readApr 19, 2025

--

Not a member? Read it here.

Rust has become increasingly popular for building high-performance systems where reliability and safety are critical. We’ll start building a trading engine from scratch using Rust. This project is perfect for beginners looking to learn Rust through practical application while creating something substantial.

A trading engine, or matching engine, is the core component of any financial exchange. It processes incoming orders and matches them with existing orders in the order book.

Setting Up the Project Structure

We’ll begin by creating the basic structures needed for our trading engine:

  1. Order - Represents a buy (bid) or sell (ask) order
  2. Limit - Holds orders at a specific price level
  3. OrderBook - Contains collections of bids and asks

Building the Order Structure

First, let’s create an Order struct that will store information about individual orders:

#[derive(Debug)]
enum BidOrAsk {
Bid,
Ask,
}

#[derive(Debug)]
struct Order {
size: f64,
bid_or_ask: BidOrAsk,
}

impl Order {
fn new(bid_or_ask: BidOrAsk, size: f64) -> Self {
Order {
bid_or_ask…

--

--

Tomas Svojanovsky
Tomas Svojanovsky

Written by Tomas Svojanovsky

I'm a full-stack developer. Programming isn't just my job but also my hobby. I like developing seamless user experiences and working on server-side complexities

No responses yet