Improve "empty" handling of BotProfit

This commit is contained in:
Matthias 2023-09-06 20:29:55 +02:00
parent 5f2aa82314
commit f1e22cd644

View File

@ -4,7 +4,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { formatPercent, formatPriceCurrency, timestampms } from '@/shared/formatters'; import {
formatPercent,
formatPriceCurrency,
timestampms,
timestampmsOrNa,
} from '@/shared/formatters';
import { ProfitInterface } from '@/types'; import { ProfitInterface } from '@/types';
import { TableField, TableItem } from 'bootstrap-vue-next'; import { TableField, TableItem } from 'bootstrap-vue-next';
@ -26,42 +31,46 @@ const profitItems = computed<TableItem[]>(() => {
return [ return [
{ {
metric: 'ROI open trades', metric: 'ROI open trades',
value: `${formatPriceCurrency( value: props.profit.profit_closed_coin
props.profit.profit_closed_coin, ? `${formatPriceCurrency(
props.stakeCurrency, props.profit.profit_closed_coin,
props.stakeCurrencyDecimals, props.stakeCurrency,
)} (${formatPercent(props.profit.profit_closed_ratio_mean, 2)})`, props.stakeCurrencyDecimals,
)} (${formatPercent(props.profit.profit_closed_ratio_mean, 2)})`
: 'N/A',
// (&sum; ${formatPercent(props.profit.profit_closed_ratio_sum, 2,)})` // (&sum; ${formatPercent(props.profit.profit_closed_ratio_sum, 2,)})`
}, },
{ {
metric: 'ROI all trades', metric: 'ROI all trades',
value: `${formatPriceCurrency( value: props.profit.profit_all_coin
props.profit.profit_all_coin, ? `${formatPriceCurrency(
props.stakeCurrency, props.profit.profit_all_coin,
props.stakeCurrencyDecimals, props.stakeCurrency,
)} (${formatPercent(props.profit.profit_all_ratio_mean, 2)})`, props.stakeCurrencyDecimals,
)} (${formatPercent(props.profit.profit_all_ratio_mean, 2)})`
: 'N/A',
// (&sum; ${formatPercent(props.profit.profit_all_ratio_sum,2,)})` // (&sum; ${formatPercent(props.profit.profit_all_ratio_sum,2,)})`
}, },
{ {
metric: 'Total Trade count', metric: 'Total Trade count',
value: `${props.profit.trade_count}`, value: `${props.profit.trade_count ?? 0}`,
}, },
{ {
metric: 'Bot started', metric: 'Bot started',
value: timestampms(props.profit.bot_start_timestamp ?? 0), value: timestampmsOrNa(props.profit.bot_start_timestamp ?? 0),
}, },
{ {
metric: 'First Trade opened', metric: 'First Trade opened',
value: timestampms(props.profit.first_trade_timestamp), value: timestampmsOrNa(props.profit.first_trade_timestamp),
}, },
{ {
metric: 'Latest Trade opened', metric: 'Latest Trade opened',
value: timestampms(props.profit.latest_trade_timestamp), value: timestampmsOrNa(props.profit.latest_trade_timestamp),
}, },
{ {
metric: 'Win / Loss', metric: 'Win / Loss',
value: `${props.profit.winning_trades} / ${props.profit.losing_trades}`, value: `${props.profit.winning_trades ?? 0} / ${props.profit.losing_trades ?? 0}`,
}, },
{ {
metric: 'Winrate', metric: 'Winrate',
@ -75,11 +84,13 @@ const profitItems = computed<TableItem[]>(() => {
}, },
{ {
metric: 'Avg. Duration', metric: 'Avg. Duration',
value: `${props.profit.avg_duration}`, value: `${props.profit.avg_duration ?? 'N/A'}`,
}, },
{ {
metric: 'Best performing', metric: 'Best performing',
value: `${props.profit.best_pair}: ${formatPercent(props.profit.best_pair_profit_ratio, 2)}`, value: props.profit.best_pair
? `${props.profit.best_pair}: ${formatPercent(props.profit.best_pair_profit_ratio, 2)}`
: 'N/A',
}, },
{ {
metric: 'Trading volume', metric: 'Trading volume',