Fix some type errors with bootstrap table

This commit is contained in:
Matthias 2023-04-05 21:08:53 +02:00
parent fa01c39b5b
commit b08e1286c9
3 changed files with 23 additions and 12 deletions

View File

@ -68,6 +68,7 @@ import {
formatPrice,
humanizeDurationFromSeconds,
} from '@/shared/formatters';
import { TableField } from 'bootstrap-vue-next';
const props = defineProps({
backtestResult: { required: true, type: Object as () => StrategyBacktestResult },
@ -389,12 +390,12 @@ const perExitReason = computed(() => {
{ key: 'losses', label: 'Losses' },
];
});
const backtestResultFields: Array<Record<string, string>> = [
const backtestResultFields: TableField[] = [
{ key: 'metric', label: 'Metric' },
{ key: 'value', label: 'Value' },
];
const backtestsettingFields: Array<Record<string, string>> = [
const backtestsettingFields: TableField[] = [
{ key: 'setting', label: 'Setting' },
{ key: 'value', label: 'Value' },
];

View File

@ -20,8 +20,9 @@
<script lang="ts">
import { defineComponent, computed, onMounted } from 'vue';
import DailyChart from '@/components/charts/DailyChart.vue';
import { formatPercent, formatPrice } from '@/shared/formatters';
import { formatPercent } from '@/shared/formatters';
import { useBotStore } from '@/stores/ftbotwrapper';
import { TableField } from 'bootstrap-vue-next';
export default defineComponent({
name: 'DailyStats',
@ -30,20 +31,28 @@ export default defineComponent({
},
setup() {
const botStore = useBotStore();
const dailyFields = computed(() => {
return [
const dailyFields = computed<TableField[]>(() => {
const res: TableField[] = [
{ key: 'date', label: 'Day' },
{ key: 'abs_profit', label: 'Profit', formatter: (value) => formatPrice(value) },
{
key: 'abs_profit',
label: 'Profit',
// formatter: (value: unknown) => formatPrice(value as number),
},
{
key: 'fiat_value',
label: `In ${botStore.activeBot.dailyStats.fiat_display_currency}`,
formatter: (value) => formatPrice(value, 2),
// formatter: (value: unknown) => formatPrice(value as number, 2),
},
{ key: 'trade_count', label: 'Trades' },
botStore.activeBot.botApiVersion >= 2.16
? { key: 'rel_profit', label: 'Profit%', formatter: (value) => formatPercent(value, 2) }
: null,
];
if (botStore.activeBot.botApiVersion >= 2.16)
res.push({
key: 'rel_profit',
label: 'Profit%',
formatter: (value: unknown) => formatPercent(value as number, 2),
});
return res;
});
onMounted(() => {
botStore.activeBot.getDaily();

View File

@ -15,19 +15,20 @@
import { formatPrice } from '@/shared/formatters';
import { defineComponent, computed } from 'vue';
import { useBotStore } from '@/stores/ftbotwrapper';
import { TableField } from 'bootstrap-vue-next';
export default defineComponent({
name: 'Performance',
setup() {
const botStore = useBotStore();
const tableFields = computed(() => {
const tableFields = computed<TableField[]>(() => {
return [
{ key: 'pair', label: 'Pair' },
{ key: 'profit', label: 'Profit %' },
{
key: 'profit_abs',
label: `Profit ${botStore.activeBot.botState?.stake_currency}`,
formatter: (v: number) => formatPrice(v, 5),
formatter: (v: unknown) => formatPrice(v as number, 5),
},
{ key: 'count', label: 'Count' },
];