diff --git a/src/api-objects/include/order.hpp b/src/api-objects/include/order.hpp index d7c77af0..6dc689d2 100644 --- a/src/api-objects/include/order.hpp +++ b/src/api-objects/include/order.hpp @@ -44,7 +44,7 @@ class Order { Market market() const { return Market(_matchedVolume.currencyCode(), _price.currencyCode()); } /// default ordering by place time first, then matched volume, etc - auto operator<=>(const Order &) const = default; + std::strong_ordering operator<=>(const Order &) const noexcept = default; using trivially_relocatable = is_trivially_relocatable::type; diff --git a/src/api-objects/include/publictrade.hpp b/src/api-objects/include/publictrade.hpp index 7eda35cf..d5bf2943 100644 --- a/src/api-objects/include/publictrade.hpp +++ b/src/api-objects/include/publictrade.hpp @@ -30,7 +30,7 @@ class PublicTrade { /// 3 way operator - make compiler generate all 6 operators (including == and !=) /// we order by time first, then amount, price, etc. Do not change the fields order! - std::strong_ordering operator<=>(const PublicTrade &) const = default; + std::strong_ordering operator<=>(const PublicTrade&) const noexcept = default; private: TimePoint _time; diff --git a/src/api-objects/src/publictrade.cpp b/src/api-objects/src/publictrade.cpp index 5ba601fa..423275d0 100644 --- a/src/api-objects/src/publictrade.cpp +++ b/src/api-objects/src/publictrade.cpp @@ -4,5 +4,7 @@ #include "timestring.hpp" namespace cct { + string PublicTrade::timeStr() const { return ToString(_time); } + } // namespace cct \ No newline at end of file diff --git a/src/api/exchanges/src/binancepublicapi.cpp b/src/api/exchanges/src/binancepublicapi.cpp index 3d8468d7..3dd08486 100644 --- a/src/api/exchanges/src/binancepublicapi.cpp +++ b/src/api/exchanges/src/binancepublicapi.cpp @@ -495,12 +495,12 @@ MarketOrderBook BinancePublic::OrderBookFunc::operator()(Market mk, int depth) { if (asksIt != asksAndBids.end() && bidsIt != asksAndBids.end()) { orderBookLines.reserve(static_cast(asksIt->size() + bidsIt->size())); for (const auto& asksOrBids : {asksIt, bidsIt}) { - const bool isAsk = asksOrBids == asksIt; + const auto type = asksOrBids == asksIt ? OrderBookLine::Type::kAsk : OrderBookLine::Type::kBid; for (const auto& priceQuantityPair : *asksOrBids) { MonetaryAmount amount(priceQuantityPair.back().get(), mk.base()); MonetaryAmount price(priceQuantityPair.front().get(), mk.quote()); - orderBookLines.emplace_back(amount, price, isAsk); + orderBookLines.emplace_back(amount, price, type); } } } diff --git a/src/api/exchanges/src/bithumbpublicapi.cpp b/src/api/exchanges/src/bithumbpublicapi.cpp index 707bd1d3..c354becc 100644 --- a/src/api/exchanges/src/bithumbpublicapi.cpp +++ b/src/api/exchanges/src/bithumbpublicapi.cpp @@ -235,12 +235,12 @@ MarketOrderBookMap GetOrderbooks(CurlHandle& curlHandle, const CoincenterInfo& c OrderBookVec orderBookLines; orderBookLines.reserve(static_cast(asksBids[0]->size() + asksBids[1]->size())); for (const json* asksOrBids : asksBids) { - const bool isAsk = asksOrBids == asksBids[0]; + const auto type = asksOrBids == asksBids[0] ? OrderBookLine::Type::kAsk : OrderBookLine::Type::kBid; for (const json& priceQuantityPair : *asksOrBids) { MonetaryAmount amount(priceQuantityPair["quantity"].get(), baseCurrencyCode); MonetaryAmount price(priceQuantityPair["price"].get(), quoteCurrencyCode); - orderBookLines.emplace_back(amount, price, isAsk); + orderBookLines.emplace_back(amount, price, type); } } Market market(baseCurrencyCode, quoteCurrencyCode); diff --git a/src/api/exchanges/src/huobipublicapi.cpp b/src/api/exchanges/src/huobipublicapi.cpp index 0662acee..ccd55ab7 100644 --- a/src/api/exchanges/src/huobipublicapi.cpp +++ b/src/api/exchanges/src/huobipublicapi.cpp @@ -389,15 +389,16 @@ MarketOrderBook HuobiPublic::OrderBookFunc::operator()(Market mk, int depth) { orderBookLines.reserve(bidsIt->size() + asksIt->size()); for (const auto& asksOrBids : {bidsIt, asksIt}) { int currentDepth = 0; - bool isBid = asksOrBids == bidsIt; + const auto type = asksOrBids == asksIt ? OrderBookLine::Type::kAsk : OrderBookLine::Type::kBid; for (const auto& priceQuantityPair : *asksOrBids) { MonetaryAmount amount(priceQuantityPair.back().get(), mk.base()); MonetaryAmount price(priceQuantityPair.front().get(), mk.quote()); - orderBookLines.emplace_back(amount, price, !isBid); + orderBookLines.emplace_back(amount, price, type); if (++currentDepth == depth) { if (depth < static_cast(asksOrBids->size())) { - log::debug("Truncate number of {} prices in order book to {}", isBid ? "bid" : "ask", depth); + log::debug("Truncate number of {} prices in order book to {}", + type == OrderBookLine::Type::kAsk ? "ask" : "bid", depth); } break; } diff --git a/src/api/exchanges/src/krakenpublicapi.cpp b/src/api/exchanges/src/krakenpublicapi.cpp index ca836073..2a0fc9f6 100644 --- a/src/api/exchanges/src/krakenpublicapi.cpp +++ b/src/api/exchanges/src/krakenpublicapi.cpp @@ -309,7 +309,7 @@ MarketOrderBook KrakenPublic::OrderBookFunc::operator()(Market mk, int count) { orderBookLines.reserve(static_cast(asksIt->size() + bidsIt->size())); for (const auto& asksOrBids : {asksIt, bidsIt}) { - const bool isAsk = asksOrBids == asksIt; + const auto type = asksOrBids == asksIt ? OrderBookLine::Type::kAsk : OrderBookLine::Type::kBid; for (const auto& priceQuantityTuple : *asksOrBids) { std::string_view priceStr = priceQuantityTuple[0].get(); std::string_view amountStr = priceQuantityTuple[1].get(); @@ -317,7 +317,7 @@ MarketOrderBook KrakenPublic::OrderBookFunc::operator()(Market mk, int count) { MonetaryAmount amount(amountStr, mk.base()); MonetaryAmount price(priceStr, mk.quote()); - orderBookLines.emplace_back(amount, price, isAsk); + orderBookLines.emplace_back(amount, price, type); } } } diff --git a/src/api/exchanges/src/kucoinpublicapi.cpp b/src/api/exchanges/src/kucoinpublicapi.cpp index d6e371e3..ae7ba651 100644 --- a/src/api/exchanges/src/kucoinpublicapi.cpp +++ b/src/api/exchanges/src/kucoinpublicapi.cpp @@ -261,16 +261,18 @@ MarketOrderBookMap KucoinPublic::AllOrderBooksFunc::operator()(int depth) { namespace { template -void FillOrderBook(Market mk, int depth, bool isAsk, InputIt beg, InputIt end, vector& orderBookLines) { +void FillOrderBook(Market mk, int depth, OrderBookLine::Type type, InputIt beg, InputIt end, + vector& orderBookLines) { int currentDepth = 0; for (auto it = beg; it != end; ++it) { MonetaryAmount price((*it)[0].template get(), mk.quote()); MonetaryAmount amount((*it)[1].template get(), mk.base()); - orderBookLines.emplace_back(amount, price, isAsk); + orderBookLines.emplace_back(amount, price, type); if (++currentDepth == depth) { if (++it != end) { - log::debug("Truncate number of {} prices in order book to {}", isAsk ? "ask" : "bid", depth); + log::debug("Truncate number of {} prices in order book to {}", + type == OrderBookLine::Type::kAsk ? "ask" : "bid", depth); } break; } @@ -299,8 +301,8 @@ MarketOrderBook KucoinPublic::OrderBookFunc::operator()(Market mk, int depth) { if (asksIt != asksAndBids.end() && bidsIt != asksAndBids.end()) { orderBookLines.reserve(asksIt->size() + bidsIt->size()); // Reverse iterate as bids are received in descending order - FillOrderBook(mk, depth, false, bidsIt->rbegin(), bidsIt->rend(), orderBookLines); - FillOrderBook(mk, depth, true, asksIt->begin(), asksIt->end(), orderBookLines); + FillOrderBook(mk, depth, OrderBookLine::Type::kBid, bidsIt->rbegin(), bidsIt->rend(), orderBookLines); + FillOrderBook(mk, depth, OrderBookLine::Type::kAsk, asksIt->begin(), asksIt->end(), orderBookLines); } return MarketOrderBook(Clock::now(), mk, orderBookLines); diff --git a/src/api/exchanges/src/upbitpublicapi.cpp b/src/api/exchanges/src/upbitpublicapi.cpp index 752f3f57..98b0ca56 100644 --- a/src/api/exchanges/src/upbitpublicapi.cpp +++ b/src/api/exchanges/src/upbitpublicapi.cpp @@ -201,8 +201,8 @@ MarketOrderBookMap ParseOrderBooks(const json& result, int depth) { MonetaryAmount askVol(orderbookDetails["ask_size"].get(), base); MonetaryAmount bidVol(orderbookDetails["bid_size"].get(), base); - orderBookLines.emplace_back(askVol, askPri, true /* isAsk */); - orderBookLines.emplace_back(bidVol, bidPri, false /* isAsk */); + orderBookLines.emplace_back(askVol, askPri, OrderBookLine::Type::kAsk); + orderBookLines.emplace_back(bidVol, bidPri, OrderBookLine::Type::kBid); if (static_cast(orderBookLines.size() / 2) == depth) { // Upbit does not have a depth parameter, the only thing we can do is to truncate it manually diff --git a/src/monitoring/include/prometheusmetricgateway.hpp b/src/monitoring/include/prometheusmetricgateway.hpp index 6be53b15..6615b86f 100644 --- a/src/monitoring/include/prometheusmetricgateway.hpp +++ b/src/monitoring/include/prometheusmetricgateway.hpp @@ -5,9 +5,7 @@ #include #include -#include #include -#include #include "abstractmetricgateway.hpp" #include "timedef.hpp" diff --git a/src/monitoring/include/voidmetricgateway.hpp b/src/monitoring/include/voidmetricgateway.hpp index a0341a23..e4386ca9 100644 --- a/src/monitoring/include/voidmetricgateway.hpp +++ b/src/monitoring/include/voidmetricgateway.hpp @@ -1,8 +1,8 @@ #pragma once -#include - #include "abstractmetricgateway.hpp" +#include "metric.hpp" +#include "monitoringinfo.hpp" namespace cct { class VoidMetricGateway : public AbstractMetricGateway { diff --git a/src/objects/include/coincentercommandtype.hpp b/src/objects/include/coincentercommandtype.hpp index d7aeb6af..5078ba1a 100644 --- a/src/objects/include/coincentercommandtype.hpp +++ b/src/objects/include/coincentercommandtype.hpp @@ -27,6 +27,8 @@ enum class CoincenterCommandType : int8_t { kSell, kWithdrawApply, kDustSweeper, + + kLast }; std::string_view CoincenterCommandTypeToString(CoincenterCommandType type); diff --git a/src/objects/include/generalconfig.hpp b/src/objects/include/generalconfig.hpp index a6b1f800..0fd87678 100644 --- a/src/objects/include/generalconfig.hpp +++ b/src/objects/include/generalconfig.hpp @@ -16,7 +16,7 @@ class GeneralConfig { static json LoadFile(std::string_view dataDir); - GeneralConfig() : _loggingInfo(LoggingInfo::WithLoggersCreation::kYes) {} + GeneralConfig() = default; GeneralConfig(LoggingInfo &&loggingInfo, RequestsConfig &&requestsConfig, Duration fiatConversionQueryRate, ApiOutputType apiOutputType); @@ -30,7 +30,7 @@ class GeneralConfig { Duration fiatConversionQueryRate() const { return _fiatConversionQueryRate; } private: - LoggingInfo _loggingInfo; + LoggingInfo _loggingInfo{LoggingInfo::WithLoggersCreation::kYes}; RequestsConfig _requestsConfig; Duration _fiatConversionQueryRate = std::chrono::hours(8); ApiOutputType _apiOutputType = ApiOutputType::kFormattedTable; diff --git a/src/objects/include/market.hpp b/src/objects/include/market.hpp index 576018ed..f4d3c007 100644 --- a/src/objects/include/market.hpp +++ b/src/objects/include/market.hpp @@ -101,4 +101,4 @@ struct hash { return cct::HashCombine(hash()(mk.base()), hash()(mk.quote())); } }; -} // namespace std \ No newline at end of file +} // namespace std diff --git a/src/objects/include/marketorderbook.hpp b/src/objects/include/marketorderbook.hpp index 3effc2ab..b25d7d21 100644 --- a/src/objects/include/marketorderbook.hpp +++ b/src/objects/include/marketorderbook.hpp @@ -1,8 +1,10 @@ #pragma once +#include #include #include #include +#include #include "cct_smallvector.hpp" #include "market.hpp" @@ -18,10 +20,11 @@ class PriceOptions; /// Represents an entry in an order book, an amount at a given price. class OrderBookLine { public: + enum class Type : int8_t { kAsk, kBid }; + /// Constructs a new OrderBookLine. - /// @param isAsk true if it represents a 'ask' price, false if it is a 'bid' price. - OrderBookLine(MonetaryAmount amount, MonetaryAmount price, bool isAsk) - : _amount(isAsk ? -amount : amount), _price(price) {} + OrderBookLine(MonetaryAmount amount, MonetaryAmount price, Type type) + : _amount(type == Type::kAsk ? -amount : amount), _price(price) {} private: friend class MarketOrderBook; @@ -142,6 +145,8 @@ class MarketOrderBook { std::optional computeAvgPrice(MonetaryAmount from, const PriceOptions& priceOptions) const; + VolAndPriNbDecimals volAndPriNbDecimals() const noexcept { return _volAndPriNbDecimals; } + /// Print the market order book in a SimpleTable and returns it. /// @param conversionPriceRate prices will be multiplied to given amount to display an additional column of equivalent /// currency @@ -153,7 +158,7 @@ class MarketOrderBook { struct AmountPrice { using AmountType = MonetaryAmount::AmountType; - bool operator==(const AmountPrice& o) const noexcept = default; + bool operator==(const AmountPrice&) const noexcept = default; AmountType amount = 0; AmountType price = 0; @@ -165,7 +170,7 @@ class MarketOrderBook { public: using trivially_relocatable = is_trivially_relocatable::type; - bool operator==(const MarketOrderBook&) const = default; + bool operator==(const MarketOrderBook&) const noexcept = default; private: /// Represents a total amount of waiting orders at a given price. diff --git a/src/objects/src/coincentercommandtype.cpp b/src/objects/src/coincentercommandtype.cpp index 1d2aea8e..e074ddd6 100644 --- a/src/objects/src/coincentercommandtype.cpp +++ b/src/objects/src/coincentercommandtype.cpp @@ -1,126 +1,54 @@ #include "coincentercommandtype.hpp" +#include #include +#include #include "cct_exception.hpp" namespace cct { -std::string_view CoincenterCommandTypeToString(CoincenterCommandType type) { - switch (type) { - case CoincenterCommandType::kHealthCheck: - return "HealthCheck"; - case CoincenterCommandType::kCurrencies: - return "Currencies"; - case CoincenterCommandType::kMarkets: - return "Markets"; - case CoincenterCommandType::kConversionPath: - return "ConversionPath"; - case CoincenterCommandType::kLastPrice: - return "LastPrice"; - case CoincenterCommandType::kTicker: - return "Ticker"; - case CoincenterCommandType::kOrderbook: - return "Orderbook"; - case CoincenterCommandType::kLastTrades: - return "LastTrades"; - case CoincenterCommandType::kLast24hTradedVolume: - return "Last24hTradedVolume"; - case CoincenterCommandType::kWithdrawFees: - return "WithdrawFees"; +namespace { +constexpr std::string_view kCommandTypeNames[] = { + "HealthCheck", + "Currencies", + "Markets", + "ConversionPath", + "LastPrice", + "Ticker", + "Orderbook", + "LastTrades", + "Last24hTradedVolume", + "WithdrawFees", - case CoincenterCommandType::kBalance: - return "Balance"; - case CoincenterCommandType::kDepositInfo: - return "DepositInfo"; - case CoincenterCommandType::kOrdersOpened: - return "OrdersOpened"; - case CoincenterCommandType::kOrdersCancel: - return "OrdersCancel"; - case CoincenterCommandType::kRecentDeposits: - return "RecentDeposits"; - case CoincenterCommandType::kRecentWithdraws: - return "RecentWithdraws"; - case CoincenterCommandType::kTrade: - return "Trade"; - case CoincenterCommandType::kBuy: - return "Buy"; - case CoincenterCommandType::kSell: - return "Sell"; - case CoincenterCommandType::kWithdrawApply: - return "Withdraw"; - case CoincenterCommandType::kDustSweeper: - return "DustSweeper"; - default: - throw exception("Unknown command type"); - } + "Balance", + "DepositInfo", + "OrdersOpened", + "OrdersCancel", + "RecentDeposits", + "RecentWithdraws", + "Trade", + "Buy", + "Sell", + "Withdraw", + "DustSweeper", +}; } -CoincenterCommandType CoincenterCommandTypeFromString(std::string_view str) { - if (str == "HealthCheck") { - return CoincenterCommandType::kHealthCheck; - } - if (str == "Currencies") { - return CoincenterCommandType::kCurrencies; - } - if (str == "Markets") { - return CoincenterCommandType::kMarkets; - } - if (str == "ConversionPath") { - return CoincenterCommandType::kConversionPath; - } - if (str == "LastPrice") { - return CoincenterCommandType::kLastPrice; - } - if (str == "Ticker") { - return CoincenterCommandType::kTicker; - } - if (str == "Orderbook") { - return CoincenterCommandType::kOrderbook; - } - if (str == "LastTrades") { - return CoincenterCommandType::kLastTrades; - } - if (str == "Last24hTradedVolume") { - return CoincenterCommandType::kLast24hTradedVolume; - } - if (str == "WithdrawFees") { - return CoincenterCommandType::kWithdrawFees; +std::string_view CoincenterCommandTypeToString(CoincenterCommandType type) { + const auto intValue = static_cast>(type); + if (intValue < decltype(intValue){} || + intValue >= static_cast>(CoincenterCommandType::kLast)) { + throw exception("Unknown command type {}", intValue); } + return kCommandTypeNames[intValue]; +} - if (str == "Balance") { - return CoincenterCommandType::kBalance; - } - if (str == "DepositInfo") { - return CoincenterCommandType::kDepositInfo; - } - if (str == "OrdersOpened") { - return CoincenterCommandType::kOrdersOpened; - } - if (str == "OrdersCancel") { - return CoincenterCommandType::kOrdersCancel; - } - if (str == "RecentDeposits") { - return CoincenterCommandType::kRecentDeposits; - } - if (str == "RecentWithdraws") { - return CoincenterCommandType::kRecentWithdraws; - } - if (str == "Trade") { - return CoincenterCommandType::kTrade; - } - if (str == "Buy") { - return CoincenterCommandType::kBuy; - } - if (str == "Sell") { - return CoincenterCommandType::kSell; - } - if (str == "Withdraw") { - return CoincenterCommandType::kWithdrawApply; - } - if (str == "DustSweeper") { - return CoincenterCommandType::kDustSweeper; +CoincenterCommandType CoincenterCommandTypeFromString(std::string_view str) { + const auto cmdIt = std::ranges::find(kCommandTypeNames, str); + if (cmdIt == std::end(kCommandTypeNames)) { + throw exception("Unknown command type {}", str); } - throw exception("Unknown command type {}", str); + return static_cast(cmdIt - std::begin(kCommandTypeNames)); } bool IsAnyTrade(CoincenterCommandType type) { diff --git a/src/objects/src/coincenterinfo.cpp b/src/objects/src/coincenterinfo.cpp index 053c4ad9..b02d16a0 100644 --- a/src/objects/src/coincenterinfo.cpp +++ b/src/objects/src/coincenterinfo.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -21,6 +20,7 @@ #include "runmodes.hpp" #include "toupperlower-string.hpp" #include "toupperlower.hpp" + #ifdef CCT_ENABLE_PROMETHEUS #include "prometheusmetricgateway.hpp" #else diff --git a/src/objects/src/marketorderbook.cpp b/src/objects/src/marketorderbook.cpp index f8ac4d21..5ba5609a 100644 --- a/src/objects/src/marketorderbook.cpp +++ b/src/objects/src/marketorderbook.cpp @@ -94,6 +94,7 @@ MarketOrderBook::MarketOrderBook(TimePoint timeStamp, MonetaryAmount askPrice, M if (bidVolume <= 0) { throw exception("Invalid bid volume {}{}", bidVolume, kErrNegVolumeMsg); } + static constexpr MonetaryAmount::RoundType roundType = MonetaryAmount::RoundType::kNearest; askPrice.round(_volAndPriNbDecimals.priNbDecimals, roundType); diff --git a/src/objects/src/monetaryamount.cpp b/src/objects/src/monetaryamount.cpp index 5dc95f03..0563ebf5 100644 --- a/src/objects/src/monetaryamount.cpp +++ b/src/objects/src/monetaryamount.cpp @@ -193,7 +193,6 @@ MonetaryAmount::MonetaryAmount(double amount, CurrencyCode currencyCode, RoundTy } std::optional MonetaryAmount::amount(int8_t nbDecimals) const { - assert(nbDecimals >= 0); AmountType integralAmount = _amount; const int8_t ourNbDecimals = this->nbDecimals(); for (; nbDecimals < ourNbDecimals; ++nbDecimals) { diff --git a/src/objects/test/balanceportfolio_test.cpp b/src/objects/test/balanceportfolio_test.cpp index 2848b2a7..df3ae051 100644 --- a/src/objects/test/balanceportfolio_test.cpp +++ b/src/objects/test/balanceportfolio_test.cpp @@ -4,6 +4,7 @@ #include #include "monetaryamount.hpp" + namespace cct { class BalancePortfolioTest1 : public ::testing::Test { diff --git a/src/objects/test/market_test.cpp b/src/objects/test/market_test.cpp index 432d083a..c9fdd98e 100644 --- a/src/objects/test/market_test.cpp +++ b/src/objects/test/market_test.cpp @@ -51,4 +51,4 @@ TEST(MarketTest, StringRepresentationFiatConversionMarket) { EXPECT_EQ(market.assetsPairStrUpper('('), "*USDT(EUR"); EXPECT_EQ(market.assetsPairStrLower(')'), "*usdt)eur"); } -} // namespace cct \ No newline at end of file +} // namespace cct diff --git a/src/objects/test/marketorderbook_test.cpp b/src/objects/test/marketorderbook_test.cpp index 196aab6b..6f092adf 100644 --- a/src/objects/test/marketorderbook_test.cpp +++ b/src/objects/test/marketorderbook_test.cpp @@ -28,12 +28,13 @@ class MarketOrderBookTestCase1 : public ::testing::Test { MarketOrderBook marketOrderBook{ Clock::now(), Market("ETH", "EUR"), std::array{ - OrderBookLine(MonetaryAmount("0.65", "ETH"), MonetaryAmount("1300.50", "EUR"), false), - OrderBookLine(MonetaryAmount("0.24", "ETH"), MonetaryAmount("1301", "EUR"), false), - OrderBookLine(MonetaryAmount(0, "ETH"), MonetaryAmount("1301.50", "EUR"), false), - OrderBookLine(MonetaryAmount("1.4009", "ETH"), MonetaryAmount("1302", "EUR"), true), - OrderBookLine(MonetaryAmount("3.78", "ETH"), MonetaryAmount("1302.50", "EUR"), true), - OrderBookLine(MonetaryAmount("56.10001267", "ETH"), MonetaryAmount("1303", "EUR"), true)}}; + OrderBookLine(MonetaryAmount("0.65", "ETH"), MonetaryAmount("1300.50", "EUR"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("0.24", "ETH"), MonetaryAmount("1301", "EUR"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount(0, "ETH"), MonetaryAmount("1301.50", "EUR"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("1.4009", "ETH"), MonetaryAmount("1302", "EUR"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("3.78", "ETH"), MonetaryAmount("1302.50", "EUR"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("56.10001267", "ETH"), MonetaryAmount("1303", "EUR"), + OrderBookLine::Type::kAsk)}}; }; TEST_F(MarketOrderBookTestCase1, NumberOfElements) { @@ -132,15 +133,17 @@ class MarketOrderBookTestCase2 : public ::testing::Test { MarketOrderBook marketOrderBook{ time, Market("APM", "KRW"), std::array{ - OrderBookLine(MonetaryAmount("1991.3922", "APM"), MonetaryAmount("57.8", "KRW"), true), - OrderBookLine(MonetaryAmount("90184.3951", "APM"), MonetaryAmount("57.81", "KRW"), true), - OrderBookLine(MonetaryAmount("91.1713", "APM"), MonetaryAmount("57.84", "KRW"), true), - OrderBookLine(MonetaryAmount("41.0131", "APM"), MonetaryAmount("57.9", "KRW"), true), - OrderBookLine(MonetaryAmount("33.5081914157147802", "APM"), MonetaryAmount("57.78", "KRW"), true), - OrderBookLine(MonetaryAmount("3890.879", "APM"), MonetaryAmount("57.19", "KRW"), false), - OrderBookLine(MonetaryAmount("14", "APM"), MonetaryAmount("57.18", "KRW"), false), - OrderBookLine(MonetaryAmount("14", "APM"), MonetaryAmount("57.17", "KRW"), false), - OrderBookLine(MonetaryAmount("3848.8453", "APM"), MonetaryAmount("57.16", "KRW"), false)}}; + OrderBookLine(MonetaryAmount("1991.3922", "APM"), MonetaryAmount("57.8", "KRW"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("90184.3951", "APM"), MonetaryAmount("57.81", "KRW"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("91.1713", "APM"), MonetaryAmount("57.84", "KRW"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("41.0131", "APM"), MonetaryAmount("57.9", "KRW"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("33.5081914157147802", "APM"), MonetaryAmount("57.78", "KRW"), + OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("3890.879", "APM"), MonetaryAmount("57.19", "KRW"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("14", "APM"), MonetaryAmount("57.18", "KRW"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("14", "APM"), MonetaryAmount("57.17", "KRW"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("3848.8453", "APM"), MonetaryAmount("57.16", "KRW"), + OrderBookLine::Type::kBid)}}; }; TEST_F(MarketOrderBookTestCase2, SimpleQueries) { @@ -160,13 +163,18 @@ class MarketOrderBookTestCase3 : public ::testing::Test { TimePoint time{}; MarketOrderBook marketOrderBook{ time, Market("XLM", "BTC"), - std::array{ - OrderBookLine(MonetaryAmount("126881.164", "XLM"), MonetaryAmount("0.000007130", "BTC"), true), - OrderBookLine(MonetaryAmount("95716.519", "XLM"), MonetaryAmount("0.000007120", "BTC"), true), - OrderBookLine(MonetaryAmount("23726.285", "XLM"), MonetaryAmount("0.000007110", "BTC"), true), - OrderBookLine(MonetaryAmount("37863.710", "XLM"), MonetaryAmount("0.000007100", "BTC"), false), - OrderBookLine(MonetaryAmount("169165.594", "XLM"), MonetaryAmount("0.000007090", "BTC"), false), - OrderBookLine(MonetaryAmount("204218.966", "XLM"), MonetaryAmount("0.000007080", "BTC"), false)}}; + std::array{OrderBookLine(MonetaryAmount("126881.164", "XLM"), + MonetaryAmount("0.000007130", "BTC"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("95716.519", "XLM"), + MonetaryAmount("0.000007120", "BTC"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("23726.285", "XLM"), + MonetaryAmount("0.000007110", "BTC"), OrderBookLine::Type::kAsk), + OrderBookLine(MonetaryAmount("37863.710", "XLM"), + MonetaryAmount("0.000007100", "BTC"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("169165.594", "XLM"), + MonetaryAmount("0.000007090", "BTC"), OrderBookLine::Type::kBid), + OrderBookLine(MonetaryAmount("204218.966", "XLM"), + MonetaryAmount("0.000007080", "BTC"), OrderBookLine::Type::kBid)}}; }; TEST_F(MarketOrderBookTestCase3, Convert) {