diff --git a/.clang-tidy b/.clang-tidy index 1fd5dc5f..451697a3 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -6,7 +6,6 @@ Checks: "-*,\ google-readability-casting,\ misc-*,\ -misc-non-private-member-variables-in-classes,\ - -misc-include-cleaner,\ -misc-const-correctness,\ modernize-*,\ -modernize-avoid-c-arrays,\ diff --git a/src/api-objects/include/order.hpp b/src/api-objects/include/order.hpp index f7699fc3..d7c77af0 100644 --- a/src/api-objects/include/order.hpp +++ b/src/api-objects/include/order.hpp @@ -4,6 +4,7 @@ #include #include "cct_string.hpp" +#include "cct_type_traits.hpp" #include "market.hpp" #include "monetaryamount.hpp" #include "orderid.hpp" diff --git a/src/api-objects/include/withdraw.hpp b/src/api-objects/include/withdraw.hpp index b8a55bc4..3a649485 100644 --- a/src/api-objects/include/withdraw.hpp +++ b/src/api-objects/include/withdraw.hpp @@ -1,5 +1,9 @@ #pragma once +#include + +#include "monetaryamount.hpp" +#include "timedef.hpp" #include "withdrawordeposit.hpp" namespace cct { diff --git a/src/api-objects/src/apikeysprovider.cpp b/src/api-objects/src/apikeysprovider.cpp index 22339b09..f73dafb6 100644 --- a/src/api-objects/src/apikeysprovider.cpp +++ b/src/api-objects/src/apikeysprovider.cpp @@ -1,11 +1,20 @@ #include "apikeysprovider.hpp" +#include #include +#include +#include +#include "accountowner.hpp" +#include "apikey.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "exchangename.hpp" +#include "exchangesecretsinfo.hpp" #include "file.hpp" +#include "runmodes.hpp" namespace cct::api { namespace { diff --git a/src/api-objects/src/order.cpp b/src/api-objects/src/order.cpp index 66a1e9b7..6f412a3c 100644 --- a/src/api-objects/src/order.cpp +++ b/src/api-objects/src/order.cpp @@ -1,6 +1,13 @@ #include "order.hpp" +#include +#include + +#include "cct_string.hpp" +#include "monetaryamount.hpp" +#include "timedef.hpp" #include "timestring.hpp" +#include "tradeside.hpp" namespace cct { diff --git a/src/api-objects/src/ordersconstraints.cpp b/src/api-objects/src/ordersconstraints.cpp index 43ad9c68..ff6745d4 100644 --- a/src/api-objects/src/ordersconstraints.cpp +++ b/src/api-objects/src/ordersconstraints.cpp @@ -1,5 +1,10 @@ #include "ordersconstraints.hpp" +#include + +#include "currencycode.hpp" +#include "timedef.hpp" + namespace cct { OrdersConstraints::OrdersConstraints(CurrencyCode cur1, CurrencyCode cur2, Duration minAge, Duration maxAge, diff --git a/src/api-objects/src/publictrade.cpp b/src/api-objects/src/publictrade.cpp index b40a254c..5ba601fa 100644 --- a/src/api-objects/src/publictrade.cpp +++ b/src/api-objects/src/publictrade.cpp @@ -1,5 +1,6 @@ #include "publictrade.hpp" +#include "cct_string.hpp" #include "timestring.hpp" namespace cct { diff --git a/src/api-objects/src/recentdeposit.cpp b/src/api-objects/src/recentdeposit.cpp index 38b2d9f9..3a038cfc 100644 --- a/src/api-objects/src/recentdeposit.cpp +++ b/src/api-objects/src/recentdeposit.cpp @@ -1,8 +1,9 @@ #include "recentdeposit.hpp" #include +#include +#include -#include "cct_exception.hpp" #include "cct_log.hpp" namespace cct::api { diff --git a/src/api-objects/src/tradeoptions.cpp b/src/api-objects/src/tradeoptions.cpp index 93091de2..f0090958 100644 --- a/src/api-objects/src/tradeoptions.cpp +++ b/src/api-objects/src/tradeoptions.cpp @@ -1,9 +1,13 @@ #include "tradeoptions.hpp" -#include +#include +#include -#include "cct_invalid_argument_exception.hpp" +#include "cct_string.hpp" +#include "priceoptions.hpp" #include "stringhelpers.hpp" +#include "timedef.hpp" +#include "tradedefinitions.hpp" #include "unreachable.hpp" namespace cct { @@ -75,9 +79,9 @@ string TradeOptions::str(bool placeRealOrderInSimulationMode) const { ret.append(", "); ret.append(tradeSyncPolicyStr()); ret.append(" mode, timeout of "); - AppendString(ret, std::chrono::duration_cast(_maxTradeTime).count()); + AppendString(ret, std::chrono::duration_cast(_maxTradeTime).count()); ret.append("s, ").append(timeoutActionStr()).append(" at timeout, min time between two price updates of "); - AppendString(ret, std::chrono::duration_cast(_minTimeBetweenPriceUpdates).count()); + AppendString(ret, std::chrono::duration_cast(_minTimeBetweenPriceUpdates).count()); ret.push_back('s'); return ret; } diff --git a/src/api-objects/src/withdrawinfo.cpp b/src/api-objects/src/withdrawinfo.cpp index aefcb050..e413d021 100644 --- a/src/api-objects/src/withdrawinfo.cpp +++ b/src/api-objects/src/withdrawinfo.cpp @@ -1,6 +1,12 @@ #include "withdrawinfo.hpp" +#include +#include + #include "cct_exception.hpp" +#include "monetaryamount.hpp" +#include "timedef.hpp" +#include "wallet.hpp" namespace cct { namespace api { diff --git a/src/api-objects/src/withdrawoptions.cpp b/src/api-objects/src/withdrawoptions.cpp index e82197ca..7f664bc5 100644 --- a/src/api-objects/src/withdrawoptions.cpp +++ b/src/api-objects/src/withdrawoptions.cpp @@ -1,5 +1,8 @@ #include "withdrawoptions.hpp" +#include + +#include "timedef.hpp" #include "unreachable.hpp" namespace cct { diff --git a/src/api-objects/src/withdrawordeposit.cpp b/src/api-objects/src/withdrawordeposit.cpp index 52f6a5c5..9c9896de 100644 --- a/src/api-objects/src/withdrawordeposit.cpp +++ b/src/api-objects/src/withdrawordeposit.cpp @@ -1,5 +1,8 @@ #include "withdrawordeposit.hpp" +#include + +#include "cct_string.hpp" #include "timestring.hpp" #include "unreachable.hpp" diff --git a/src/api-objects/src/withdrawsordepositsconstraints.cpp b/src/api-objects/src/withdrawsordepositsconstraints.cpp index 0e2289f4..0ce0dd1d 100644 --- a/src/api-objects/src/withdrawsordepositsconstraints.cpp +++ b/src/api-objects/src/withdrawsordepositsconstraints.cpp @@ -1,5 +1,12 @@ #include "withdrawsordepositsconstraints.hpp" +#include +#include + +#include "baseconstraints.hpp" +#include "currencycode.hpp" +#include "timedef.hpp" + namespace cct { WithdrawsOrDepositsConstraints::WithdrawsOrDepositsConstraints(CurrencyCode currencyCode, Duration minAge, Duration maxAge, IdSet &&idSet) diff --git a/src/api-objects/test/deposit_test.cpp b/src/api-objects/test/deposit_test.cpp index b6151526..c753eb81 100644 --- a/src/api-objects/test/deposit_test.cpp +++ b/src/api-objects/test/deposit_test.cpp @@ -1,15 +1,22 @@ #include "deposit.hpp" +#include + +#include +#include +#include + #include "cct_vector.hpp" -#include "gtest/gtest.h" +#include "monetaryamount.hpp" +#include "timedef.hpp" namespace cct { class DepositTest : public ::testing::Test { protected: - TimePoint tp1{std::chrono::milliseconds{std::numeric_limits::max() / 10000000}}; - TimePoint tp2{std::chrono::milliseconds{std::numeric_limits::max() / 9000000}}; - TimePoint tp3{std::chrono::milliseconds{std::numeric_limits::max() / 8000000}}; - TimePoint tp4{std::chrono::milliseconds{std::numeric_limits::max() / 7000000}}; + TimePoint tp1{TimeInMs{std::numeric_limits::max() / 10000000}}; + TimePoint tp2{TimeInMs{std::numeric_limits::max() / 9000000}}; + TimePoint tp3{TimeInMs{std::numeric_limits::max() / 8000000}}; + TimePoint tp4{TimeInMs{std::numeric_limits::max() / 7000000}}; Deposit deposit1{"id1", tp2, MonetaryAmount("0.045", "BTC"), Deposit::Status::kSuccess}; Deposit deposit2{"id2", tp4, MonetaryAmount(37, "XRP"), Deposit::Status::kSuccess}; @@ -22,6 +29,7 @@ class DepositTest : public ::testing::Test { TEST_F(DepositTest, SortByTimeFirst) { std::ranges::sort(deposits); + EXPECT_EQ(deposits.front(), deposit3); EXPECT_EQ(deposits.back(), deposit4); } diff --git a/src/api-objects/test/ordersconstraints_test.cpp b/src/api-objects/test/ordersconstraints_test.cpp index 85f67282..62e3a522 100644 --- a/src/api-objects/test/ordersconstraints_test.cpp +++ b/src/api-objects/test/ordersconstraints_test.cpp @@ -2,6 +2,8 @@ #include +#include "market.hpp" + namespace cct { TEST(OrderConstraintsBitmapTest, Empty) { OrderConstraintsBitmap bmp; diff --git a/src/api-objects/test/recentdeposit_test.cpp b/src/api-objects/test/recentdeposit_test.cpp index d200348b..168b69bf 100644 --- a/src/api-objects/test/recentdeposit_test.cpp +++ b/src/api-objects/test/recentdeposit_test.cpp @@ -2,6 +2,11 @@ #include +#include + +#include "monetaryamount.hpp" +#include "timedef.hpp" + namespace cct::api { inline bool operator==(const RecentDeposit &lhs, const RecentDeposit &rhs) { diff --git a/src/api-objects/test/withdraw_test.cpp b/src/api-objects/test/withdraw_test.cpp index cddcebc9..fb0bbbb2 100644 --- a/src/api-objects/test/withdraw_test.cpp +++ b/src/api-objects/test/withdraw_test.cpp @@ -1,15 +1,22 @@ #include "withdraw.hpp" +#include + +#include +#include +#include + #include "cct_vector.hpp" -#include "gtest/gtest.h" +#include "monetaryamount.hpp" +#include "timedef.hpp" namespace cct { class WithdrawTest : public ::testing::Test { protected: - TimePoint tp1{std::chrono::milliseconds{std::numeric_limits::max() / 10000000}}; - TimePoint tp2{std::chrono::milliseconds{std::numeric_limits::max() / 9000000}}; - TimePoint tp3{std::chrono::milliseconds{std::numeric_limits::max() / 8000000}}; - TimePoint tp4{std::chrono::milliseconds{std::numeric_limits::max() / 7000000}}; + TimePoint tp1{TimeInMs{std::numeric_limits::max() / 10000000}}; + TimePoint tp2{TimeInMs{std::numeric_limits::max() / 9000000}}; + TimePoint tp3{TimeInMs{std::numeric_limits::max() / 8000000}}; + TimePoint tp4{TimeInMs{std::numeric_limits::max() / 7000000}}; Withdraw withdraw1{"id1", tp2, MonetaryAmount("0.045", "BTC"), Withdraw::Status::kSuccess, MonetaryAmount("0.001", "BTC")}; @@ -26,6 +33,7 @@ class WithdrawTest : public ::testing::Test { TEST_F(WithdrawTest, SortByTimeFirst) { std::ranges::sort(withdraws); + EXPECT_EQ(withdraws.front(), withdraw3); EXPECT_EQ(withdraws.back(), withdraw4); } diff --git a/src/api/common/include/commonapi.hpp b/src/api/common/include/commonapi.hpp index 13858bfb..35e6318f 100644 --- a/src/api/common/include/commonapi.hpp +++ b/src/api/common/include/commonapi.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "cachedresult.hpp" diff --git a/src/api/common/include/exchangebase.hpp b/src/api/common/include/exchangebase.hpp index 36df5912..ce72770e 100644 --- a/src/api/common/include/exchangebase.hpp +++ b/src/api/common/include/exchangebase.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "cachedresultvault.hpp" namespace cct::api { diff --git a/src/api/common/include/exchangeprivateapi_mock.hpp b/src/api/common/include/exchangeprivateapi_mock.hpp index e6731f98..2377e768 100644 --- a/src/api/common/include/exchangeprivateapi_mock.hpp +++ b/src/api/common/include/exchangeprivateapi_mock.hpp @@ -2,8 +2,18 @@ #include +#include "balanceoptions.hpp" +#include "balanceportfolio.hpp" +#include "currencycode.hpp" +#include "depositsconstraints.hpp" #include "exchangeprivateapi.hpp" #include "exchangeprivateapitypes.hpp" +#include "monetaryamount.hpp" +#include "ordersconstraints.hpp" +#include "tradeinfo.hpp" +#include "wallet.hpp" +#include "withdrawinfo.hpp" +#include "withdrawsconstraints.hpp" namespace cct::api { diff --git a/src/api/common/src/commonapi.cpp b/src/api/common/src/commonapi.cpp index 488cbfc5..28a661c3 100644 --- a/src/api/common/src/commonapi.cpp +++ b/src/api/common/src/commonapi.cpp @@ -1,14 +1,19 @@ #include "commonapi.hpp" -#include +#include #include +#include +#include "cachedresult.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" #include "curloptions.hpp" +#include "currencycode.hpp" #include "file.hpp" +#include "httprequesttype.hpp" #include "permanentcurloptions.hpp" #include "timedef.hpp" @@ -35,7 +40,7 @@ CommonAPI::CommonAPI(const CoincenterInfo& config, Duration fiatsUpdateFrequency fiats.emplace_hint(fiats.end(), std::move(val.get_ref())); } log::debug("Loaded {} fiats from cache file", fiats.size()); - _fiatsCache.set(std::move(fiats), TimePoint(std::chrono::seconds(timeEpoch))); + _fiatsCache.set(std::move(fiats), TimePoint(TimeInS(timeEpoch))); } } } @@ -70,13 +75,13 @@ CommonAPI::Fiats CommonAPI::FiatsFunc::operator()() { } void CommonAPI::updateCacheFile() const { - File fiatsCacheFile = GetFiatCacheFile(_coincenterInfo.dataDir()); - json data = fiatsCacheFile.readAllJson(); - auto fiatsPtrLastUpdatedTimePair = _fiatsCache.retrieve(); - auto timeEpochIt = data.find("timeepoch"); + const auto fiatsCacheFile = GetFiatCacheFile(_coincenterInfo.dataDir()); + auto data = fiatsCacheFile.readAllJson(); + const auto fiatsPtrLastUpdatedTimePair = _fiatsCache.retrieve(); + const auto timeEpochIt = data.find("timeepoch"); if (timeEpochIt != data.end()) { - int64_t lastTimeFileUpdated = timeEpochIt->get(); - if (TimePoint(std::chrono::seconds(lastTimeFileUpdated)) >= fiatsPtrLastUpdatedTimePair.second) { + const int64_t lastTimeFileUpdated = timeEpochIt->get(); + if (TimePoint(TimeInS(lastTimeFileUpdated)) >= fiatsPtrLastUpdatedTimePair.second) { return; // No update } } diff --git a/src/api/common/src/exchangepublicapi.cpp b/src/api/common/src/exchangepublicapi.cpp index 6eff220b..f3bd8cfe 100644 --- a/src/api/common/src/exchangepublicapi.cpp +++ b/src/api/common/src/exchangepublicapi.cpp @@ -1,12 +1,28 @@ #include "exchangepublicapi.hpp" +#include +#include +#include +#include +#include +#include #include +#include -#include "cct_allocator.hpp" #include "cct_exception.hpp" +#include "cct_smallvector.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" +#include "commonapi.hpp" +#include "currencycode.hpp" +#include "exchangeinfo.hpp" +#include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" -#include "unreachable.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" +#include "monetaryamount.hpp" +#include "priceoptions.hpp" +#include "priceoptionsdef.hpp" namespace cct::api { ExchangePublic::ExchangePublic(std::string_view name, FiatConverter &fiatConverter, CommonAPI &commonApi, diff --git a/src/api/common/src/fiatconverter.cpp b/src/api/common/src/fiatconverter.cpp index d0097fbc..0d43a74c 100644 --- a/src/api/common/src/fiatconverter.cpp +++ b/src/api/common/src/fiatconverter.cpp @@ -1,10 +1,22 @@ #include "fiatconverter.hpp" +#include +#include +#include +#include +#include + #include "cct_exception.hpp" #include "cct_json.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" #include "curloptions.hpp" +#include "currencycode.hpp" #include "file.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "permanentcurloptions.hpp" +#include "timedef.hpp" namespace cct { namespace { @@ -49,8 +61,7 @@ FiatConverter::FiatConverter(const CoincenterInfo& coincenterInfo, Duration rate double rate = rateAndTimeData["rate"]; int64_t timeepoch = rateAndTimeData["timeepoch"]; log::trace("Stored rate {} for market {} from {}", rate, marketStr, kRatesCacheFile); - _pricesMap.insert_or_assign(Market(marketStr, '-'), - PriceTimedValue{rate, TimePoint(std::chrono::seconds(timeepoch))}); + _pricesMap.insert_or_assign(Market(marketStr, '-'), PriceTimedValue{rate, TimePoint(TimeInS(timeepoch))}); } log::debug("Loaded {} fiat currency rates from {}", _pricesMap.size(), kRatesCacheFile); } diff --git a/src/api/common/src/ssl_sha.cpp b/src/api/common/src/ssl_sha.cpp index 55f5c144..6fb18fd0 100644 --- a/src/api/common/src/ssl_sha.cpp +++ b/src/api/common/src/ssl_sha.cpp @@ -1,14 +1,17 @@ #include "ssl_sha.hpp" +#include #include #include #include #include -#include #include +#include +#include #include "cct_exception.hpp" +#include "cct_string.hpp" #include "codec.hpp" namespace cct::ssl { diff --git a/src/api/common/test/commonapi_test.cpp b/src/api/common/test/commonapi_test.cpp index cbdd4302..54de6ddb 100644 --- a/src/api/common/test/commonapi_test.cpp +++ b/src/api/common/test/commonapi_test.cpp @@ -4,6 +4,7 @@ #include #include "coincenterinfo.hpp" +#include "runmodes.hpp" namespace cct::api { diff --git a/src/api/common/test/exchangeprivateapi_test.cpp b/src/api/common/test/exchangeprivateapi_test.cpp index f8347f28..e46811d8 100644 --- a/src/api/common/test/exchangeprivateapi_test.cpp +++ b/src/api/common/test/exchangeprivateapi_test.cpp @@ -3,13 +3,45 @@ #include #include +#include +#include +#include + +#include "accountowner.hpp" +#include "balanceoptions.hpp" +#include "balanceportfolio.hpp" #include "cct_const.hpp" +#include "cct_exception.hpp" #include "coincenterinfo.hpp" +#include "commonapi.hpp" +#include "currencycode.hpp" +#include "exchangeinfo.hpp" #include "exchangeprivateapi_mock.hpp" +#include "exchangeprivateapitypes.hpp" #include "exchangepublicapi_mock.hpp" #include "exchangepublicapitypes.hpp" +#include "fiatconverter.hpp" +#include "loadconfiguration.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" +#include "monetaryamount.hpp" +#include "orderid.hpp" +#include "priceoptions.hpp" +#include "priceoptionsdef.hpp" +#include "runmodes.hpp" #include "stringhelpers.hpp" +#include "timedef.hpp" +#include "tradedamounts.hpp" +#include "tradedefinitions.hpp" +#include "tradeinfo.hpp" +#include "tradeoptions.hpp" +#include "tradeside.hpp" +#include "volumeandpricenbdecimals.hpp" +#include "wallet.hpp" +#include "withdraw.hpp" +#include "withdrawinfo.hpp" #include "withdrawoptions.hpp" +#include "withdrawordeposit.hpp" namespace cct { inline bool operator==(const DeliveredWithdrawInfo &lhs, const DeliveredWithdrawInfo &rhs) { diff --git a/src/api/common/test/fiatconverter_test.cpp b/src/api/common/test/fiatconverter_test.cpp index 118aeec6..886d16ec 100644 --- a/src/api/common/test/fiatconverter_test.cpp +++ b/src/api/common/test/fiatconverter_test.cpp @@ -2,10 +2,16 @@ #include +#include + +#include "besturlpicker.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "coincenterinfo.hpp" #include "curlhandle.hpp" +#include "permanentcurloptions.hpp" +#include "runmodes.hpp" +#include "timedef.hpp" namespace cct { @@ -80,7 +86,7 @@ class FiatConverterTest : public ::testing::Test { protected: settings::RunMode runMode = settings::RunMode::kTestKeys; CoincenterInfo coincenterInfo{runMode}; - FiatConverter converter{coincenterInfo, std::chrono::milliseconds(1)}; + FiatConverter converter{coincenterInfo, TimeInMs(1)}; }; TEST_F(FiatConverterTest, DirectConversion) { diff --git a/src/api/common/test/ssl_sha_test.cpp b/src/api/common/test/ssl_sha_test.cpp index 4a7f5f7e..a109c580 100644 --- a/src/api/common/test/ssl_sha_test.cpp +++ b/src/api/common/test/ssl_sha_test.cpp @@ -4,6 +4,9 @@ #include #include +#include + +#include "cct_string.hpp" namespace cct::ssl { TEST(SSLTest, Version) { EXPECT_NE(GetOpenSSLVersion(), ""); } diff --git a/src/api/exchanges/include/binanceprivateapi.hpp b/src/api/exchanges/include/binanceprivateapi.hpp index 9e1f3a0f..2c08ac45 100644 --- a/src/api/exchanges/include/binanceprivateapi.hpp +++ b/src/api/exchanges/include/binanceprivateapi.hpp @@ -1,14 +1,27 @@ #pragma once +#include + +#include "apikey.hpp" +#include "balanceoptions.hpp" +#include "balanceportfolio.hpp" #include "cachedresult.hpp" -#include "cct_json.hpp" #include "curlhandle.hpp" -#include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencyexchangeflatset.hpp" +#include "depositsconstraints.hpp" #include "exchangeprivateapi.hpp" #include "exchangeprivateapitypes.hpp" #include "exchangepublicapitypes.hpp" +#include "httprequesttype.hpp" +#include "monetaryamount.hpp" +#include "ordersconstraints.hpp" #include "timedef.hpp" #include "tradeinfo.hpp" +#include "wallet.hpp" +#include "withdrawinfo.hpp" +#include "withdrawsconstraints.hpp" namespace cct { diff --git a/src/api/exchanges/include/binancepublicapi.hpp b/src/api/exchanges/include/binancepublicapi.hpp index beab4963..19fe4e0c 100644 --- a/src/api/exchanges/include/binancepublicapi.hpp +++ b/src/api/exchanges/include/binancepublicapi.hpp @@ -7,10 +7,15 @@ #include "cct_json.hpp" #include "curlhandle.hpp" #include "currencycode.hpp" +#include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" #include "exchangepublicapi.hpp" #include "exchangepublicapitypes.hpp" +#include "market.hpp" +#include "monetaryamount.hpp" +#include "permanentcurloptions.hpp" +#include "runmodes.hpp" #include "timedef.hpp" -#include "volumeandpricenbdecimals.hpp" namespace cct { diff --git a/src/api/exchanges/include/kucoinpublicapi.hpp b/src/api/exchanges/include/kucoinpublicapi.hpp index d47db1ce..b735f058 100644 --- a/src/api/exchanges/include/kucoinpublicapi.hpp +++ b/src/api/exchanges/include/kucoinpublicapi.hpp @@ -9,7 +9,7 @@ #include "cct_json.hpp" #include "cct_string.hpp" #include "curlhandle.hpp" -#include "curloptions.hpp" +#include "curlpostdata.hpp" #include "currencycode.hpp" #include "exchangepublicapi.hpp" #include "exchangepublicapitypes.hpp" diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index c94cc668..dce47bba 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -1,18 +1,57 @@ #include "binanceprivateapi.hpp" +#include +#include +#include +#include +#include +#include +#include #include #include +#include #include "apikey.hpp" +#include "apiquerytypeenum.hpp" +#include "balanceoptions.hpp" +#include "balanceportfolio.hpp" #include "binancepublicapi.hpp" +#include "cachedresult.hpp" +#include "cct_exception.hpp" +#include "cct_json.hpp" #include "cct_smallvector.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" +#include "curlhandle.hpp" +#include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencyexchangeflatset.hpp" +#include "deposit.hpp" +#include "depositsconstraints.hpp" +#include "exchangename.hpp" +#include "exchangeprivateapi.hpp" +#include "exchangeprivateapitypes.hpp" +#include "exchangepublicapitypes.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "monetaryamount.hpp" +#include "order.hpp" +#include "orderid.hpp" +#include "ordersconstraints.hpp" +#include "permanentcurloptions.hpp" #include "recentdeposit.hpp" #include "ssl_sha.hpp" #include "stringhelpers.hpp" #include "timedef.hpp" #include "timestring.hpp" +#include "tradedamounts.hpp" #include "tradeinfo.hpp" +#include "tradeside.hpp" +#include "wallet.hpp" +#include "withdraw.hpp" +#include "withdrawinfo.hpp" +#include "withdrawsconstraints.hpp" namespace cct::api { @@ -620,7 +659,7 @@ PlaceOrderInfo BinancePrivate::placeOrder(MonetaryAmount from, MonetaryAmount vo placeOrderInfo.setClosed(); return placeOrderInfo; } - SetString(placeOrderInfo.orderId, result["orderId"].get()); + SetString(placeOrderInfo.orderId, result["orderId"].get()); std::string_view status = result["status"].get(); if (status == "FILLED" || status == "REJECTED" || status == "EXPIRED") { if (status == "FILLED") { diff --git a/src/api/exchanges/src/binancepublicapi.cpp b/src/api/exchanges/src/binancepublicapi.cpp index 108168b6..9d3da3f7 100644 --- a/src/api/exchanges/src/binancepublicapi.cpp +++ b/src/api/exchanges/src/binancepublicapi.cpp @@ -3,21 +3,42 @@ #include #include #include -#include -#include +#include +#include +#include +#include +#include #include +#include -#include "apikey.hpp" +#include "apiquerytypeenum.hpp" +#include "cachedresult.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" -#include "codec.hpp" +#include "cct_string.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" #include "commonapi.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencycodeset.hpp" +#include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" +#include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" #include "monetaryamount.hpp" -#include "ssl_sha.hpp" +#include "permanentcurloptions.hpp" +#include "runmodes.hpp" +#include "timedef.hpp" +#include "tradeside.hpp" +#include "volumeandpricenbdecimals.hpp" namespace cct::api { namespace { diff --git a/src/api/exchanges/src/bithumbprivateapi.cpp b/src/api/exchanges/src/bithumbprivateapi.cpp index 7e874200..93cc434c 100644 --- a/src/api/exchanges/src/bithumbprivateapi.cpp +++ b/src/api/exchanges/src/bithumbprivateapi.cpp @@ -27,15 +27,23 @@ #include "coincenterinfo.hpp" #include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "currencycode.hpp" +#include "deposit.hpp" +#include "depositsconstraints.hpp" #include "exchangeinfo.hpp" +#include "exchangename.hpp" +#include "exchangeprivateapi.hpp" #include "exchangeprivateapitypes.hpp" #include "exchangepublicapitypes.hpp" #include "file.hpp" #include "httprequesttype.hpp" +#include "market.hpp" #include "monetaryamount.hpp" #include "order.hpp" +#include "orderid.hpp" #include "ordersconstraints.hpp" +#include "permanentcurloptions.hpp" #include "runmodes.hpp" #include "ssl_sha.hpp" #include "stringhelpers.hpp" @@ -47,6 +55,7 @@ #include "tradeside.hpp" #include "wallet.hpp" #include "withdraw.hpp" +#include "withdrawinfo.hpp" #include "withdrawordeposit.hpp" #include "withdrawsconstraints.hpp" #include "withdrawsordepositsconstraints.hpp" diff --git a/src/api/exchanges/src/bithumbpublicapi.cpp b/src/api/exchanges/src/bithumbpublicapi.cpp index b71732b0..f80a089c 100644 --- a/src/api/exchanges/src/bithumbpublicapi.cpp +++ b/src/api/exchanges/src/bithumbpublicapi.cpp @@ -1,6 +1,8 @@ #include "bithumbpublicapi.hpp" #include +#include +#include #include #include #include @@ -22,7 +24,10 @@ #include "curlhandle.hpp" #include "curloptions.hpp" #include "currencycode.hpp" +#include "currencycodeset.hpp" #include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" #include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" #include "httprequesttype.hpp" @@ -31,6 +36,7 @@ #include "monetaryamount.hpp" #include "permanentcurloptions.hpp" #include "stringhelpers.hpp" +#include "timedef.hpp" #include "timestring.hpp" #include "tradeside.hpp" diff --git a/src/api/exchanges/src/huobiprivateapi.cpp b/src/api/exchanges/src/huobiprivateapi.cpp index 48c56d19..1d629afd 100644 --- a/src/api/exchanges/src/huobiprivateapi.cpp +++ b/src/api/exchanges/src/huobiprivateapi.cpp @@ -1,17 +1,54 @@ #include "huobiprivateapi.hpp" +#include +#include +#include #include -#include +#include +#include +#include #include "apikey.hpp" +#include "apiquerytypeenum.hpp" +#include "balanceoptions.hpp" +#include "balanceportfolio.hpp" +#include "cachedresult.hpp" +#include "cct_exception.hpp" +#include "cct_json.hpp" +#include "cct_string.hpp" +#include "cct_vector.hpp" #include "codec.hpp" #include "coincenterinfo.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "deposit.hpp" +#include "depositsconstraints.hpp" +#include "exchangename.hpp" +#include "exchangeprivateapi.hpp" +#include "exchangeprivateapitypes.hpp" +#include "exchangepublicapitypes.hpp" +#include "httprequesttype.hpp" #include "huobipublicapi.hpp" +#include "market.hpp" +#include "monetaryamount.hpp" +#include "order.hpp" +#include "orderid.hpp" +#include "ordersconstraints.hpp" +#include "permanentcurloptions.hpp" #include "ssl_sha.hpp" #include "stringhelpers.hpp" +#include "timedef.hpp" #include "timestring.hpp" #include "toupperlower.hpp" +#include "tradedamounts.hpp" +#include "tradeinfo.hpp" +#include "tradeside.hpp" +#include "wallet.hpp" +#include "withdraw.hpp" +#include "withdrawinfo.hpp" +#include "withdrawsconstraints.hpp" namespace cct::api { diff --git a/src/api/exchanges/src/huobipublicapi.cpp b/src/api/exchanges/src/huobipublicapi.cpp index 65fc846c..f2273097 100644 --- a/src/api/exchanges/src/huobipublicapi.cpp +++ b/src/api/exchanges/src/huobipublicapi.cpp @@ -1,18 +1,40 @@ #include "huobipublicapi.hpp" #include -#include -#include +#include +#include +#include #include +#include +#include "apiquerytypeenum.hpp" +#include "cachedresult.hpp" #include "cct_exception.hpp" +#include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" #include "commonapi.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencycodeset.hpp" +#include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" +#include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "permanentcurloptions.hpp" +#include "timedef.hpp" #include "toupperlower.hpp" +#include "tradeside.hpp" +#include "volumeandpricenbdecimals.hpp" namespace cct::api { namespace { @@ -421,7 +443,7 @@ LastTradesVector HuobiPublic::queryLastTrades(Market mk, int nbTrades) { TradeSide tradeSide = detail2["direction"].get() == "buy" ? TradeSide::kBuy : TradeSide::kSell; - ret.emplace_back(tradeSide, amount, price, TimePoint(std::chrono::milliseconds(millisecondsSinceEpoch))); + ret.emplace_back(tradeSide, amount, price, TimePoint(TimeInMs(millisecondsSinceEpoch))); } } } diff --git a/src/api/exchanges/src/krakenprivateapi.cpp b/src/api/exchanges/src/krakenprivateapi.cpp index 53313701..e8f68726 100644 --- a/src/api/exchanges/src/krakenprivateapi.cpp +++ b/src/api/exchanges/src/krakenprivateapi.cpp @@ -4,8 +4,10 @@ #include #include #include +#include #include #include +#include #include #include "apikey.hpp" @@ -23,8 +25,10 @@ #include "commonapi.hpp" #include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "currencycode.hpp" #include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" #include "deposit.hpp" #include "depositsconstraints.hpp" #include "exchangeinfo.hpp" diff --git a/src/api/exchanges/src/krakenpublicapi.cpp b/src/api/exchanges/src/krakenpublicapi.cpp index 73d6c2c6..7611560b 100644 --- a/src/api/exchanges/src/krakenpublicapi.cpp +++ b/src/api/exchanges/src/krakenpublicapi.cpp @@ -1,18 +1,41 @@ #include "krakenpublicapi.hpp" -#include +#include +#include +#include +#include +#include #include +#include +#include "apiquerytypeenum.hpp" +#include "cachedresult.hpp" #include "cct_cctype.hpp" -#include "cct_const.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" #include "commonapi.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencycodeset.hpp" +#include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" +#include "exchangepublicapitypes.hpp" +#include "fiatconverter.hpp" #include "file.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" +#include "monetaryamount.hpp" +#include "permanentcurloptions.hpp" #include "timedef.hpp" +#include "tradeside.hpp" namespace cct::api { namespace { @@ -101,7 +124,7 @@ KrakenPublic::KrakenPublic(const CoincenterInfo& config, FiatConverter& fiatConv json data = GetKrakenWithdrawInfoFile(_coincenterInfo.dataDir()).readAllJson(); if (!data.empty()) { Duration withdrawDataRefreshTime = exchangeInfo().getAPICallUpdateFrequency(kWithdrawalFees); - TimePoint lastUpdatedTime(std::chrono::seconds(data["timeepoch"].get())); + TimePoint lastUpdatedTime(TimeInS(data["timeepoch"].get())); if (Clock::now() < lastUpdatedTime + withdrawDataRefreshTime) { // we can reuse file data KrakenPublic::WithdrawalFeesFunc::WithdrawalInfoMaps withdrawalInfoMaps; @@ -517,7 +540,7 @@ LastTradesVector KrakenPublic::queryLastTrades(Market mk, int nbLastTrades) { int64_t millisecondsSinceEpoch = static_cast(det[2].get() * 1000); TradeSide tradeSide = det[3].get() == "b" ? TradeSide::kBuy : TradeSide::kSell; - ret.emplace_back(tradeSide, amount, price, TimePoint(std::chrono::milliseconds(millisecondsSinceEpoch))); + ret.emplace_back(tradeSide, amount, price, TimePoint(TimeInMs(millisecondsSinceEpoch))); } std::ranges::sort(ret); return ret; diff --git a/src/api/exchanges/src/kucoinprivateapi.cpp b/src/api/exchanges/src/kucoinprivateapi.cpp index 4989c25e..a151a60c 100644 --- a/src/api/exchanges/src/kucoinprivateapi.cpp +++ b/src/api/exchanges/src/kucoinprivateapi.cpp @@ -22,6 +22,7 @@ #include "commonapi.hpp" #include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "currencycode.hpp" #include "deposit.hpp" #include "depositsconstraints.hpp" diff --git a/src/api/exchanges/src/kucoinpublicapi.cpp b/src/api/exchanges/src/kucoinpublicapi.cpp index cf2ab23b..a39a1e51 100644 --- a/src/api/exchanges/src/kucoinpublicapi.cpp +++ b/src/api/exchanges/src/kucoinpublicapi.cpp @@ -2,18 +2,40 @@ #include #include -#include -#include - +#include +#include +#include +#include +#include + +#include "apiquerytypeenum.hpp" +#include "cachedresult.hpp" #include "cct_exception.hpp" +#include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "cct_vector.hpp" #include "coincenterinfo.hpp" #include "commonapi.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencycodeset.hpp" +#include "currencyexchange.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" +#include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" #include "monetaryamount.hpp" +#include "permanentcurloptions.hpp" #include "stringhelpers.hpp" -#include "toupperlower.hpp" +#include "timedef.hpp" +#include "tradeside.hpp" +#include "volumeandpricenbdecimals.hpp" namespace cct::api { namespace { @@ -324,7 +346,7 @@ LastTradesVector KucoinPublic::queryLastTrades(Market mk, [[maybe_unused]] int n int64_t millisecondsSinceEpoch = static_cast(detail["time"].get() / 1000000UL); TradeSide tradeSide = detail["side"].get() == "buy" ? TradeSide::kBuy : TradeSide::kSell; - ret.emplace_back(tradeSide, amount, price, TimePoint(std::chrono::milliseconds(millisecondsSinceEpoch))); + ret.emplace_back(tradeSide, amount, price, TimePoint(TimeInMs(millisecondsSinceEpoch))); } std::ranges::sort(ret); return ret; diff --git a/src/api/exchanges/src/upbitprivateapi.cpp b/src/api/exchanges/src/upbitprivateapi.cpp index ab5bd1ef..8a975c94 100644 --- a/src/api/exchanges/src/upbitprivateapi.cpp +++ b/src/api/exchanges/src/upbitprivateapi.cpp @@ -25,6 +25,7 @@ #include "commonapi.hpp" #include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "currencycode.hpp" #include "currencycodeset.hpp" #include "currencyexchange.hpp" @@ -54,6 +55,7 @@ #include "withdraw.hpp" #include "withdrawinfo.hpp" #include "withdrawordeposit.hpp" +#include "withdrawsconstraints.hpp" namespace cct::api { diff --git a/src/api/exchanges/src/upbitpublicapi.cpp b/src/api/exchanges/src/upbitpublicapi.cpp index d9cc05d0..3b34bf3d 100644 --- a/src/api/exchanges/src/upbitpublicapi.cpp +++ b/src/api/exchanges/src/upbitpublicapi.cpp @@ -1,16 +1,37 @@ #include "upbitpublicapi.hpp" #include -#include +#include +#include +#include +#include +#include +#include "apiquerytypeenum.hpp" +#include "cachedresult.hpp" #include "cct_exception.hpp" #include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_smallvector.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" +#include "curlhandle.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" +#include "currencycode.hpp" +#include "currencycodeset.hpp" +#include "currencyexchangeflatset.hpp" +#include "exchangepublicapi.hpp" +#include "exchangepublicapitypes.hpp" #include "fiatconverter.hpp" #include "file.hpp" -#include "stringhelpers.hpp" +#include "httprequesttype.hpp" +#include "market.hpp" +#include "marketorderbook.hpp" +#include "monetaryamount.hpp" +#include "permanentcurloptions.hpp" +#include "timedef.hpp" +#include "tradeside.hpp" namespace cct::api { namespace { @@ -232,7 +253,7 @@ LastTradesVector UpbitPublic::queryLastTrades(Market mk, int nbTrades) { int64_t millisecondsSinceEpoch = detail["timestamp"].get(); TradeSide tradeSide = detail["ask_bid"].get() == "BID" ? TradeSide::kBuy : TradeSide::kSell; - ret.emplace_back(tradeSide, amount, price, TimePoint(std::chrono::milliseconds(millisecondsSinceEpoch))); + ret.emplace_back(tradeSide, amount, price, TimePoint(TimeInMs(millisecondsSinceEpoch))); } std::ranges::sort(ret); return ret; diff --git a/src/api/exchanges/test/bithumb_place_order_test.cpp b/src/api/exchanges/test/bithumb_place_order_test.cpp index 96c84742..97382f21 100644 --- a/src/api/exchanges/test/bithumb_place_order_test.cpp +++ b/src/api/exchanges/test/bithumb_place_order_test.cpp @@ -1,10 +1,24 @@ #include +#include + +#include "apikey.hpp" #include "apikeysprovider.hpp" #include "bithumbprivateapi.hpp" #include "bithumbpublicapi.hpp" +#include "cct_const.hpp" +#include "cct_string.hpp" #include "coincenterinfo.hpp" +#include "exchangename.hpp" #include "fiatconverter.hpp" +#include "loadconfiguration.hpp" +#include "market.hpp" +#include "monetaryamount.hpp" +#include "runmodes.hpp" +#include "timedef.hpp" +#include "tradeinfo.hpp" +#include "tradeoptions.hpp" +#include "tradeside.hpp" namespace cct::api { class BithumbPrivateAPIPlaceOrderTest : public ::testing::Test { diff --git a/src/api/interface/src/exchange.cpp b/src/api/interface/src/exchange.cpp index 6a670027..1c7a031d 100644 --- a/src/api/interface/src/exchange.cpp +++ b/src/api/interface/src/exchange.cpp @@ -2,6 +2,7 @@ #include +#include "cct_log.hpp" #include "currencycode.hpp" #include "currencyexchangeflatset.hpp" #include "exchangeinfo.hpp" diff --git a/src/api/interface/test/exchangeretrieverbase_test.cpp b/src/api/interface/test/exchangeretrieverbase_test.cpp index a680ac6b..ed784518 100644 --- a/src/api/interface/test/exchangeretrieverbase_test.cpp +++ b/src/api/interface/test/exchangeretrieverbase_test.cpp @@ -2,6 +2,13 @@ #include +#include +#include + +#include "cct_exception.hpp" +#include "cct_string.hpp" +#include "exchangename.hpp" + namespace cct { class ExchangeTest { diff --git a/src/engine/test/queryresultprinter_base_test.hpp b/src/engine/test/queryresultprinter_base_test.hpp index b29d3780..22ae0122 100644 --- a/src/engine/test/queryresultprinter_base_test.hpp +++ b/src/engine/test/queryresultprinter_base_test.hpp @@ -1,3 +1,5 @@ +#pragma once + #include #include @@ -6,7 +8,6 @@ #include #include "apioutputtype.hpp" -#include "cct_config.hpp" #include "cct_json.hpp" #include "exchangedata_test.hpp" #include "queryresultprinter.hpp" diff --git a/src/http-request/include/curloptions.hpp b/src/http-request/include/curloptions.hpp index 93ccae99..3c4942e0 100644 --- a/src/http-request/include/curloptions.hpp +++ b/src/http-request/include/curloptions.hpp @@ -1,15 +1,17 @@ #pragma once +#include +#include #include -#include +#include +#include "cct_type_traits.hpp" +#include "curlpostdata.hpp" #include "flatkeyvaluestring.hpp" #include "httprequesttype.hpp" namespace cct { -using CurlPostData = FlatKeyValueString<'&', '='>; - class CurlOptions { public: // Trick: may get a null-terminated const char * for each kv pair. diff --git a/src/http-request/include/curlpostdata.hpp b/src/http-request/include/curlpostdata.hpp new file mode 100644 index 00000000..b3f847f1 --- /dev/null +++ b/src/http-request/include/curlpostdata.hpp @@ -0,0 +1,7 @@ +#pragma once + +#include "flatkeyvaluestring.hpp" + +namespace cct { +using CurlPostData = FlatKeyValueString<'&', '='>; +} \ No newline at end of file diff --git a/src/http-request/src/curlhandle.cpp b/src/http-request/src/curlhandle.cpp index a2bd4b06..23fcba87 100644 --- a/src/http-request/src/curlhandle.cpp +++ b/src/http-request/src/curlhandle.cpp @@ -22,6 +22,7 @@ #include "cct_string.hpp" #include "curlmetrics.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "flatkeyvaluestring.hpp" #include "httprequesttype.hpp" #include "metric.hpp" diff --git a/src/http-request/test/curlhandle_test.cpp b/src/http-request/test/curlhandle_test.cpp index be5662e9..eedc6974 100644 --- a/src/http-request/test/curlhandle_test.cpp +++ b/src/http-request/test/curlhandle_test.cpp @@ -6,6 +6,7 @@ #include "cct_exception.hpp" #include "curloptions.hpp" +#include "curlpostdata.hpp" #include "httprequesttype.hpp" #include "permanentcurloptions.hpp" #include "proxy.hpp" diff --git a/src/main/src/main.cpp b/src/main/src/main.cpp index 742b9c79..96f2520d 100644 --- a/src/main/src/main.cpp +++ b/src/main/src/main.cpp @@ -20,10 +20,10 @@ int main(int argc, const char* argv[]) { cct::settings::RunMode::kProd); } } catch (const cct::invalid_argument& e) { - std::cerr << "Invalid argument: " << e.what() << std::endl; + std::cerr << "Invalid argument: " << e.what() << '\n'; return EXIT_FAILURE; } catch (const std::exception& e) { - std::cerr << e.what() << std::endl; + std::cerr << e.what() << '\n'; return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/src/objects/include/wallet.hpp b/src/objects/include/wallet.hpp index 8c85c0d3..8ab1145c 100644 --- a/src/objects/include/wallet.hpp +++ b/src/objects/include/wallet.hpp @@ -1,6 +1,8 @@ #pragma once +#include #include +#include #include "accountowner.hpp" #include "cct_config.hpp" @@ -56,7 +58,7 @@ class Wallet { bool hasTag() const { return _tagPos != std::string_view::npos; } - bool operator==(const Wallet &) const = default; + bool operator==(const Wallet &) const noexcept = default; static bool ValidateWallet(WalletCheck walletCheck, const ExchangeName &exchangeName, CurrencyCode currency, std::string_view expectedAddress, std::string_view expectedTag); diff --git a/src/objects/src/exchangeinfomap.cpp b/src/objects/src/exchangeinfomap.cpp index 6c3d2fe7..b81c10b0 100644 --- a/src/objects/src/exchangeinfomap.cpp +++ b/src/objects/src/exchangeinfomap.cpp @@ -1,13 +1,19 @@ #include "exchangeinfomap.hpp" #include +#include +#include #include "cct_const.hpp" +#include "cct_json.hpp" #include "cct_log.hpp" -#include "durationstring.hpp" +#include "cct_string.hpp" +#include "exchangeinfo.hpp" #include "exchangeinfodefault.hpp" #include "exchangeinfoparser.hpp" +#include "monetaryamountbycurrencyset.hpp" #include "parseloglevel.hpp" +#include "timedef.hpp" namespace cct { @@ -53,9 +59,9 @@ ExchangeInfoMap ComputeExchangeInfoMap(std::string_view fileName, const json &js queryTopLevelOption.getMonetaryAmountsArray(exchangeName, "dustAmountsThreshold")); const int dustSweeperMaxNbTrades = queryTopLevelOption.getInt(exchangeName, "dustSweeperMaxNbTrades"); - const log::level::level_enum requestsCallLogLevel = + const auto requestsCallLogLevel = LevelFromPos(LogPosFromLogStr(queryTopLevelOption.getStr(exchangeName, "logLevels", "requestsCall"))); - const log::level::level_enum requestsAnswerLogLevel = + const auto requestsAnswerLogLevel = LevelFromPos(LogPosFromLogStr(queryTopLevelOption.getStr(exchangeName, "logLevels", "requestsAnswer"))); map.insert_or_assign( diff --git a/src/objects/src/exchangeinfoparser.cpp b/src/objects/src/exchangeinfoparser.cpp index 7b87887b..19fa5eba 100644 --- a/src/objects/src/exchangeinfoparser.cpp +++ b/src/objects/src/exchangeinfoparser.cpp @@ -1,7 +1,14 @@ #include "exchangeinfoparser.hpp" +#include +#include +#include + #include "cct_exception.hpp" +#include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "currencycodevector.hpp" #include "exchangeinfodefault.hpp" #include "file.hpp" #include "loadconfiguration.hpp" diff --git a/src/objects/src/exchangename.cpp b/src/objects/src/exchangename.cpp index df17a265..b9d95b1a 100644 --- a/src/objects/src/exchangename.cpp +++ b/src/objects/src/exchangename.cpp @@ -3,7 +3,6 @@ #include #include -#include "cct_exception.hpp" #include "cct_invalid_argument_exception.hpp" #include "cct_string.hpp" #include "toupperlower.hpp" diff --git a/src/objects/src/generalconfig.cpp b/src/objects/src/generalconfig.cpp index 171b09e0..c08c3270 100644 --- a/src/objects/src/generalconfig.cpp +++ b/src/objects/src/generalconfig.cpp @@ -1,7 +1,16 @@ #include "generalconfig.hpp" +#include +#include + +#include "apioutputtype.hpp" +#include "cct_json.hpp" +#include "cct_log.hpp" #include "file.hpp" #include "generalconfigdefault.hpp" +#include "logginginfo.hpp" +#include "requestsconfig.hpp" +#include "timedef.hpp" namespace cct { diff --git a/src/objects/src/logginginfo.cpp b/src/objects/src/logginginfo.cpp index 877e13f7..366ef716 100644 --- a/src/objects/src/logginginfo.cpp +++ b/src/objects/src/logginginfo.cpp @@ -4,12 +4,19 @@ #include #include +#include +#include #include +#include #include -#include "cct_const.hpp" #include "cct_fixedcapacityvector.hpp" +#include "cct_json.hpp" +#include "cct_log.hpp" +#include "cct_string.hpp" +#include "file.hpp" #include "parseloglevel.hpp" +#include "timedef.hpp" #include "timestring.hpp" #include "unitsparser.hpp" diff --git a/src/objects/src/monetaryamount.cpp b/src/objects/src/monetaryamount.cpp index 95e36289..88810381 100644 --- a/src/objects/src/monetaryamount.cpp +++ b/src/objects/src/monetaryamount.cpp @@ -370,7 +370,7 @@ MonetaryAmount MonetaryAmount::operator*(AmountType mult) const { log::trace("Reaching numeric limits of MonetaryAmount for {} * {}, truncate {} digits", _amount, mult, nbDigitsToTruncate); amount /= ipow10(static_cast(nbDigitsToTruncate)); - if (static_cast(nbDecs) >= nbDigitsToTruncate) { + if (static_cast>(nbDecs) >= nbDigitsToTruncate) { nbDecs -= static_cast(nbDigitsToTruncate); } else { log::warn("Cannot truncate decimal part, I need to truncate integral part"); diff --git a/src/objects/src/wallet.cpp b/src/objects/src/wallet.cpp index 7741fbbb..93e2436f 100644 --- a/src/objects/src/wallet.cpp +++ b/src/objects/src/wallet.cpp @@ -1,8 +1,18 @@ #include "wallet.hpp" +#include +#include +#include +#include + +#include "accountowner.hpp" #include "cct_const.hpp" #include "cct_exception.hpp" +#include "cct_json.hpp" #include "cct_log.hpp" +#include "cct_string.hpp" +#include "currencycode.hpp" +#include "exchangename.hpp" #include "file.hpp" namespace cct { diff --git a/src/objects/test/coincenterinfo_test.cpp b/src/objects/test/coincenterinfo_test.cpp index 38ae3a6f..9945e063 100644 --- a/src/objects/test/coincenterinfo_test.cpp +++ b/src/objects/test/coincenterinfo_test.cpp @@ -1,7 +1,16 @@ #include "coincenterinfo.hpp" +#include +#include + +#include "cct_const.hpp" +#include "cct_string.hpp" +#include "currencycode.hpp" +#include "generalconfig.hpp" +#include "loadconfiguration.hpp" +#include "monitoringinfo.hpp" #include "reader_mock.hpp" -#include "writer_mock.hpp" +#include "runmodes.hpp" namespace cct { namespace { diff --git a/src/objects/test/exchangeinfo_test.cpp b/src/objects/test/exchangeinfo_test.cpp index a09e471a..bb2aaf25 100644 --- a/src/objects/test/exchangeinfo_test.cpp +++ b/src/objects/test/exchangeinfo_test.cpp @@ -2,11 +2,14 @@ #include +#include + #include "cct_const.hpp" -#include "durationstring.hpp" +#include "currencycodeset.hpp" #include "exchangeinfomap.hpp" #include "exchangeinfoparser.hpp" #include "loadconfiguration.hpp" +#include "monetaryamount.hpp" namespace cct { class ExchangeInfoTest : public ::testing::Test { diff --git a/src/objects/test/logginginfo_test.cpp b/src/objects/test/logginginfo_test.cpp index 60142a19..982d17b5 100644 --- a/src/objects/test/logginginfo_test.cpp +++ b/src/objects/test/logginginfo_test.cpp @@ -2,6 +2,10 @@ #include +#include + +#include "cct_const.hpp" +#include "cct_log.hpp" #include "generalconfigdefault.hpp" namespace cct { diff --git a/src/objects/test/marketorderbook_test.cpp b/src/objects/test/marketorderbook_test.cpp index b0eecb6f..b42387ac 100644 --- a/src/objects/test/marketorderbook_test.cpp +++ b/src/objects/test/marketorderbook_test.cpp @@ -2,7 +2,13 @@ #include +#include +#include +#include + #include "cct_exception.hpp" +#include "market.hpp" +#include "monetaryamount.hpp" namespace cct { namespace { diff --git a/src/objects/test/monetaryamount_test.cpp b/src/objects/test/monetaryamount_test.cpp index a27f1528..a6d60fd3 100644 --- a/src/objects/test/monetaryamount_test.cpp +++ b/src/objects/test/monetaryamount_test.cpp @@ -2,10 +2,13 @@ #include +#include #include #include "cct_exception.hpp" +#include "cct_string.hpp" #include "currencycode.hpp" +#include "mathhelpers.hpp" namespace cct { diff --git a/src/tech/include/cachedresult.hpp b/src/tech/include/cachedresult.hpp index ee17a9b1..782242cf 100644 --- a/src/tech/include/cachedresult.hpp +++ b/src/tech/include/cachedresult.hpp @@ -35,10 +35,10 @@ template class CachedResultT : public CachedResultBase { public: using ResultType = std::remove_cvref_t()(std::declval()...))>; - using TimePoint = typename ClockT::time_point; - using Duration = typename ClockT::duration; + using TimePoint = ClockT::time_point; + using Duration = ClockT::duration; using ResPtrTimePair = std::pair; - using State = typename CachedResultBase::State; + using State = CachedResultBase::State; private: using TKey = std::tuple...>; diff --git a/src/tech/include/cachedresultvault.hpp b/src/tech/include/cachedresultvault.hpp index 3c42ece8..8b4252c9 100644 --- a/src/tech/include/cachedresultvault.hpp +++ b/src/tech/include/cachedresultvault.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "cct_vector.hpp" #include "timedef.hpp" diff --git a/src/tech/include/cct_cctype.hpp b/src/tech/include/cct_cctype.hpp index bd186045..dad8295e 100644 --- a/src/tech/include/cct_cctype.hpp +++ b/src/tech/include/cct_cctype.hpp @@ -4,21 +4,21 @@ namespace cct { /// Safe std::isalnum version. See https://en.cppreference.com/w/cpp/string/byte/isalnum -inline bool isalnum(char c) { return std::isalnum(static_cast(c)); } +inline bool isalnum(char ch) { return std::isalnum(static_cast(ch)) != 0; } /// Safe std::isalpha version. See https://en.cppreference.com/w/cpp/string/byte/isalpha -inline bool isalpha(char c) { return std::isalpha(static_cast(c)); } +inline bool isalpha(char ch) { return std::isalpha(static_cast(ch)) != 0; } /// Safe std::isblank version. See https://en.cppreference.com/w/cpp/string/byte/isblank -inline bool isblank(char c) { return std::isblank(static_cast(c)); } +inline bool isblank(char ch) { return std::isblank(static_cast(ch)) != 0; } /// Safe std::isdigit version. See https://en.cppreference.com/w/cpp/string/byte/isdigit -inline bool isdigit(char c) { return std::isdigit(static_cast(c)); } +inline bool isdigit(char ch) { return std::isdigit(static_cast(ch)) != 0; } /// Safe std::islower version. See https://en.cppreference.com/w/cpp/string/byte/islower -inline bool islower(char c) { return std::islower(static_cast(c)); } +inline bool islower(char ch) { return std::islower(static_cast(ch)) != 0; } /// Safe std::isspace version. See https://en.cppreference.com/w/cpp/string/byte/isspace -inline bool isspace(char c) { return std::isspace(static_cast(c)); } +inline bool isspace(char ch) { return std::isspace(static_cast(ch)) != 0; } } // namespace cct \ No newline at end of file diff --git a/src/tech/include/cct_exception.hpp b/src/tech/include/cct_exception.hpp index 244bb494..d0f3bf34 100644 --- a/src/tech/include/cct_exception.hpp +++ b/src/tech/include/cct_exception.hpp @@ -4,11 +4,14 @@ #include #include #include +#include +#include #include #include "cct_format.hpp" #include "cct_string.hpp" #include "cct_type_traits.hpp" +#include "unreachable.hpp" namespace cct { diff --git a/src/tech/include/cct_hash.hpp b/src/tech/include/cct_hash.hpp index d6c93f1c..dc6c44ae 100644 --- a/src/tech/include/cct_hash.hpp +++ b/src/tech/include/cct_hash.hpp @@ -1,7 +1,6 @@ - - #pragma once +#include #include #include #include @@ -19,12 +18,12 @@ constexpr uint64_t HashValue64(uint64_t h1) { return h1; } -constexpr size_t HashCombine(size_t h1, size_t h2) { +constexpr std::size_t HashCombine(std::size_t h1, std::size_t h2) { // Taken from boost::hash_combine - static_assert(sizeof(size_t) == 4 || sizeof(size_t) == 8, "HashCombine not defined for this size_t"); - if constexpr (sizeof(size_t) == 4) { + static_assert(sizeof(std::size_t) == 4 || sizeof(std::size_t) == 8, "HashCombine not defined for this std::size_t"); + if constexpr (sizeof(std::size_t) == 4) { h1 ^= h2 + 0x9e3779b9 + (h1 << 6) + (h1 >> 2); - } else if constexpr (sizeof(size_t) == 8) { + } else { // see https://github.com/HowardHinnant/hash_append/issues/7 h1 ^= h2 + 0x9e3779b97f4a7c15ULL + (h1 << 12) + (h1 >> 4); } @@ -34,8 +33,8 @@ constexpr size_t HashCombine(size_t h1, size_t h2) { class HashTuple { public: template - size_t operator()(const Tuple& tuple) const { - return std::hash()(std::apply([](const auto&... xs) { return (Component{xs}, ..., 0); }, tuple)); + std::size_t operator()(const Tuple& tuple) const { + return std::hash()(std::apply([](const auto&... xs) { return (Component{xs}, ..., 0); }, tuple)); } private: @@ -43,7 +42,7 @@ class HashTuple { struct Component { const T& value; - size_t operator,(size_t n) const { return HashCombine(std::hash()(value), n); } + std::size_t operator,(std::size_t n) const { return HashCombine(std::hash()(value), n); } }; }; diff --git a/src/tech/include/cct_invalid_argument_exception.hpp b/src/tech/include/cct_invalid_argument_exception.hpp index 722d2a9e..735cc82c 100644 --- a/src/tech/include/cct_invalid_argument_exception.hpp +++ b/src/tech/include/cct_invalid_argument_exception.hpp @@ -1,7 +1,11 @@ #pragma once +#include + +#include "cct_config.hpp" #include "cct_exception.hpp" #include "cct_format.hpp" +#include "cct_string.hpp" namespace cct { class invalid_argument : public exception { diff --git a/src/tech/include/cct_json.hpp b/src/tech/include/cct_json.hpp index c906be53..143418a2 100644 --- a/src/tech/include/cct_json.hpp +++ b/src/tech/include/cct_json.hpp @@ -1,4 +1,3 @@ - #pragma once #include diff --git a/src/tech/include/flatkeyvaluestring.hpp b/src/tech/include/flatkeyvaluestring.hpp index c1ea68c4..21ad0e79 100644 --- a/src/tech/include/flatkeyvaluestring.hpp +++ b/src/tech/include/flatkeyvaluestring.hpp @@ -4,8 +4,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -17,6 +19,7 @@ #include "cct_cctype.hpp" #include "cct_json.hpp" #include "cct_string.hpp" +#include "cct_type_traits.hpp" #include "cct_vector.hpp" #include "unreachable.hpp" @@ -67,8 +70,8 @@ class FlatKeyValueStringIterator { const value_type &operator*() const { return _kv; } const value_type *operator->() const { return &this->operator*(); } - bool operator==(const FlatKeyValueStringIterator &o) const { return _kv[0].data() == o._kv[0].data(); } - bool operator!=(const FlatKeyValueStringIterator &o) const { return !(*this == o); } + bool operator==(const FlatKeyValueStringIterator &rhs) const noexcept { return _kv[0].data() == rhs._kv[0].data(); } + bool operator!=(const FlatKeyValueStringIterator &rhs) const noexcept { return !(*this == rhs); } private: template @@ -87,7 +90,7 @@ class FlatKeyValueStringIterator { /// Create a new FlatKeyValueStringIterator representing end() /// bool as second parameter is only here to differentiate both constructors - FlatKeyValueStringIterator(std::string_view data, bool) : _data(data) {} + FlatKeyValueStringIterator(std::string_view data, [[maybe_unused]] bool dummy) : _data(data) {} std::string_view _data; value_type _kv; @@ -326,7 +329,7 @@ void FlatKeyValueString::erase(std::string_view while (last < ps && _data[last] != KeyValuePairSep) { ++last; } - _data.erase(_data.begin() + first, _data.begin() + last + (first == 0)); + _data.erase(_data.begin() + first, _data.begin() + last + static_cast(first == 0)); } } @@ -363,7 +366,7 @@ std::string_view FlatKeyValueString::Get(std::s last = data.begin() + endPos; } } - return std::string_view(first, last); + return {first, last}; } template diff --git a/src/tech/include/mathhelpers.hpp b/src/tech/include/mathhelpers.hpp index aee6cc06..98314768 100644 --- a/src/tech/include/mathhelpers.hpp +++ b/src/tech/include/mathhelpers.hpp @@ -6,8 +6,6 @@ #include #include -#include "cct_config.hpp" - namespace cct { /// constexpr and integral version of math.power. /// Taken from https://gist.github.com/orlp/3551590 diff --git a/src/tech/include/simpletable.hpp b/src/tech/include/simpletable.hpp index d2307772..5bdf1a40 100644 --- a/src/tech/include/simpletable.hpp +++ b/src/tech/include/simpletable.hpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/tech/include/static_string_view_helpers.hpp b/src/tech/include/static_string_view_helpers.hpp index c3f22079..3e440681 100644 --- a/src/tech/include/static_string_view_helpers.hpp +++ b/src/tech/include/static_string_view_helpers.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include "mathhelpers.hpp" diff --git a/src/tech/include/timedef.hpp b/src/tech/include/timedef.hpp index f6c679b5..cc7ad693 100644 --- a/src/tech/include/timedef.hpp +++ b/src/tech/include/timedef.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace cct { /// Alias some types to make it easier to use diff --git a/src/tech/include/timestring.hpp b/src/tech/include/timestring.hpp index 4e4f357e..9d37f144 100644 --- a/src/tech/include/timestring.hpp +++ b/src/tech/include/timestring.hpp @@ -1,6 +1,5 @@ #pragma once -#include #include #include "cct_string.hpp" diff --git a/src/tech/src/gethostname.cpp b/src/tech/src/gethostname.cpp index 87ad3606..3bcdddbe 100644 --- a/src/tech/src/gethostname.cpp +++ b/src/tech/src/gethostname.cpp @@ -7,8 +7,9 @@ #include #include #else -#include #include + +#include #endif namespace cct { @@ -25,10 +26,12 @@ HostNameGetter::HostNameGetter() { HostNameGetter::~HostNameGetter() { WSACleanup(); } #endif +// This method cannot be made static as it needs the RAII WSAStartup / WSACleanup wrapper in Windows. +// NOLINTNEXTLINE(readability-convert-member-functions-to-static) string HostNameGetter::getHostName() const { string hostname(16U, '\0'); - static constexpr std::size_t kMaxHostNameSize = 1024; - std::size_t nullTerminatedCharPos = 0; + static constexpr string::size_type kMaxHostNameSize = 1024; + string::size_type nullTerminatedCharPos = 0; do { auto errorCode = ::gethostname(hostname.data(), hostname.size() - 1U); if (errorCode != 0) { diff --git a/src/tech/src/parseloglevel.cpp b/src/tech/src/parseloglevel.cpp index 03cbec63..ed82bc80 100644 --- a/src/tech/src/parseloglevel.cpp +++ b/src/tech/src/parseloglevel.cpp @@ -1,5 +1,8 @@ #include "parseloglevel.hpp" +#include +#include + #include "cct_exception.hpp" namespace cct { diff --git a/src/tech/test/gethostname_test.cpp b/src/tech/test/gethostname_test.cpp index d3f30f28..b2de8281 100644 --- a/src/tech/test/gethostname_test.cpp +++ b/src/tech/test/gethostname_test.cpp @@ -2,6 +2,8 @@ #include +#include "cct_string.hpp" + namespace cct { TEST(GetHostNameTest, Default) { HostNameGetter hostNameGetter;