-
Notifications
You must be signed in to change notification settings - Fork 4
10 create end to end trade management logic #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
05435e4
16fb2c3
3ba4cec
46e720d
61309bd
48a9a99
fab3106
85be15b
cbc033d
bb24f06
27f82f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Start QuestDB (on macOS) | ||
|
|
||
| ``` | ||
| JAVA_HOME="/opt/homebrew/opt/openjdk@17" sh $HOME/dev/questdb/questdb.sh start -d $HOME/dev/questdb/data | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,21 @@ | ||
| // Backtesting Engine in C++ | ||
| // | ||
| // (c) 2025 Ryan McCaffery | https://mccaffers.com | ||
| // (c) 2026 Ryan McCaffery | https://mccaffers.com | ||
| // This code is licensed under MIT license (see LICENSE.txt for details) | ||
| // --------------------------------------- | ||
| #pragma once | ||
| #include <chrono> | ||
| #include <string> | ||
|
|
||
| struct PriceData { | ||
| double value1; | ||
| double value2; | ||
| double ask; | ||
| double bid; | ||
| std::chrono::system_clock::time_point timestamp; | ||
| std::string symbol; | ||
|
|
||
| // Constructor for easy creation | ||
| PriceData(double v1, double v2, const std::chrono::system_clock::time_point& ts) | ||
| : value1(v1), value2(v2), timestamp(ts) {} | ||
| PriceData(double ask, double bid, const std::chrono::system_clock::time_point& ts, const std::string& symbol) | ||
| : ask(ask), bid(bid), timestamp(ts), symbol(symbol) {} | ||
|
|
||
| PriceData() : ask(0.0), bid(0.0), timestamp{}, symbol("") {} | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| // Backtesting Engine in C++ | ||
| // | ||
| // (c) 2026 Ryan McCaffery | https://mccaffers.com | ||
| // This code is licensed under MIT license (see LICENSE.txt for details) | ||
| // --------------------------------------- | ||
|
|
||
| #pragma once | ||
| #include <vector> | ||
| #include "models/priceData.hpp" | ||
|
|
||
| class Operations { | ||
|
|
||
| public: | ||
| static void run(const std::vector<PriceData>& priceData); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| cd ./external/libpqxx | ||
|
|
||
| mkdir -p build | ||
| cd ./build | ||
|
|
||
| export PATH="$(brew --prefix libpq)/bin:$PATH" | ||
| export PKG_CONFIG_PATH="$(brew --prefix libpq)/lib/pkgconfig:$PKG_CONFIG_PATH" | ||
| export PostgreSQL_ROOT="$(brew --prefix libpq)" | ||
|
|
||
| cmake .. -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=Release | ||
| make | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| cmake_minimum_required(VERSION 3.30) | ||
|
|
||
| # CMAKE_OSX_SYSROOT is a macOS-specific setting that specifies the SDK path. | ||
| # Only query and set it on Apple platforms, where xcrun is expected to exist. | ||
| if(APPLE) | ||
| execute_process( | ||
| COMMAND xcrun --show-sdk-path | ||
| OUTPUT_VARIABLE CMAKE_OSX_SYSROOT | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| endif() | ||
|
|
||
| project(BacktestingEngine) | ||
|
|
||
| # Set the C++ standard | ||
| set(CMAKE_CXX_STANDARD 20) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
|
||
| # Configure libpqxx build | ||
| set(PQXX_LIBRARIES_INSTALL ON) | ||
| set(SKIP_BUILD_TEST ON) | ||
| set(SKIP_CONFIGURE_LIBPQXX OFF) | ||
|
|
||
| # Disable warningsfor external libraries | ||
| set(PREV_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) | ||
| if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") | ||
| elseif(MSVC) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") | ||
| endif() | ||
|
|
||
| # Quiet CMAKE output | ||
| set(CMAKE_INSTALL_MESSAGE NEVER) | ||
| set(CMAKE_MESSAGE_LOG_LEVEL "WARNING") | ||
|
|
||
| # Build libpqxx from source | ||
| add_subdirectory(external/libpqxx EXCLUDE_FROM_ALL) | ||
|
|
||
| # Include directories | ||
| include_directories( | ||
| ${CMAKE_SOURCE_DIR}/include | ||
| ${CMAKE_SOURCE_DIR}/include/utilities | ||
| ${CMAKE_SOURCE_DIR}/include/models | ||
| ${CMAKE_SOURCE_DIR}/include/trading | ||
| ${CMAKE_SOURCE_DIR}/include/trading_definitions | ||
| ${CMAKE_SOURCE_DIR}/external | ||
| ) | ||
|
|
||
| # Collect all .cpp files in the src directory | ||
| file(GLOB_RECURSE SOURCES "source/*.cpp") | ||
|
|
||
| # Create a library of your project's code | ||
| add_library(BacktestingEngineLib STATIC ${SOURCES}) | ||
|
|
||
| # Replace find_package(OpenMP REQUIRED) with this: | ||
| if(APPLE) | ||
| set(OpenMP_C_FLAGS "-Xclang -fopenmp") | ||
| set(OpenMP_CXX_FLAGS "-Xclang -fopenmp") | ||
| set(OpenMP_C_LIB_NAMES "omp") | ||
| set(OpenMP_CXX_LIB_NAMES "omp") | ||
| set(OpenMP_omp_LIBRARY /opt/homebrew/opt/libomp/lib/libomp.dylib) | ||
| find_package(OpenMP REQUIRED) | ||
| target_include_directories(BacktestingEngineLib PRIVATE /opt/homebrew/opt/libomp/include) | ||
| endif() | ||
|
|
||
| target_link_libraries(BacktestingEngineLib PUBLIC pqxx OpenMP::OpenMP_CXX) | ||
|
|
||
|
Comment on lines
+56
to
+67
|
||
| # Main executable | ||
| add_executable(BacktestingEngine source/main.cpp) | ||
| target_link_libraries(BacktestingEngine BacktestingEngineLib) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is missing a shebang (e.g.,
#!/bin/bashor#!/usr/bin/env bash). As-is, running it directly (instead ofsh scripts/build_dep.sh) may fail depending on permissions/default shell. Add a shebang and considerset -euo pipefailso dependency builds fail fast.