Add support for mixed tags

closes #1917
This commit is contained in:
Matthias 2024-06-12 06:24:48 +02:00
parent 913668fe8a
commit bdc91a9ec9
3 changed files with 37 additions and 6 deletions

View File

@ -40,6 +40,15 @@
:stake-currency-decimals="backtestResult.stake_currency_decimals"
/>
<BacktestResultTablePer
v-if="backtestResult.mix_tag_stats"
title="Results Mixed Tag"
:results="backtestResult.mix_tag_stats ?? []"
:stake-currency="backtestResult.stake_currency"
:key-headers="['Enter Tag', 'Exit Tag']"
:stake-currency-decimals="backtestResult.stake_currency_decimals"
/>
<BacktestResultTablePer
title="Results per pair"
:results="backtestResult.results_per_pair"

View File

@ -1,30 +1,51 @@
<script setup lang="ts">
import { formatPercent, formatPrice } from '@/shared/formatters';
import type { ExitReasonResults, PairResult } from '@/types';
import { TableItem } from 'bootstrap-vue-next';
import { TableField, TableItem } from 'bootstrap-vue-next';
const props = defineProps({
title: { type: String, required: true },
results: { type: Array as PropType<(PairResult | ExitReasonResults)[]>, required: true },
stakeCurrency: { type: String, required: true },
stakeCurrencyDecimals: { type: Number, required: true },
keyHeader: { type: String, default: 'Tag' },
keyHeader: { type: String, default: '' },
keyHeaders: { type: Array as PropType<string[]>, default: () => [] },
});
const tableItems = computed(() => props.results as unknown as TableItem[]);
const perTagReason = computed(() => {
return [
{
const firstFields: TableField[] = [];
if (props.keyHeaders.length > 0) {
// Keys could be an array
for (let i = 0; i < props.keyHeaders.length; i += 1) {
firstFields.push({
key: `key`,
label: props.keyHeaders[i],
formatter: (value, _, item) =>
Array.isArray(value) ? value[i] : value || item['exit_reason'] || 'OTHER',
});
}
} else {
firstFields.push({
key: 'key',
label: props.keyHeader,
formatter: (value, _, item) => value || item['exit_reason'] || 'OTHER',
},
});
}
return [
...firstFields,
// {
// key: 'key',
// label: props.keyHeader,
// formatter: (value, _, item) => value || item['exit_reason'] || 'OTHER',
// },
{ key: 'trades', label: 'Trades' },
{
key: 'profit_mean',
label: 'Avg Profit %',
formatter: (value) => formatPercent(value, 2),
formatter: (value: number) => formatPercent(value, 2),
},
{
key: 'profit_total_abs',

View File

@ -77,6 +77,7 @@ export interface StrategyBacktestResult {
results_per_pair: PairResult[];
sell_reason_summary?: ExitReasonResults[];
exit_reason_summary?: ExitReasonResults[] | PairResult[];
mix_tag_stats?: ExitReasonResults[];
results_per_enter_tag: PairResult[];
periodic_breakdown?: PeriodicBreakdown;
left_open_trades: Trade[];