Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a small SQL abstraction (SqlManager) and reorganizes/expands public headers under ./include, updating build and IDE configuration accordingly.
Changes:
- Add
SqlManagerand route the initial DB query inmain.cppthrough it. - Introduce/move several headers under
include/and update CMake include paths to match. - Minor tooling/IDE updates (run script env sourcing removed; Xcode scheme/project updated).
Reviewed changes
Copilot reviewed 9 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| source/sqlManager.cpp | Implements SqlManager query helpers. |
| include/sqlManager.hpp | Declares SqlManager API for fetching initial price data. |
| source/main.cpp | Switches to SqlManager::getInitialPriceData(db) for initial query. |
| source/jsonParser.cpp | Adds file header banner comment. |
| include/jsonParser.hpp | Adds JsonParser public header. |
| include/databaseConnection.hpp | Adds DatabaseConnection public header. |
| include/models/priceData.hpp | Adds missing <chrono> include for timestamp. |
| include/utilities/base64.hpp | Adds Base64/Utilities header (currently missing required <chrono> include). |
| include/models/trade.hpp | Adds Trade model header (static counter defined in source/models/trade.cpp). |
| include/trading/tradeManager.hpp | Adds TradeManager public header. |
| include/trading_definitions.hpp | Convenience umbrella header for trading definitions. |
| include/trading_definitions/configuration.hpp | Adds Configuration model + JSON mapping. |
| include/trading_definitions/strategy.hpp | Adds Strategy model + JSON mapping. |
| include/trading_definitions/strategy_variables.hpp | Adds StrategyVariables model and JSON (de)serialization declarations. |
| include/trading_definitions/trading_variables.hpp | Adds TradingVariables model + JSON mapping. |
| include/trading_definitions/ohlc_variables.hpp | Adds OHLCVariables model + JSON mapping. |
| include/trading_definitions/ohlc_rsi_variables.hpp | Adds OHLCRSIVariables model + JSON mapping. |
| include/configManager.hpp | Adds ConfigManager header. |
| include/serviceA.hpp | Adds ServiceA header. |
| scripts/run.sh | Stops sourcing environment.sh (commented as unnecessary). |
| CMakeLists.txt | Updates include directories to ./include/.... |
| backtesting-engine-cpp.xcodeproj/xcshareddata/xcschemes/source.xcscheme | Changes default CLI argument to localhost. |
| backtesting-engine-cpp.xcodeproj/project.pbxproj | Adds include group + wires sqlManager.cpp/.hpp into the Xcode project. |
Comments suppressed due to low confidence (1)
source/main.cpp:41
priceData[0]is accessed unconditionally, butSqlManager::getInitialPriceData()can return an empty vector (e.g. query returns zero rows or the DB call fails and returns empty results). This will cause out-of-bounds access and undefined behavior. Add an explicit empty-check (and handle/report the error) before usingpriceData[0].
std::vector<PriceData> priceData = SqlManager::getInitialPriceData(db);
// Convert timestamp to readable format for debugging
auto timeT = std::chrono::system_clock::to_time_t(priceData[0].timestamp);
std::cout << "Timestamp: " << std::put_time(std::localtime(&timeT), "%Y-%m-%d %H:%M:%S") << std::endl;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ${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 |
There was a problem hiding this comment.
This PR changes the canonical header location from ./source/include to ./include (via include paths), but CONVENTIONS.md still documents headers as living under ./source/include. Either update the documentation to match the new layout, or keep the include paths aligned with the documented convention to avoid confusion for contributors.
| ${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}/source/include | |
| ${CMAKE_SOURCE_DIR}/source/include/utilities | |
| ${CMAKE_SOURCE_DIR}/source/include/models | |
| ${CMAKE_SOURCE_DIR}/source/include/trading | |
| ${CMAKE_SOURCE_DIR}/source/include/trading_definitions |
| # Include directories | ||
| include_directories( | ||
| ${CMAKE_SOURCE_DIR}/source/include | ||
| ${CMAKE_SOURCE_DIR}/source/include/utilities | ||
| ${CMAKE_SOURCE_DIR}/source/include/models | ||
| ${CMAKE_SOURCE_DIR}/source/include/trading | ||
| ${CMAKE_SOURCE_DIR}/source/include/trading_definitions | ||
| ${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 | ||
| ) |
There was a problem hiding this comment.
PR title "Dev/gitignore" doesn't appear to match the actual changes (new SQL manager, header relocation, script tweak, Xcode scheme update). Consider renaming the PR and/or adding a short description so reviewers understand the intent/scope.
| #include <vector> | ||
| #include "models/priceData.hpp" | ||
| #include "databaseConnection.hpp" | ||
|
|
||
| class SqlManager { | ||
| public: | ||
| static std::vector<PriceData> getInitialPriceData(const DatabaseConnection& db); | ||
| static std::string getBaseQuery(); |
There was a problem hiding this comment.
SqlManager.hpp includes databaseConnection.hpp, which itself pulls in <pqxx/pqxx>. Since this header only needs DatabaseConnection as a reference type, consider forward-declaring class DatabaseConnection; here and including databaseConnection.hpp in source/sqlManager.cpp instead. This reduces transitive dependencies/compile time for any file that includes sqlManager.hpp.
No description provided.