Event-driven bond trading system for U.S. Treasuries, developed for MTH 9815 – Software Engineering for Finance.
This project implements a modular, service-oriented bond trading system in C++.
It mirrors a realistic front-to-risk trading architecture using services, listeners,
connectors, and TCP socket integration.
The traded universe consists of U.S. Treasury securities: 2Y, 3Y, 5Y, 7Y, 10Y, 20Y, and 30Y.
All prices use U.S. Treasury fractional notation (1/256).
Note: the digit 4 is written explicitly (no + shorthand).
A more in depth presentation is done in the Latex_file
The system follows a strict event-driven design with clear separation of concerns:
- Feeders read input files and publish raw messages via TCP sockets.
- Connectors parse and normalize external data.
- Services own business logic and state.
- Listeners propagate events between services.
- Printers and historical services handle output outside the core trading process.
End-to-end flow:
(File) → Feeder → TCP → Inbound Connector → Service → Listener
→ Outbound Connector → TCP → Printer
IMPORTANT: THIS MAKEFILE IS CURRENTLY MACOS-ORIENTED (Apple Silicon / Homebrew).
The Makefile builds:
- the trading system (
main_demo), - socket-based feeders,
- execution and streaming printer processes.
- clang++ (C++17)
- make
- (Optional) llvm-profdata for PGO
- Homebrew (Apple Silicon uses /opt/homebrew)
make clean
make all
make run-demo
This launches, in order:
- execution and streaming printers,
- the trading system,
- pricing, trades, market data, and inquiry feeders.
Inbound (feeders → trading system):
- pricing: 9201
- trades: 9202
- marketdata: 9203
- inquiries: 9204
Outbound (trading system → printers):
- executions: 9301
- streaming: 9302
Outputs are written to:
data/output/
positions.txt
risk.txt
executions.txt
streaming.txt
allinquiries.txt
gui.txt
To stop everything manually:
make stop-demo
To build on Linux, the Makefile must be edited:
-
Remove the Homebrew include path: -I/opt/homebrew/include
-
Set the compiler if needed: CXX = clang++ or clang++-16
-
If LTO fails, add: LDFLAGS += -fuse-ld=lld
-
For portability, remove or replace: -march=native -mtune=native
Laferté Edouard
MTH 9815 – Software Engineering for Finance