frequi_origin/src/components/ftbot/BotComarisonList.vue

100 lines
3.1 KiB
Vue
Raw Normal View History

2021-09-03 14:55:39 +00:00
<template>
<b-table
ref="tradesTable"
small
hover
stacked="md"
show-empty
primary-key="botId"
:items="tableItems"
:fields="tableFields"
>
2021-09-04 09:10:57 +00:00
<template #cell(profitClosed)="row">
<profit-pill
v-if="row.item.profitClosed"
:profit-ratio="row.item.profitClosedRatio"
:profit-abs="row.item.profitClosed"
:stake-currency="row.item.stakeCurrency"
/>
</template>
<template #cell(profitOpen)="row">
<profit-pill
v-if="row.item.profitClosed"
:profit-ratio="row.item.profitOpenRatio"
:profit-abs="row.item.profitOpen"
:stake-currency="row.item.stakeCurrency"
/>
</template>
2021-09-03 14:55:39 +00:00
</b-table>
</template>
<script lang="ts">
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
2021-09-03 15:27:20 +00:00
import { BotDescriptors, BotState, ProfitInterface } from '@/types';
2021-09-03 14:55:39 +00:00
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
2021-09-04 09:10:57 +00:00
import ProfitPill from '@/components/general/ProfitPill.vue';
2021-09-03 14:55:39 +00:00
const ftbot = namespace('ftbot');
2021-09-04 09:10:57 +00:00
@Component({ components: { ProfitPill } })
2021-09-03 14:55:39 +00:00
export default class BotComparisonList extends Vue {
@ftbot.Getter [MultiBotStoreGetters.allProfit]!: Record<string, ProfitInterface>;
2021-09-03 15:27:20 +00:00
@ftbot.Getter [MultiBotStoreGetters.allOpenTradeCount]!: Record<string, number>;
@ftbot.Getter [MultiBotStoreGetters.allBotState]!: Record<string, BotState>;
2021-09-03 14:55:39 +00:00
@ftbot.Getter [MultiBotStoreGetters.allAvailableBots]!: BotDescriptors;
get tableItems() {
const val: any[] = [];
2021-09-04 09:10:57 +00:00
const summary = {
botId: 'Summary',
profitClosed: 0,
profitClosedRatio: undefined,
profitOpen: 0,
profitOpenRatio: undefined,
stakeCurrency: 'USDT',
wins: 0,
losses: 0,
winVsLoss: '',
};
2021-09-03 14:55:39 +00:00
Object.entries(this.allProfit).forEach(([k, v]) => {
// TODO: handle one inactive bot ...
val.push({
botId: this.allAvailableBots[k].botName,
2021-09-03 15:27:20 +00:00
trades: `${this.allOpenTradeCount[k]} / ${this.allBotState[k]?.max_open_trades}`,
2021-09-04 09:10:57 +00:00
profitClosed: v.profit_closed_coin,
profitClosedRatio: v.profit_closed_ratio_sum || 0,
stakeCurrency: this.allBotState[k]?.stake_currency || '',
profitOpenRatio: v.profit_all_ratio_sum - v.profit_closed_ratio_sum,
profitOpen: v.profit_all_coin - v.profit_closed_coin,
2021-09-03 14:55:39 +00:00
winVsLoss: `${v.winning_trades || 'N/A'} / ${v.losing_trades || 'N/A'}`,
});
2021-09-03 15:27:20 +00:00
if (v.profit_closed_coin !== undefined) {
2021-09-04 09:10:57 +00:00
summary.profitClosed += v.profit_closed_coin;
summary.profitOpen += v.profit_all_coin;
summary.wins += v.winning_trades;
summary.losses += v.losing_trades;
// summary.decimals = this.allBotState[k]?.stake_currency_decimals || summary.decimals;
2021-09-03 15:27:20 +00:00
}
});
2021-09-04 09:10:57 +00:00
summary.winVsLoss = `${summary.wins} / ${summary.losses}`;
val.push(summary);
2021-09-03 14:55:39 +00:00
return val;
}
tableFields: Record<string, string | Function>[] = [
2021-09-03 15:27:20 +00:00
{ key: 'botId', label: 'Bot' },
{ key: 'trades', label: 'Trades' },
2021-09-04 09:10:57 +00:00
{ key: 'profitOpen', label: 'Open Profit' },
2021-09-03 14:55:39 +00:00
{ key: 'profitClosed', label: 'Closed Profit' },
{ key: 'winVsLoss', label: 'W/L' },
];
}
</script>
<style scoped></style>