Add winrate to backtest results

closes #1372
This commit is contained in:
Matthias 2023-07-20 20:47:30 +02:00
parent c8517939e0
commit b1266bd4f6
2 changed files with 21 additions and 8 deletions

View File

@ -79,6 +79,7 @@ import {
formatPercent, formatPercent,
formatPrice, formatPrice,
humanizeDurationFromSeconds, humanizeDurationFromSeconds,
isNotUndefined,
} from '@/shared/formatters'; } from '@/shared/formatters';
import { TableField, TableItem } from 'bootstrap-vue-next'; import { TableField, TableItem } from 'bootstrap-vue-next';
@ -115,6 +116,10 @@ const worstPair = computed((): string => {
return `${value.pair} ${formatPercent(value.profit_ratio, 2)}`; return `${value.pair} ${formatPercent(value.profit_ratio, 2)}`;
}); });
const pairSummary = computed(() => {
return props.backtestResult.results_per_pair[props.backtestResult.results_per_pair.length - 1];
});
const backtestResultStats = computed(() => { const backtestResultStats = computed(() => {
// Transpose Result into readable format // Transpose Result into readable format
const shortMetrics = const shortMetrics =
@ -198,14 +203,19 @@ const backtestResultStats = computed(() => {
{ {
metric: 'Win/Draw/Loss', metric: 'Win/Draw/Loss',
value: `${ value: `${pairSummary.value.wins} / ${pairSummary.value.draws} / ${
props.backtestResult.results_per_pair[props.backtestResult.results_per_pair.length - 1].wins pairSummary.value.losses
} / ${ } ${
props.backtestResult.results_per_pair[props.backtestResult.results_per_pair.length - 1] isNotUndefined(pairSummary.value.winrate)
.draws ? '(WR: ' +
} / ${ formatPercent(
props.backtestResult.results_per_pair[props.backtestResult.results_per_pair.length - 1] props.backtestResult.results_per_pair[
.losses props.backtestResult.results_per_pair.length - 1
].winrate ?? 0,
2,
) +
')'
: ''
}`, }`,
}, },
{ {

View File

@ -32,6 +32,7 @@ export interface PairResult {
profit_total: number; profit_total: number;
trades: number; trades: number;
wins: number; wins: number;
winrate?: number;
} }
export interface ExitReasonResults { export interface ExitReasonResults {
@ -48,6 +49,7 @@ export interface ExitReasonResults {
profit_total_pct: number; profit_total_pct: number;
trades: number; trades: number;
wins: number; wins: number;
winrate?: number;
} }
// Generated by https://quicktype.io // Generated by https://quicktype.io
@ -59,6 +61,7 @@ export interface PeriodicStat {
wins: number; wins: number;
draws: number; draws: number;
loses: number; loses: number;
winrate?: number;
} }
export interface PeriodicBreakdown { export interface PeriodicBreakdown {