How sohaibelkarmi/high-frequency-trading-simulator works
This repository is a high-frequency trading research simulator. Its central workflow generates Hawkes order events, applies latency and deterministic matching, records execution costs, and exposes results through a Python backtester and analytics/UI. The README also documents recorded-feed ingestion and research diagnostics. Arrows are limited to relationships explicit in the README or shown in indexed source references and excerpts; unsampled subsystems are retained where their paths are supported, without asserting unverified wiring.
Main entry points: backtester.py Replay Orchestrator · matching_engine.cpp Matching Engine · timeline_dashboard.py Timeline Dashboard · kernels.py Python Hawkes Kernels
Components 24
Order Flow
- Hawkes Sampler
src/hawkes_engine.cpp - Python Hawkes Kernels
python/kernels.py - Order-Flow Calibration
python/order_flow/calibration.py - Feed Ingestion
python/backtester/itch.py
Simulation Engine
- Event Producer
src/event_engine.cpp - Engine Runtime
src/engine_runtime.cpp - Matching Engine
src/matching_engine.cpp - Order Book
src/OrderBook.hpp - Latency Model
src/latency_model.hpp - Execution Costs
src/execution_cost.hpp - Simulator Core
src/simulator_core.hpp
Python Backtesting
- Python Book Adapter
python/backtester/order_book.py - Replay Orchestrator
python/backtester/backtester.py - Trading Strategy
python/backtester/strategy.py - Risk and PnL
python/backtester/risk.py - Metrics Logging
python/backtester/logging.py - Risk Dashboard
python/backtester/dashboard.py
Analytics and UI
- Analytics I/O
python/analysis/io.py - Diagnostics Plots
python/analysis/plots.py - Timeline Dashboard
python/timeline_dashboard.py - Hawkes Streamlit
python/streamlit_app.py - Simulation API
python/simulate.py
Other components
- Researcher
- Researcher Results
Connections 31
- Researcher → Hawkes Streamlit: configures simulations
- Researcher → Replay Orchestrator: runs replay
- Hawkes Sampler → Event Producer: samples events
src/event_engine.cpp - Engine Runtime → Event Producer: starts and joins
src/engine_runtime.cpp - Event Producer → Matching Engine: queues events
src/event_engine.cpp - Engine Runtime → Matching Engine: starts and joins
src/engine_runtime.cpp - Matching Engine → Latency Model: samples delays
- Matching Engine → Order Book: matches orders
src/matching_engine.cpp - Matching Engine → Execution Costs: records executions
- Simulator Core → Hawkes Sampler: uses process
src/simulator_core.hpp - Simulator Core → Order Book: seeds book
src/simulator_core.hpp - Simulator Core → Execution Costs: tracks costs
src/simulator_core.hpp - Replay Orchestrator → Python Book Adapter: applies replay
python/backtester/backtester.py - Replay Orchestrator → Trading Strategy: invokes strategy
python/backtester/backtester.py - Replay Orchestrator → Risk and PnL: updates risk
python/backtester/backtester.py - Replay Orchestrator → Metrics Logging: logs metrics
python/backtester/backtester.py - Replay Orchestrator → Risk Dashboard: renders dashboard
python/backtester/backtester.py - Feed Ingestion → Replay Orchestrator: supplies events
- Python Book Adapter → Order Book: uses native bridge
python/backtester/order_book.py - Risk Dashboard → Metrics Logging: reads metrics
python/backtester/dashboard.py - Hawkes Streamlit → Python Hawkes Kernels: configures kernels
python/streamlit_app.py - Hawkes Streamlit → Timeline Dashboard: uses dashboard
python/streamlit_app.py - Timeline Dashboard → Python Hawkes Kernels: uses kernels
python/timeline_dashboard.py - Timeline Dashboard → Simulation API: simulates events
python/timeline_dashboard.py - Timeline Dashboard → Researcher Results: presents timelines
- Simulation API → Python Hawkes Kernels: uses kernels
python/simulate.py - Order-Flow Calibration → Researcher Results: produces calibration
- Analytics I/O → Researcher Results: exports artefacts
- Diagnostics Plots → Researcher Results: visualizes diagnostics
- Replay Orchestrator → Researcher Results: reports replay metrics
- Python Hawkes Kernels → Researcher Results: generates order flow