Skip to content

git-abdoul/order-matching-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

order-matching-engine


🚀 Intraday Trade Matching & Slippage Analysis

A Python application for simulating real-time order matching and slippage analysis in equity trading. Designed for speed, clarity, and robust analytics.


📦 App Structure

order-matching-engine/
├── README.md
├── requirements.txt  # All runtime & dev dependencies
├── intraday_trade_matching.md
├── engine/           # Core matching engine logic
│   ├── __init__.py
│   └── matcher.py    # Matching algorithm implementation
├── tests/            # Unit and integration tests
│   └── test_matcher.py
└── scripts/          # CLI and utility scripts
	└── run_engine.py

🛠️ Features

  • Fast in-memory matching of orders and market trades
  • FIFO priority for equal prices
  • Partial fills supported
  • Real-time queries:
    • get_open_orders(symbol)
    • get_filled(order_id)
    • get_slippage(order_id)
  • Efficient: O(log N) matching per trade

⚙️ Deployment

  1. Clone the repository:
    git clone https://github.com/git-abdoul/order-matching-engine.git
    cd order-matching-engine
  2. Set up a Python environment and install dependencies:
    python3 -m venv venv
    source venv/bin/activate
    pip install --upgrade pip
    pip install -r requirements.txt
    This will install all required libraries: numpy, pandas, pytest, flake8, black.
  3. Run the engine:
    python scripts/run_engine.py

🧑‍💻 Development Setup

  1. Create and activate a virtual environment:
    python3 -m venv venv
    source venv/bin/activate
  2. Install all dependencies (runtime & dev):
    pip install -r requirements.txt
    This single requirements file includes all libraries for running, testing, and linting the app.
  3. Run tests:
    pytest tests/
  4. Lint and format code:
    flake8 engine/
    black engine/

📚 How to Use

  • Place orders and stream market trades using the provided API or CLI.
  • Query open orders, filled quantities, and slippage in real time.
  • See intraday_trade_matching.md for scenario details and requirements.

💡 Example

  • Order: BUY 500 AAPL @190.25
  • Tape prints:
    • AAPL 190.10 x100 → fills 100 (ok, <= 190.25)
    • AAPL 190.20 x250 → fills 250 (ok, <= 190.25)
    • AAPL 190.40 x200 → ignored (price too high)

Open qty = 150 left.
Filled qty = 350.
Avg fill price = (100×190.10 + 250×190.20)/350 = 190.17.
Slippage = 190.17 − 190.25 = −0.08 (better fill).


⚡️ Build, test, and deploy your matching engine for high-performance trading analytics!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages