2020-07-26 17:35:56 +00:00
|
|
|
<template>
|
2023-08-16 09:55:32 +00:00
|
|
|
<div class="px-0 mw-100">
|
|
|
|
<div class="d-flex justify-content-center">
|
2021-03-10 15:09:55 +00:00
|
|
|
<h3>Backtest-result for {{ backtestResult.strategy_name }}</h3>
|
2020-07-26 17:35:56 +00:00
|
|
|
</div>
|
2021-03-11 18:17:09 +00:00
|
|
|
|
2023-08-16 09:55:32 +00:00
|
|
|
<div class="d-flex flex-column text-start ms-0 me-2 gap-2">
|
2023-08-16 09:57:12 +00:00
|
|
|
<div class="d-flex flex-column flex-xl-row">
|
|
|
|
<div class="px-0 px-xl-0 pe-xl-1 flex-fill">
|
2021-07-04 17:57:19 +00:00
|
|
|
<b-card header="Strategy settings">
|
|
|
|
<b-table
|
|
|
|
small
|
|
|
|
borderless
|
|
|
|
:items="backtestResultSettings"
|
|
|
|
:fields="backtestsettingFields"
|
|
|
|
>
|
|
|
|
</b-table>
|
|
|
|
</b-card>
|
|
|
|
</div>
|
2023-08-16 09:57:12 +00:00
|
|
|
<div class="px-0 px-xl-0 pt-2 pt-xl-0 ps-xl-1 flex-fill">
|
2021-07-04 17:57:19 +00:00
|
|
|
<b-card header="Metrics">
|
|
|
|
<b-table small borderless :items="backtestResultStats" :fields="backtestResultFields">
|
|
|
|
</b-table>
|
|
|
|
</b-card>
|
|
|
|
</div>
|
2021-01-19 21:50:51 +00:00
|
|
|
</div>
|
2023-08-16 09:55:32 +00:00
|
|
|
<b-card header="Results per Exit-reason">
|
2023-10-24 17:51:46 +00:00
|
|
|
<b-table small hover stacked="sm" :items="exitReasonSummary" :fields="perExitReason">
|
2020-07-26 17:36:47 +00:00
|
|
|
</b-table>
|
|
|
|
</b-card>
|
2023-08-16 09:55:32 +00:00
|
|
|
<b-card header="Results per pair">
|
2023-10-24 17:51:46 +00:00
|
|
|
<b-table small hover stacked="sm" :items="resultsPerPair" :fields="perPairFields">
|
2021-01-06 19:25:38 +00:00
|
|
|
</b-table>
|
|
|
|
</b-card>
|
2023-08-16 09:55:32 +00:00
|
|
|
<b-card v-if="backtestResult.periodic_breakdown" header="Periodic breakdown">
|
2023-07-11 20:02:02 +00:00
|
|
|
<BacktestResultPeriodBreakdown :periodic-breakdown="backtestResult.periodic_breakdown">
|
|
|
|
</BacktestResultPeriodBreakdown>
|
2023-04-24 09:19:14 +00:00
|
|
|
</b-card>
|
2020-07-26 17:36:47 +00:00
|
|
|
|
2023-08-16 09:55:32 +00:00
|
|
|
<b-card header="Single trades">
|
2021-07-04 17:57:19 +00:00
|
|
|
<TradeList
|
|
|
|
:trades="backtestResult.trades"
|
2021-08-09 17:56:11 +00:00
|
|
|
:show-filter="true"
|
2021-07-17 15:14:20 +00:00
|
|
|
:stake-currency="backtestResult.stake_currency"
|
2021-07-04 17:57:19 +00:00
|
|
|
/>
|
|
|
|
</b-card>
|
2020-07-26 17:35:56 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
<script setup lang="ts">
|
2020-07-26 17:35:56 +00:00
|
|
|
import TradeList from '@/components/ftbot/TradeList.vue';
|
2023-10-24 17:49:24 +00:00
|
|
|
import { StrategyBacktestResult } from '@/types';
|
2023-04-24 09:25:30 +00:00
|
|
|
import BacktestResultPeriodBreakdown from './BacktestResultPeriodBreakdown.vue';
|
2023-10-24 17:21:56 +00:00
|
|
|
import { formatObjectForTable } from '@/shared/objectToTableItems';
|
2020-07-26 17:35:56 +00:00
|
|
|
|
2023-04-24 09:25:30 +00:00
|
|
|
import { computed } from 'vue';
|
2023-10-24 17:49:24 +00:00
|
|
|
import { formatPercent, formatPrice } from '@/shared/formatters';
|
|
|
|
import { generateBacktestMetricRows, generateBacktestSettingRows } from '@/shared/backtestMetrics';
|
2023-04-06 05:16:57 +00:00
|
|
|
import { TableField, TableItem } from 'bootstrap-vue-next';
|
2020-07-26 17:35:56 +00:00
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
const props = defineProps({
|
|
|
|
backtestResult: { required: true, type: Object as () => StrategyBacktestResult },
|
|
|
|
});
|
2021-01-21 06:47:51 +00:00
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
const backtestResultStats = computed(() => {
|
2023-10-24 17:45:37 +00:00
|
|
|
const tmp = generateBacktestMetricRows(props.backtestResult);
|
2023-10-24 17:32:40 +00:00
|
|
|
return formatObjectForTable({ value: tmp }, 'metric');
|
2022-12-10 13:17:13 +00:00
|
|
|
});
|
2021-01-19 21:50:51 +00:00
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
const backtestResultSettings = computed(() => {
|
|
|
|
// Transpose Result into readable format
|
2023-10-24 17:49:24 +00:00
|
|
|
const tmp = generateBacktestSettingRows(props.backtestResult);
|
2023-10-24 17:21:56 +00:00
|
|
|
|
|
|
|
return formatObjectForTable({ value: tmp }, 'setting');
|
2022-12-10 13:17:13 +00:00
|
|
|
});
|
2023-10-24 17:51:46 +00:00
|
|
|
|
|
|
|
const resultsPerPair = computed(() => backtestResult.results_per_pair as unknown as TableItem[]);
|
|
|
|
const exitReasonSummary = computed(
|
|
|
|
() =>
|
|
|
|
(backtestResult.exit_reason_summary ||
|
|
|
|
backtestResult.sell_reason_summary) as unknown as TableItem[],
|
|
|
|
);
|
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
const perPairFields = computed(() => {
|
|
|
|
return [
|
|
|
|
{ key: 'key', label: 'Pair' },
|
|
|
|
{ key: 'trades', label: 'Buys' },
|
|
|
|
{
|
|
|
|
key: 'profit_mean',
|
|
|
|
label: 'Avg Profit %',
|
|
|
|
formatter: (value) => formatPercent(value, 2),
|
|
|
|
},
|
|
|
|
{ key: 'profit_sum', label: 'Cum Profit %', formatter: (value) => formatPercent(value, 2) },
|
|
|
|
{
|
|
|
|
key: 'profit_total_abs',
|
|
|
|
label: `Tot Profit ${props.backtestResult.stake_currency}`,
|
|
|
|
formatter: (value) => formatPrice(value, props.backtestResult.stake_currency_decimals),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'profit_total',
|
|
|
|
label: 'Tot Profit %',
|
|
|
|
formatter: (value) => formatPercent(value, 2),
|
|
|
|
},
|
|
|
|
{ key: 'duration_avg', label: 'Avg Duration' },
|
|
|
|
{ key: 'wins', label: 'Wins' },
|
|
|
|
{ key: 'draws', label: 'Draws' },
|
|
|
|
{ key: 'losses', label: 'Losses' },
|
|
|
|
];
|
|
|
|
});
|
2020-07-26 17:36:47 +00:00
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
const perExitReason = computed(() => {
|
|
|
|
return [
|
|
|
|
{ key: 'exit_reason', label: 'Exit Reason' },
|
|
|
|
{ key: 'trades', label: 'Buys' },
|
|
|
|
{
|
|
|
|
key: 'profit_mean',
|
|
|
|
label: 'Avg Profit %',
|
|
|
|
formatter: (value) => formatPercent(value, 2),
|
|
|
|
},
|
|
|
|
{ key: 'profit_sum', label: 'Cum Profit %', formatter: (value) => formatPercent(value, 2) },
|
|
|
|
{
|
|
|
|
key: 'profit_total_abs',
|
|
|
|
label: `Tot Profit ${props.backtestResult.stake_currency}`,
|
2021-01-19 21:50:51 +00:00
|
|
|
|
2022-12-10 13:17:13 +00:00
|
|
|
formatter: (value) => formatPrice(value, props.backtestResult.stake_currency_decimals),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'profit_total',
|
|
|
|
label: 'Tot Profit %',
|
|
|
|
formatter: (value) => formatPercent(value, 2),
|
|
|
|
},
|
|
|
|
{ key: 'wins', label: 'Wins' },
|
|
|
|
{ key: 'draws', label: 'Draws' },
|
|
|
|
{ key: 'losses', label: 'Losses' },
|
|
|
|
];
|
2022-04-21 04:37:57 +00:00
|
|
|
});
|
2023-04-05 19:08:53 +00:00
|
|
|
const backtestResultFields: TableField[] = [
|
2022-12-10 13:17:13 +00:00
|
|
|
{ key: 'metric', label: 'Metric' },
|
|
|
|
{ key: 'value', label: 'Value' },
|
|
|
|
];
|
|
|
|
|
2023-04-05 19:08:53 +00:00
|
|
|
const backtestsettingFields: TableField[] = [
|
2022-12-10 13:17:13 +00:00
|
|
|
{ key: 'setting', label: 'Setting' },
|
|
|
|
{ key: 'value', label: 'Value' },
|
|
|
|
];
|
2020-07-26 17:35:56 +00:00
|
|
|
</script>
|
|
|
|
|
2023-08-16 09:55:32 +00:00
|
|
|
<style lang="scss" scoped></style>
|