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

View File

@ -20,8 +20,9 @@
<script lang="ts"> <script lang="ts">
import { defineComponent, computed, onMounted } from 'vue'; import { defineComponent, computed, onMounted } from 'vue';
import DailyChart from '@/components/charts/DailyChart.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 { useBotStore } from '@/stores/ftbotwrapper';
import { TableField } from 'bootstrap-vue-next';
export default defineComponent({ export default defineComponent({
name: 'DailyStats', name: 'DailyStats',
@ -30,20 +31,28 @@ export default defineComponent({
}, },
setup() { setup() {
const botStore = useBotStore(); const botStore = useBotStore();
const dailyFields = computed(() => { const dailyFields = computed<TableField[]>(() => {
return [ const res: TableField[] = [
{ key: 'date', label: 'Day' }, { 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', key: 'fiat_value',
label: `In ${botStore.activeBot.dailyStats.fiat_display_currency}`, 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' }, { 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(() => { onMounted(() => {
botStore.activeBot.getDaily(); botStore.activeBot.getDaily();

View File

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