Flower Trading System
A console-based order matching and trade execution system developed for the UCSC C++ Workshop.
backend

Overview
The Flower Trading System is a simplified exchange application designed for the UCSC–LSEG C++ Workshop. It simulates how real-world electronic trading platforms work by processing buy and sell orders for different flower instruments. The system reads orders from a CSV file, validates them, inserts them into instrument-wise order books, matches eligible orders, and generates execution reports reflecting the results of each order. This project models core financial exchange concepts such as aggressive vs. passive orders, order book sorting, partial fills, full fills, rejections, and transaction time stamping.
Problem & Goal
Problem:
Manual or naive trading simulations do not cover essential matching logic, order book priority handling, or real exchange-like behaviors. Without a structured system, it becomes difficult to validate order formats, process trades in real time, manage multiple instruments, or ensure accurate reporting. Students also lack hands-on experience in building performant order matching systems, which are widely used in financial markets.
Goal:
The goal of this project is to implement an efficient and accurate order matching engine capable of processing flower trade orders, maintaining order books, executing trades, and producing valid execution reports. The system aims to teach core concepts of electronic trading, data validation, and high-performance C++ patterns while ensuring correctness, speed, and real-time behavior through timestamping.
Objectives
- Implement a working exchange-like system fully using C++ within a three-week workshop timeline.
- Process buy and sell orders from a CSV file and output matching execution reports.
- Maintain five separate order books (Rose, Lavender, Lotus, Tulip, Orchid).
- Support aggressive and passive order behavior with proper fill/partial-fill logic.
- Validate input orders and generate appropriate rejected execution reports.
- Accurately sort order books using price-time priority rules.
- Add proper transaction timestamps for every execution report.
- Produce results identical to the provided reference exec_rep.csv files.
Scope
- Reading input orders from CSV files (orders.csv).
- Validating mandatory fields, instrument names, sides, price, and quantity.
- Maintaining dedicated order books for five instruments.
- Sorting buy side descending by price and sell side ascending by price.
- Processing new, rejected, filled, and partially filled orders.
- Generating execution reports with status values (0–New, 1–Rejected, 2–Fill, 3–Pfill).
- Executing buy–sell order matching using real exchange matching logic.
- Writing output execution reports as execution_rep.csv.
- Handling full and partial quantity matches across multiple book levels.
- Timestamping every execution event for performance evaluation.
Tech Stack
The project is fully implemented in C++ using STL containers for order book management. CSV files are used for input and output to simulate real exchange feeds. The architecture separates the Trader Application and Exchange Application to model real-world market systems. Efficient processing, sorting, and memory management are emphasized as part of the workshop's performance goals.
Screenshots & UI

Key Features
- CSV-based buy/sell order intake supporting five flower instruments.
- Automatic validation of input orders with detailed reject reasons.
- Separate order books for Rose, Lavender, Lotus, Tulip, and Orchid, each with buy/sell sides.
- Full order matching logic including aggressive and passive order handling.
- Partial fill (PFILL) and full fill (FILL) execution handling.
- Price–time priority sorting for both buy and sell sides.
- Rejection handling for invalid instruments, quantity errors, or missing fields.
- Generation of execution reports including order ID, status, and timestamps.
- Output verification against provided sample execution files.
- Designed for performance, capable of handling large input CSV files.