Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Checks: '-*,bugprone-*,performance-*,modernize-*'
WarningsAsErrors: ''
HeaderFilterRegex: 'src/.*'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@

# debug information files
*.dwo

# Build directories
/build/
45 changes: 45 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# ExchangeSimulator
# 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.
3 changes: 3 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ExchangeSimulator Documentation

Documentation will be added here.
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
15 changes: 15 additions & 0 deletions src/core/logger.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include <spdlog/spdlog.h>
#include <string_view>

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
8 changes: 8 additions & 0 deletions src/engine/matching_engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace es {
class MatchingEngine {
public:
void run();
};
}
8 changes: 8 additions & 0 deletions src/exchanges/cme/adapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace es::cme {
class Adapter {
public:
void connect();
};
}
8 changes: 8 additions & 0 deletions src/exchanges/eurex/adapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace es::eurex {
class Adapter {
public:
void connect();
};
}
8 changes: 8 additions & 0 deletions src/exchanges/ice/adapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

namespace es::ice {
class Adapter {
public:
void connect();
};
}
6 changes: 6 additions & 0 deletions src/sim/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <core/logger.h>

int main() {
SPDLOG_INFO("ExchangeSimulator skeleton");
return 0;
}
1 change: 1 addition & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Placeholder for future tests