Skip to content

About

Event-driven C++ bond trading system for US Treasuries. Service-oriented architecture with feeders, connectors, listeners, TCP socket integration, execution, risk, streaming, inquiries, GUI throttling, and historical persistence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

Bond Trading System (C++)

Event-driven bond trading system for U.S. Treasuries, developed for MTH 9815 – Software Engineering for Finance.

Overview

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

Architecture

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

Build System

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.

Prerequisites (macOS)

  • clang++ (C++17)
  • make
  • (Optional) llvm-profdata for PGO
  • Homebrew (Apple Silicon uses /opt/homebrew)

Build

make clean
make all

Run the End-to-End Demo

make run-demo

This launches, in order:

  1. execution and streaming printers,
  2. the trading system,
  3. pricing, trades, market data, and inquiry feeders.

Ports

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

Linux Notes

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

Author

Laferté Edouard
MTH 9815 – Software Engineering for Finance

About

Event-driven C++ bond trading system for US Treasuries. Service-oriented architecture with feeders, connectors, listeners, TCP socket integration, execution, risk, streaming, inquiries, GUI throttling, and historical persistence.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages