Skip to content

Commit

Permalink
Code clean-up SimpleTable
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Mar 20, 2024
1 parent 137ff8d commit eb47eb2
Show file tree
Hide file tree
Showing 7 changed files with 303 additions and 335 deletions.
4 changes: 2 additions & 2 deletions src/engine/include/queryresultprinter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
#include "market.hpp"
#include "ordersconstraints.hpp"
#include "queryresulttypes.hpp"
#include "simpletable.hpp"
#include "withdrawsconstraints.hpp"

namespace cct {

class DeliveredWithdrawInfo;
class LoggingInfo;
class SimpleTable;
class TradeOptions;
class WithdrawOptions;

Expand Down Expand Up @@ -103,7 +103,7 @@ class QueryResultPrinter {
void printTrades(const TradeResultPerExchange &tradeResultPerExchange, MonetaryAmount amount, bool isPercentageTrade,
CurrencyCode toCurrency, const TradeOptions &tradeOptions, CoincenterCommandType commandType) const;

void printTable(const SimpleTable &simpleTable) const;
void printTable(const SimpleTable &table) const;

void printJson(const json &jsonData) const;

Expand Down
8 changes: 4 additions & 4 deletions src/engine/src/balanceperexchangeportfolio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ SimpleTable BalancePerExchangePortfolio::getTable(bool wide) const {
BalancePortfolio total = computeTotal();
CurrencyCode balanceCurrencyCode = total.empty() ? CurrencyCode() : total.front().equi.currencyCode();
const bool countEqui = !balanceCurrencyCode.isNeutral();
SimpleTable::Row header("Currency", "Total amount on selected");
table::Row header("Currency", "Total amount on selected");

if (countEqui) {
total.sortByDecreasingEquivalentAmount();
Expand All @@ -51,7 +51,7 @@ SimpleTable BalancePerExchangePortfolio::getTable(bool wide) const {
const int nbExchanges = _balancePerExchange.size();
for (const auto &[amount, equi] : total) {
// Amounts impossible to convert have a zero value
SimpleTable::Row row(amount.currencyStr(), amount.amountStr());
table::Row row(amount.currencyStr(), amount.amountStr());
if (countEqui) {
row.emplace_back(equi.amountStr());
}
Expand All @@ -63,8 +63,8 @@ SimpleTable BalancePerExchangePortfolio::getTable(bool wide) const {
balanceTable.push_back(std::move(row));
}
if (countEqui) {
balanceTable.push_back(SimpleTable::Row::kDivider);
SimpleTable::Row row("Total", "", ComputeTotalSum(total).amountStr());
balanceTable.emplace_back();
table::Row row("Total", "", ComputeTotalSum(total).amountStr());
if (wide) {
for (int exchangePos = 0; exchangePos < nbExchanges; ++exchangePos) {
row.emplace_back("");
Expand Down
222 changes: 128 additions & 94 deletions src/engine/src/queryresultprinter.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/objects/src/marketorderbook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ SimpleTable MarketOrderBook::getTable(std::string_view exchangeName,
const int pos = op - 1;
MonetaryAmount amount(std::abs(_orders[pos].amount), CurrencyCode(), _volAndPriNbDecimals.volNbDecimals);
MonetaryAmount price = priceAt(pos);
SimpleTable::Row row(amount.str());
table::Row row(amount.str());
row.emplace_back(price.amountStr());
if (conversionPriceRate) {
MonetaryAmount convertedPrice = price.toNeutral() * conversionPriceRate->toNeutral();
Expand Down
Loading

0 comments on commit eb47eb2

Please sign in to comment.