2021-09-03 14:55:39 +00:00
|
|
|
<template>
|
|
|
|
<b-table
|
|
|
|
ref="tradesTable"
|
|
|
|
small
|
|
|
|
hover
|
|
|
|
show-empty
|
|
|
|
primary-key="botId"
|
|
|
|
:items="tableItems"
|
|
|
|
:fields="tableFields"
|
|
|
|
>
|
2022-05-04 18:43:14 +00:00
|
|
|
<template #cell(botName)="row">
|
|
|
|
<div class="d-flex flex-row">
|
|
|
|
<b-form-checkbox
|
|
|
|
v-if="row.item.botId && botStore.botCount > 1"
|
|
|
|
v-model="botStore.botStores[row.item.botId].isSelected"
|
|
|
|
title="Show bot in Dashboard"
|
|
|
|
/>
|
|
|
|
<span>{{ row.value }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-10-28 17:33:08 +00:00
|
|
|
<template #cell(profitOpen)="row">
|
2021-09-04 09:10:57 +00:00
|
|
|
<profit-pill
|
2021-10-28 17:33:08 +00:00
|
|
|
v-if="row.item.profitOpen && row.item.botId != 'Summary'"
|
|
|
|
:profit-ratio="row.item.profitOpenRatio"
|
|
|
|
:profit-abs="row.item.profitOpen"
|
2021-09-04 09:10:57 +00:00
|
|
|
:stake-currency="row.item.stakeCurrency"
|
|
|
|
/>
|
|
|
|
</template>
|
2021-10-28 17:33:08 +00:00
|
|
|
<template #cell(profitClosed)="row">
|
2021-09-04 09:10:57 +00:00
|
|
|
<profit-pill
|
2021-10-28 17:33:08 +00:00
|
|
|
v-if="row.item.profitClosed && row.item.botId != 'Summary'"
|
|
|
|
:profit-ratio="row.item.profitClosedRatio"
|
|
|
|
:profit-abs="row.item.profitClosed"
|
2021-09-04 09:10:57 +00:00
|
|
|
:stake-currency="row.item.stakeCurrency"
|
|
|
|
/>
|
|
|
|
</template>
|
2021-10-28 17:33:08 +00:00
|
|
|
|
2021-09-18 14:31:53 +00:00
|
|
|
<template #cell(balance)="row">
|
|
|
|
<div v-if="row.item.balance">
|
|
|
|
<span :title="row.item.stakeCurrency"
|
|
|
|
>{{ formatPrice(row.item.balance, row.item.stakeCurrencyDecimals) }}
|
|
|
|
</span>
|
|
|
|
<span clas="text-small">{{ row.item.stakeCurrency }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-09-04 09:20:55 +00:00
|
|
|
<template #cell(winVsLoss)="row">
|
|
|
|
<div v-if="row.item.losses !== undefined">
|
|
|
|
<span class="text-profit">{{ row.item.wins }}</span> /
|
|
|
|
<span class="text-loss">{{ row.item.losses }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
2021-09-03 14:55:39 +00:00
|
|
|
</b-table>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-09-04 09:10:57 +00:00
|
|
|
import ProfitPill from '@/components/general/ProfitPill.vue';
|
2021-09-18 14:31:53 +00:00
|
|
|
import { formatPrice } from '@/shared/formatters';
|
2022-04-15 18:27:56 +00:00
|
|
|
import { defineComponent, computed } from '@vue/composition-api';
|
2022-04-19 17:19:45 +00:00
|
|
|
import { useBotStore } from '@/stores/ftbotwrapper';
|
2022-05-04 18:43:14 +00:00
|
|
|
import { ProfitInterface, ComparisonTableItems } from '@/types';
|
2021-09-03 14:55:39 +00:00
|
|
|
|
2022-04-15 18:27:56 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'BotComparisonList',
|
|
|
|
components: { ProfitPill },
|
|
|
|
setup() {
|
2022-04-19 17:19:45 +00:00
|
|
|
const botStore = useBotStore();
|
2021-09-03 14:55:39 +00:00
|
|
|
|
2022-04-15 18:27:56 +00:00
|
|
|
const tableFields: Record<string, string | Function>[] = [
|
2022-05-04 18:43:14 +00:00
|
|
|
{ key: 'botName', label: 'Bot' },
|
2022-04-15 18:27:56 +00:00
|
|
|
{ key: 'trades', label: 'Trades' },
|
|
|
|
{ key: 'profitOpen', label: 'Open Profit' },
|
|
|
|
{ key: 'profitClosed', label: 'Closed Profit' },
|
|
|
|
{ key: 'balance', label: 'Balance' },
|
|
|
|
{ key: 'winVsLoss', label: 'W/L' },
|
|
|
|
];
|
2021-09-03 14:55:39 +00:00
|
|
|
|
2022-04-15 18:27:56 +00:00
|
|
|
const tableItems = computed(() => {
|
2022-05-04 18:43:14 +00:00
|
|
|
const val: ComparisonTableItems[] = [];
|
|
|
|
const summary: ComparisonTableItems = {
|
|
|
|
botId: undefined,
|
|
|
|
botName: 'Summary',
|
2022-04-15 18:27:56 +00:00
|
|
|
profitClosed: 0,
|
2022-05-09 05:10:34 +00:00
|
|
|
profitClosedRatio: undefined,
|
2022-04-15 18:27:56 +00:00
|
|
|
profitOpen: 0,
|
2022-05-09 05:10:34 +00:00
|
|
|
profitOpenRatio: undefined,
|
2022-04-15 18:27:56 +00:00
|
|
|
stakeCurrency: 'USDT',
|
|
|
|
wins: 0,
|
|
|
|
losses: 0,
|
|
|
|
};
|
2021-09-03 15:27:20 +00:00
|
|
|
|
2022-04-29 15:58:25 +00:00
|
|
|
Object.entries(botStore.allProfit).forEach(([k, v]: [k: string, v: ProfitInterface]) => {
|
2022-04-19 17:19:45 +00:00
|
|
|
const allStakes = botStore.allOpenTrades[k].reduce((a, b) => a + b.stake_amount, 0);
|
2022-04-15 18:27:56 +00:00
|
|
|
const profitOpenRatio =
|
2022-04-19 17:19:45 +00:00
|
|
|
botStore.allOpenTrades[k].reduce((a, b) => a + b.profit_ratio * b.stake_amount, 0) /
|
2022-04-15 18:27:56 +00:00
|
|
|
allStakes;
|
2022-04-29 15:58:25 +00:00
|
|
|
const profitOpen = botStore.allOpenTrades[k].reduce((a, b) => a + (b.profit_abs ?? 0), 0);
|
2021-10-28 17:33:08 +00:00
|
|
|
|
2022-04-15 18:27:56 +00:00
|
|
|
// TODO: handle one inactive bot ...
|
|
|
|
val.push({
|
2022-05-04 18:43:14 +00:00
|
|
|
botId: k,
|
|
|
|
botName: botStore.availableBots[k].botName,
|
2022-04-19 17:19:45 +00:00
|
|
|
trades: `${botStore.allOpenTradeCount[k]} / ${
|
|
|
|
botStore.allBotState[k]?.max_open_trades || 'N/A'
|
2022-04-15 18:27:56 +00:00
|
|
|
}`,
|
|
|
|
profitClosed: v.profit_closed_coin,
|
|
|
|
profitClosedRatio: v.profit_closed_ratio || 0,
|
2022-04-19 17:19:45 +00:00
|
|
|
stakeCurrency: botStore.allBotState[k]?.stake_currency || '',
|
2022-04-15 18:27:56 +00:00
|
|
|
profitOpenRatio,
|
|
|
|
profitOpen,
|
|
|
|
wins: v.winning_trades,
|
|
|
|
losses: v.losing_trades,
|
2022-04-19 17:19:45 +00:00
|
|
|
balance: botStore.allBalance[k]?.total,
|
|
|
|
stakeCurrencyDecimals: botStore.allBotState[k]?.stake_currency_decimals || 3,
|
2022-04-15 18:27:56 +00:00
|
|
|
});
|
|
|
|
if (v.profit_closed_coin !== undefined) {
|
|
|
|
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 14:55:39 +00:00
|
|
|
});
|
2022-04-15 18:27:56 +00:00
|
|
|
val.push(summary);
|
|
|
|
return val;
|
2021-09-03 15:27:20 +00:00
|
|
|
});
|
2021-09-03 14:55:39 +00:00
|
|
|
|
2022-04-15 18:27:56 +00:00
|
|
|
return {
|
|
|
|
formatPrice,
|
|
|
|
tableFields,
|
|
|
|
tableItems,
|
2022-05-04 18:43:14 +00:00
|
|
|
botStore,
|
2022-04-15 18:27:56 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
2021-09-03 14:55:39 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|