Skip to content

aarav-agn/Chronos_backtesting_engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chronos

High Frequency Event Driven Backtesting Engine

Chronos is a high performance backtesting architecture designed for quantitative researchers. It processes level one tick data with zero dynamic memory allocation to simulate trading strategies with absolute fidelity. The project demonstrates advanced systems programming applied to market microstructure constraints like latency, slippage and spread crossing.

Core Architecture

The engine operates on a strict one way data flow via a central event bus. The core execution handler is written in C++20 to achieve maximum throughput. Standard queues allocate memory dynamically when items are pushed but Chronos utilizes a single producer single consumer ring buffer. This preallocates a fixed block of memory on startup to ensure constant time operations and zero garbage collection spikes.

Data ingestion bypasses standard file reading methods. The engine uses direct memory mapping to load binary structs directly into virtual memory. This allows the system to process massive datasets while utilizing minimal active RAM.

The analytics interface is built with Python and pybind11. This design choice provides quantitative developers the raw speed of a native binary along with the flexible data visualization power of Pandas.

Key Features

  • Zero allocation execution hot path
  • Lock free concurrency model
  • Memory mapped file ingestion for massive tick datasets
  • Strict determinism ensuring identical profit generation across multiple runs

Prerequisites

  • CMake build system
  • GCC compiler supporting C++20
  • Python version 3.10 or newer
  • pybind11, Pandas and NumPy

Build Instructions

Create a build directory inside the project root. Run the CMake configuration command followed by the make command to compile the native C++ tools and the shared Python module.

mkdir build
cd build
cmake ..
make

Usage Workflow

First you must prepare your data environment. Execute the mock data generator script to create millions of raw market ticks.

cd tools
python generate_mock_data.py

Next you will use the compiled C++ binary tool to pack this text data into the specialized memory mapped format.

cd ../build
./csv_to_bin ../data/raw_ticks.csv ../data/market_data.bin

Finally you can run the main Python analytics script. This will initialize the C++ core, process the binary data and return the execution ledger to Python for Sharpe ratio calculations and equity curve plotting.

cd ../python
export PYTHONPATH=../build:$PYTHONPATH
python run_backtest.py

About

Zero allocation, event driven high frequency backtesting engine in C++

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors