Skip to content

iamsank7/order-matching-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Order Matching Engine

A C++ implementation of a high-performance order matching engine with price-time priority.

Project Structure

order-matching-engine/
├── src/
│   ├── order_book/
│   │   ├── order.hpp
│   │   ├── order_book.hpp
│   │   ├── order_generator.hpp
│   │   └── trade.hpp
│   └── main.cpp
├── build/              # Build output directory
├── CMakeLists.txt     # CMake build configuration
├── README.md          # Project documentation
└── .gitignore         # Git ignore file

Features

  • Supports both limit and market orders
  • Price-time priority matching algorithm
  • Real-time order book management
  • Order operations:
    • Add new orders
    • Modify existing orders
    • Cancel orders
  • Trade execution and logging
  • Random order generation for testing

Using Shell Script

For convenience, a shell script is provided to build and run the project:

# Make the script executable (first time only)
chmod +x build_and_run.sh

# Build and run the project
./build_and_run.sh

The build_and_run.sh script automates:

  • Creating build directory if it doesn't exist
  • Running CMake configuration
  • Building the project
  • Running the executable
  • Displaying the output

Usage Example

// Initialize order book
OrderBook orderBook;

// Create and add orders
Order buyOrder(OrderSide::BUY, 100.5, 10);
Order sellOrder(OrderSide::SELL, 100.0, 5);

orderBook.addOrder(buyOrder);
orderBook.addOrder(sellOrder);

// View order book state
orderBook.printOrderBook();

// View executed trades
orderBook.printTrades();

Testing

The system includes an order generator for testing:

OrderGenerator generator(100.0);  // Base price of 100
Order randomOrder = generator.generateOrder();

License

This project is licensed under the MIT License.

About

A C++ implementation of a limit order book matching engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published