Skip to content

Commit

Permalink
Only print replay results at the full end of the replay command
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Jul 24, 2024
1 parent e863148 commit 3dc681e
Show file tree
Hide file tree
Showing 20 changed files with 1,021 additions and 557 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
clang-version: [19]
clang-version: [18]
buildmode: [Debug]

steps:
Expand Down
1 change: 0 additions & 1 deletion src/api/exchanges/src/bithumbpublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

#include "apiquerytypeenum.hpp"
#include "cachedresult.hpp"
#include "cct_exception.hpp"
#include "cct_json.hpp"
#include "cct_log.hpp"
#include "cct_string.hpp"
Expand Down
1 change: 0 additions & 1 deletion src/api/exchanges/src/kucoinprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <algorithm>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <string_view>
#include <type_traits>
Expand Down
1 change: 0 additions & 1 deletion src/api/exchanges/src/upbitpublicapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "apiquerytypeenum.hpp"
#include "cachedresult.hpp"
#include "cct_exception.hpp"
#include "cct_json.hpp"
#include "cct_log.hpp"
#include "cct_string.hpp"
Expand Down
30 changes: 30 additions & 0 deletions src/engine/include/coincenter-commands-processor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once

#include <span>

#include "coincentercommand.hpp"
#include "queryresultprinter.hpp"
#include "transferablecommandresult.hpp"

namespace cct {

class Coincenter;
class CoincenterInfo;
class CoincenterCommands;

class CoincenterCommandsProcessor {
public:
explicit CoincenterCommandsProcessor(Coincenter &coincenter);

/// Launch given commands and return the number of processed commands.
int process(const CoincenterCommands &coincenterCommands);

private:
TransferableCommandResultVector processGroupedCommands(
std::span<const CoincenterCommand> groupedCommands,
std::span<const TransferableCommandResult> previousTransferableResults);

Coincenter &_coincenter;
QueryResultPrinter _queryResultPrinter;
};
} // namespace cct
21 changes: 7 additions & 14 deletions src/engine/include/coincenter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "market.hpp"
#include "metricsexporter.hpp"
#include "ordersconstraints.hpp"
#include "queryresultprinter.hpp"
#include "queryresulttypes.hpp"
#include "replay-options.hpp"
#include "transferablecommandresult.hpp"
Expand All @@ -36,9 +35,6 @@ class Coincenter {

Coincenter(const CoincenterInfo &coincenterInfo, const ExchangeSecretsInfo &exchangeSecretsInfo);

/// Launch given commands and return the number of processed commands.
int process(const CoincenterCommands &coincenterCommands);

ExchangeHealthCheckStatus healthCheck(ExchangeNameSpan exchangeNames);

/// Retrieve all tradable currencies for given selected public exchanges, or all if empty.
Expand Down Expand Up @@ -150,8 +146,8 @@ class Coincenter {

/// Replay all markets for exchanges selection that has some data during the last
/// 'replayDuration' time (so within the time frame [now - replayDuration, now])
void replay(const AbstractMarketTraderFactory &marketTraderFactory, const ReplayOptions &replayOptions, Market market,
ExchangeNameSpan exchangeNames);
ReplayResults replay(const AbstractMarketTraderFactory &marketTraderFactory, const ReplayOptions &replayOptions,
Market market, ExchangeNameSpan exchangeNames);

/// Dumps the content of all file caches in data directory to save cURL queries.
void updateFileCaches() const;
Expand All @@ -168,15 +164,13 @@ class Coincenter {
const FiatConverter &fiatConverter() const { return _fiatConverter; }

private:
TransferableCommandResultVector processGroupedCommands(
std::span<const CoincenterCommand> groupedCommands,
std::span<const TransferableCommandResult> previousTransferableResults);

using MarketTraderEngineVector = FixedCapacityVector<MarketTraderEngine, kNbSupportedExchanges>;

void replayAlgorithm(const AbstractMarketTraderFactory &marketTraderFactory, std::string_view algorithmName,
const ReplayOptions &replayOptions, std::span<MarketTraderEngine> marketTraderEngines,
const PublicExchangeNameVector &exchangesWithThisMarketData);
MarketTradingGlobalResultPerExchange replayAlgorithm(const AbstractMarketTraderFactory &marketTraderFactory,
std::string_view algorithmName,
const ReplayOptions &replayOptions,
std::span<MarketTraderEngine> marketTraderEngines,
const PublicExchangeNameVector &exchangesWithThisMarketData);

// TODO: may be moved somewhere else?
MarketTraderEngineVector createMarketTraderEngines(const ReplayOptions &replayOptions, Market market,
Expand All @@ -195,6 +189,5 @@ class Coincenter {

ExchangePool _exchangePool;
ExchangesOrchestrator _exchangesOrchestrator;
QueryResultPrinter _queryResultPrinter;
};
} // namespace cct
3 changes: 1 addition & 2 deletions src/engine/include/queryresultprinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ class QueryResultPrinter {
void printMarketsForReplay(TimeWindow timeWindow,
const MarketTimestampSetsPerExchange &marketTimestampSetsPerExchange);

void printMarketTradingResults(TimeWindow timeWindow,
const MarketTradingGlobalResultPerExchange &marketTradingResultPerExchange,
void printMarketTradingResults(TimeWindow inputTimeWindow, const ReplayResults &replayResults,
CoincenterCommandType commandType) const;

private:
Expand Down
4 changes: 4 additions & 0 deletions src/engine/include/queryresulttypes.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <array>
#include <map>
#include <optional>
#include <string_view>
#include <tuple>
Expand All @@ -10,6 +11,7 @@
#include "cct_const.hpp"
#include "cct_fixedcapacityvector.hpp"
#include "cct_smallvector.hpp"
#include "cct_vector.hpp"
#include "currencyexchangeflatset.hpp"
#include "exchangeprivateapitypes.hpp"
#include "exchangepublicapitypes.hpp"
Expand Down Expand Up @@ -87,4 +89,6 @@ using MarketTradingResultPerExchange = FixedCapacityVector<ExchangeWith<MarketTr
using MarketTradingGlobalResultPerExchange =
FixedCapacityVector<ExchangeWith<MarketTradingGlobalResult>, kNbSupportedExchanges>;

using ReplayResults = std::map<std::string_view, vector<MarketTradingGlobalResultPerExchange>>;

} // namespace cct
Loading

0 comments on commit 3dc681e

Please sign in to comment.