diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..ab2e266 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,3 @@ +Checks: '-*,bugprone-*,performance-*,modernize-*' +WarningsAsErrors: '' +HeaderFilterRegex: 'src/.*' diff --git a/.gitignore b/.gitignore index d4fb281..be640a8 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,6 @@ # debug information files *.dwo + +# Build directories +/build/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3ce8cf4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.25) +project(ExchangeSimulator VERSION 0.1 LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +option(ENABLE_ASAN "Enable AddressSanitizer" OFF) +if(ENABLE_ASAN) + if(MSVC) + add_compile_options(/fsanitize=address) + add_link_options(/fsanitize=address) + else() + add_compile_options(-fsanitize=address -fno-omit-frame-pointer) + add_link_options(-fsanitize=address) + endif() +endif() + +option(ENABLE_CLANG_TIDY "Enable clang-tidy analysis" OFF) +if(ENABLE_CLANG_TIDY) + find_program(CLANG_TIDY_EXE NAMES clang-tidy) + if(CLANG_TIDY_EXE) + set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXE}) + else() + message(WARNING "clang-tidy requested but executable not found") + endif() +endif() + +include(FetchContent) +FetchContent_Declare( + spdlog + GIT_REPOSITORY https://github.com/gabime/spdlog.git + GIT_TAG v1.12.0 +) +FetchContent_MakeAvailable(spdlog) +add_definitions(-DSPDLOG_USE_STD_FORMAT -DSPDLOG_USE_STD_FORMAT_HO) + +add_subdirectory(src) + +# Tests +option(BUILD_TESTING "Build tests" ON) +if(BUILD_TESTING) + enable_testing() + add_subdirectory(tests) +endif() diff --git a/README.md b/README.md index c5dc79d..32a984e 100644 --- a/README.md +++ b/README.md @@ -1 +1,19 @@ -# ExchangeSimulator \ No newline at end of file +# ExchangeSimulator + +A cross-platform exchange matching engine simulator written in modern C++23. + +## Building + +```bash +cmake -S . -B build +cmake --build build +``` + +Pass optional flags to enable developer tooling: + +```bash +cmake -S . -B build -DENABLE_ASAN=ON # AddressSanitizer +cmake -S . -B build -DENABLE_CLANG_TIDY=ON # clang-tidy analysis +``` + +Requires the [spdlog](https://github.com/gabime/spdlog) library to be available to the build system. diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..5fac8ba --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# ExchangeSimulator Documentation + +Documentation will be added here. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..fe6c49e --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(core INTERFACE) +target_include_directories(core INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/core) +target_link_libraries(core INTERFACE spdlog::spdlog_header_only) + +add_library(engine INTERFACE) +target_include_directories(engine INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/engine) + +add_executable(exchange_simulator sim/main.cpp) +target_link_libraries(exchange_simulator PRIVATE core engine spdlog::spdlog_header_only) +target_include_directories(exchange_simulator PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/core/logger.h b/src/core/logger.h new file mode 100644 index 0000000..c5f8354 --- /dev/null +++ b/src/core/logger.h @@ -0,0 +1,15 @@ +#pragma once + +#include +#include + +namespace es { + +#define LOG_INFO(...) SPDLOG_INFO(__VA_ARGS__) +#define LOG_WARN(...) SPDLOG_WARN(__VA_ARGS__) +#define LOG_ERROR(...) SPDLOG_ERROR(__VA_ARGS__) +#define LOG_DEBUG(...) SPDLOG_DEBUG(__VA_ARGS__) +#define LOG_TRACE(...) SPDLOG_TRACE(__VA_ARGS__) +#define LOG_CRITICAL(...) SPDLOG_CRITICAL(__VA_ARGS__) + +} // namespace es diff --git a/src/engine/matching_engine.h b/src/engine/matching_engine.h new file mode 100644 index 0000000..96532f7 --- /dev/null +++ b/src/engine/matching_engine.h @@ -0,0 +1,8 @@ +#pragma once + +namespace es { +class MatchingEngine { +public: + void run(); +}; +} diff --git a/src/exchanges/cme/adapter.h b/src/exchanges/cme/adapter.h new file mode 100644 index 0000000..6a79734 --- /dev/null +++ b/src/exchanges/cme/adapter.h @@ -0,0 +1,8 @@ +#pragma once + +namespace es::cme { +class Adapter { +public: + void connect(); +}; +} diff --git a/src/exchanges/eurex/adapter.h b/src/exchanges/eurex/adapter.h new file mode 100644 index 0000000..905d98e --- /dev/null +++ b/src/exchanges/eurex/adapter.h @@ -0,0 +1,8 @@ +#pragma once + +namespace es::eurex { +class Adapter { +public: + void connect(); +}; +} diff --git a/src/exchanges/ice/adapter.h b/src/exchanges/ice/adapter.h new file mode 100644 index 0000000..ab551a3 --- /dev/null +++ b/src/exchanges/ice/adapter.h @@ -0,0 +1,8 @@ +#pragma once + +namespace es::ice { +class Adapter { +public: + void connect(); +}; +} diff --git a/src/sim/main.cpp b/src/sim/main.cpp new file mode 100644 index 0000000..ca3ece1 --- /dev/null +++ b/src/sim/main.cpp @@ -0,0 +1,6 @@ +#include + +int main() { + SPDLOG_INFO("ExchangeSimulator skeleton"); + return 0; +} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..b7aa1da --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1 @@ +# Placeholder for future tests