Skip to content

Commit be3731b

Browse files
committed
Updating Database constructor
1 parent 9053a11 commit be3731b

File tree

11 files changed

+33
-19
lines changed

11 files changed

+33
-19
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## C++ Backtesting Engine
22

33
> [!NOTE]
4-
> Active development - Usuable at the moment. Last updated 24th Jan 2025
4+
> Active development - Usuable at the moment. Last updated 25th Jan 2025
55
66
### About The Project
77

source/databaseConnection.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
#include "databaseConnection.hpp"
88
#include <pqxx/pqxx>
99

10+
DatabaseConnection::DatabaseConnection(const std::string& endpoint, int port,
11+
const std::string& dbname, const std::string& user,
12+
const std::string& password) {
13+
connection_string =
14+
"host=" + endpoint + " "
15+
"port=" + std::to_string(port) + " "
16+
"dbname=" + dbname + " "
17+
"user=" + user + " "
18+
"password=" + password + " "
19+
"connect_timeout=3";
20+
}
21+
1022
void DatabaseConnection::executeQuery(const std::string& query) {
1123
try {
1224
// Establish connection

source/include/configManager.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Backtesting Engine in C++
22
//
3-
// (c) 2024 Ryan McCaffery | https://mccaffers.com
3+
// (c) 2025 Ryan McCaffery | https://mccaffers.com
44
// This code is licensed under MIT license (see LICENSE.txt for details)
55
// ---------------------------------------
66
#pragma once

source/include/databaseConnection.hpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Backtesting Engine in C++
22
//
3-
// (c) 2024 Ryan McCaffery | https://mccaffers.com
3+
// (c) 2025 Ryan McCaffery | https://mccaffers.com
44
// This code is licensed under MIT license (see LICENSE.txt for details)
55
// ---------------------------------------
66
#pragma once
@@ -12,15 +12,11 @@ class DatabaseConnection {
1212
std::string connection_string;
1313

1414
public:
15-
DatabaseConnection(const std::string& endpoint) {
16-
connection_string =
17-
"host=" + endpoint + " "
18-
"port=8812 "
19-
"dbname=qdb "
20-
"user=admin "
21-
"password=quest "
22-
"connect_timeout=3";
23-
}
15+
DatabaseConnection(const std::string& endpoint = "localhost",
16+
int port = 8812,
17+
const std::string& dbname = "qdb",
18+
const std::string& user = "admin",
19+
const std::string& password = "quest");
2420

2521
void executeQuery(const std::string& query);
2622

source/include/serviceA.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Backtesting Engine in C++
22
//
3-
// (c) 2024 Ryan McCaffery | https://mccaffers.com
3+
// (c) 2025 Ryan McCaffery | https://mccaffers.com
44
// This code is licensed under MIT license (see LICENSE.txt for details)
55
// ---------------------------------------
6+
67
#pragma once
78
#include <iostream>
89
#include "configManager.hpp"

source/include/trading_definitions/ohlc_rsi_variables.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ struct OHLCRSIVariables {
1313
int RSI_SHORT;
1414
};
1515
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(OHLCRSIVariables, RSI_LONG, RSI_SHORT);
16-
} // namespace strategy
16+
}

source/include/trading_definitions/ohlc_variables.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ struct OHLCVariables {
1313
int OHLC_MINUTES;
1414
};
1515
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(OHLCVariables, OHLC_COUNT, OHLC_MINUTES);
16-
} // namespace strategy
16+
}

source/include/trading_definitions/strategy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Strategy,
2626
OHLC_VARIABLES,
2727
STRATEGY_VARIABLES
2828
);
29-
} // namespace strategy
29+
}

source/include/trading_definitions/trading_variables.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TradingVariables,
2121
LIMIT_DISTANCE_IN_PIPS,
2222
TRADING_SIZE
2323
);
24-
} // namespace strategy
24+
}

source/include/utilities/base64.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Backtesting Engine in C++
22
//
3-
// (c) 2024 Ryan McCaffery | https://mccaffers.com
3+
// (c) 2025 Ryan McCaffery | https://mccaffers.com
44
// This code is licensed under MIT license (see LICENSE.txt for details)
55
// ---------------------------------------
66
#pragma once

0 commit comments

Comments
 (0)