Reduce verbosity of ResultAnalysis further

This commit is contained in:
Matthias 2023-10-24 19:32:40 +02:00
parent 1f7ce48e70
commit 61ba6a836e

View File

@ -121,52 +121,43 @@ const backtestResultStats = computed(() => {
const shortMetrics = const shortMetrics =
props.backtestResult?.trade_count_short && props.backtestResult?.trade_count_short > 0 props.backtestResult?.trade_count_short && props.backtestResult?.trade_count_short > 0
? [ ? [
{ metric: '___', value: '___' }, { '___ ': '___' },
{ {
metric: 'Long / Short', 'Long / Short': `${props.backtestResult.trade_count_long} / ${props.backtestResult.trade_count_short}`,
value: `${props.backtestResult.trade_count_long} / ${props.backtestResult.trade_count_short}`,
}, },
{ {
metric: 'Total profit Long', 'Total profit Long': `${formatPercent(
value: `${formatPercent(
props.backtestResult.profit_total_long || 0, props.backtestResult.profit_total_long || 0,
)} | ${formatPriceStake(props.backtestResult.profit_total_long_abs)}`, )} | ${formatPriceStake(props.backtestResult.profit_total_long_abs)}`,
}, },
{ {
metric: 'Total profit Short', 'Total profit Short': `${formatPercent(
value: `${formatPercent(
props.backtestResult.profit_total_short || 0, props.backtestResult.profit_total_short || 0,
)} | ${formatPriceStake(props.backtestResult.profit_total_short_abs)}`, )} | ${formatPriceStake(props.backtestResult.profit_total_short_abs)}`,
}, },
] ]
: []; : [];
return [ const tmp = [
{ {
metric: 'Total Profit', 'Total Profit': `${formatPercent(props.backtestResult.profit_total)} | ${formatPriceStake(
value: `${formatPercent(props.backtestResult.profit_total)} | ${formatPriceStake(
props.backtestResult.profit_total_abs, props.backtestResult.profit_total_abs,
)}`, )}`,
}, },
{ {
metric: 'CAGR', CAGR: `${props.backtestResult.cagr ? formatPercent(props.backtestResult.cagr) : 'N/A'}`,
value: `${props.backtestResult.cagr ? formatPercent(props.backtestResult.cagr) : 'N/A'}`,
}, },
{ {
metric: 'Sortino', Sortino: `${props.backtestResult.sortino ? props.backtestResult.sortino.toFixed(2) : 'N/A'}`,
value: `${props.backtestResult.sortino ? props.backtestResult.sortino.toFixed(2) : 'N/A'}`,
}, },
{ {
metric: 'Sharpe', Sharpe: `${props.backtestResult.sharpe ? props.backtestResult.sharpe.toFixed(2) : 'N/A'}`,
value: `${props.backtestResult.sharpe ? props.backtestResult.sharpe.toFixed(2) : 'N/A'}`,
}, },
{ {
metric: 'Calmar', Calmar: `${props.backtestResult.calmar ? props.backtestResult.calmar.toFixed(2) : 'N/A'}`,
value: `${props.backtestResult.calmar ? props.backtestResult.calmar.toFixed(2) : 'N/A'}`,
}, },
{ {
metric: `Expectancy ${props.backtestResult.expectancy_ratio ? '(ratio)' : ''}`, [`Expectancy ${props.backtestResult.expectancy_ratio ? '(ratio)' : ''}`]: `${
value: `${
props.backtestResult.expectancy props.backtestResult.expectancy
? props.backtestResult.expectancy_ratio ? props.backtestResult.expectancy_ratio
? props.backtestResult.expectancy.toFixed(2) + ? props.backtestResult.expectancy.toFixed(2) +
@ -178,35 +169,31 @@ const backtestResultStats = computed(() => {
}`, }`,
}, },
{ {
metric: 'Profit factor', 'Profit factor': `${
value: `${
props.backtestResult.profit_factor props.backtestResult.profit_factor
? formatPrice(props.backtestResult.profit_factor, 3) ? formatPrice(props.backtestResult.profit_factor, 3)
: 'N/A' : 'N/A'
}`, }`,
}, },
{ {
metric: 'Total trades / Daily Avg Trades', 'Total trades / Daily Avg Trades': `${props.backtestResult.total_trades} / ${props.backtestResult.trades_per_day}`,
value: `${props.backtestResult.total_trades} / ${props.backtestResult.trades_per_day}`,
}, },
// { metric: 'First trade', value: props.backtestResult.backtest_fi }, // { 'First trade': props.backtestResult.backtest_fi },
// { metric: 'First trade Pair', value: props.backtestResult.backtest_best_day }, // { 'First trade Pair': props.backtestResult.backtest_best_day },
{ {
metric: 'Best day', 'Best day': `${formatPercent(props.backtestResult.backtest_best_day, 2)} | ${formatPriceStake(
value: `${formatPercent(props.backtestResult.backtest_best_day, 2)} | ${formatPriceStake(
props.backtestResult.backtest_best_day_abs, props.backtestResult.backtest_best_day_abs,
)}`, )}`,
}, },
{ {
metric: 'Worst day', 'Worst day': `${formatPercent(
value: `${formatPercent(props.backtestResult.backtest_worst_day, 2)} | ${formatPriceStake( props.backtestResult.backtest_worst_day,
props.backtestResult.backtest_worst_day_abs, 2,
)}`, )} | ${formatPriceStake(props.backtestResult.backtest_worst_day_abs)}`,
}, },
{ {
metric: 'Win/Draw/Loss', 'Win/Draw/Loss': `${pairSummary.value.wins} / ${pairSummary.value.draws} / ${
value: `${pairSummary.value.wins} / ${pairSummary.value.draws} / ${
pairSummary.value.losses pairSummary.value.losses
} ${ } ${
isNotUndefined(pairSummary.value.winrate) isNotUndefined(pairSummary.value.winrate)
@ -222,83 +209,72 @@ const backtestResultStats = computed(() => {
}`, }`,
}, },
{ {
metric: 'Days win/draw/loss', 'Days win/draw/loss': `${props.backtestResult.winning_days} / ${props.backtestResult.draw_days} / ${props.backtestResult.losing_days}`,
value: `${props.backtestResult.winning_days} / ${props.backtestResult.draw_days} / ${props.backtestResult.losing_days}`,
},
{
metric: 'Avg. Duration winners',
value: humanizeDurationFromSeconds(props.backtestResult.winner_holding_avg_s),
}, },
{ {
metric: 'Avg. Duration Losers', 'Avg. Duration winners': humanizeDurationFromSeconds(
value: humanizeDurationFromSeconds(props.backtestResult.loser_holding_avg_s), props.backtestResult.winner_holding_avg_s,
),
}, },
{ {
metric: 'Max Consecutive Wins / Loss', 'Avg. Duration Losers': humanizeDurationFromSeconds(props.backtestResult.loser_holding_avg_s),
value: },
{
'Max Consecutive Wins / Loss':
props.backtestResult.max_consecutive_wins === undefined props.backtestResult.max_consecutive_wins === undefined
? 'N/A' ? 'N/A'
: `${props.backtestResult.max_consecutive_wins} / ${props.backtestResult.max_consecutive_losses}`, : `${props.backtestResult.max_consecutive_wins} / ${props.backtestResult.max_consecutive_losses}`,
}, },
{ metric: 'Rejected entry signals', value: props.backtestResult.rejected_signals }, { 'Rejected entry signals': props.backtestResult.rejected_signals },
{ {
metric: 'Entry/Exit timeouts', 'Entry/Exit timeouts': `${props.backtestResult.timedout_entry_orders} / ${props.backtestResult.timedout_exit_orders}`,
value: `${props.backtestResult.timedout_entry_orders} / ${props.backtestResult.timedout_exit_orders}`,
}, },
{ {
metric: 'Canceled Trade Entries', 'Canceled Trade Entries': props.backtestResult.canceled_trade_entries ?? 'N/A',
value: props.backtestResult.canceled_trade_entries ?? 'N/A',
}, },
{ {
metric: 'Canceled Entry Orders', 'Canceled Entry Orders': props.backtestResult.canceled_entry_orders ?? 'N/A',
value: props.backtestResult.canceled_entry_orders ?? 'N/A',
}, },
{ {
metric: 'Replaced Entry Orders', 'Replaced Entry Orders': props.backtestResult.replaced_entry_orders ?? 'N/A',
value: props.backtestResult.replaced_entry_orders ?? 'N/A',
}, },
...shortMetrics, ...shortMetrics,
{ metric: '___', value: '___' }, { ___: '___' },
{ metric: 'Min balance', value: formatPriceStake(props.backtestResult.csum_min) }, { 'Min balance': formatPriceStake(props.backtestResult.csum_min) },
{ metric: 'Max balance', value: formatPriceStake(props.backtestResult.csum_max) }, { 'Max balance': formatPriceStake(props.backtestResult.csum_max) },
{ metric: 'Market change', value: formatPercent(props.backtestResult.market_change) }, { 'Market change': formatPercent(props.backtestResult.market_change) },
{ metric: '___', value: '___' }, { '___ ': '___' },
{ {
metric: 'Max Drawdown (Account)', 'Max Drawdown (Account)': formatPercent(props.backtestResult.max_drawdown_account),
value: formatPercent(props.backtestResult.max_drawdown_account),
}, },
{ {
metric: 'Max Drawdown ABS', 'Max Drawdown ABS': formatPriceStake(props.backtestResult.max_drawdown_abs),
value: formatPriceStake(props.backtestResult.max_drawdown_abs),
}, },
{ {
metric: 'Drawdown high | low', 'Drawdown high | low': `${formatPriceStake(
value: `${formatPriceStake(props.backtestResult.max_drawdown_high)} | ${formatPriceStake( props.backtestResult.max_drawdown_high,
props.backtestResult.max_drawdown_low, )} | ${formatPriceStake(props.backtestResult.max_drawdown_low)}`,
)}`,
}, },
{ metric: 'Drawdown start', value: timestampms(props.backtestResult.drawdown_start_ts) }, { 'Drawdown start': timestampms(props.backtestResult.drawdown_start_ts) },
{ metric: 'Drawdown end', value: timestampms(props.backtestResult.drawdown_end_ts) }, { 'Drawdown end': timestampms(props.backtestResult.drawdown_end_ts) },
{ metric: '___', value: '___' }, { '___ ': '___' },
{ {
metric: 'Best Pair', 'Best Pair': `${props.backtestResult.best_pair.key} ${formatPercent(
value: `${props.backtestResult.best_pair.key} ${formatPercent(
props.backtestResult.best_pair.profit_sum, props.backtestResult.best_pair.profit_sum,
)}`, )}`,
}, },
{ {
metric: 'Worst Pair', 'Worst Pair': `${props.backtestResult.worst_pair.key} ${formatPercent(
value: `${props.backtestResult.worst_pair.key} ${formatPercent(
props.backtestResult.worst_pair.profit_sum, props.backtestResult.worst_pair.profit_sum,
)}`, )}`,
}, },
{ metric: 'Best single Trade', value: bestPair.value }, { 'Best single Trade': bestPair.value },
{ metric: 'Worst single Trade', value: worstPair.value }, { 'Worst single Trade': worstPair.value },
]; ];
return formatObjectForTable({ value: tmp }, 'metric');
}); });
const backtestResultSettings = computed(() => { const backtestResultSettings = computed(() => {