mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 13:35:17 +00:00
Improve ComparisonList
This commit is contained in:
parent
8d8faf89b7
commit
be4a15c6fa
|
@ -9,19 +9,35 @@
|
||||||
:items="tableItems"
|
:items="tableItems"
|
||||||
:fields="tableFields"
|
:fields="tableFields"
|
||||||
>
|
>
|
||||||
|
<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>
|
||||||
</b-table>
|
</b-table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { formatPrice } from '@/shared/formatters';
|
|
||||||
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
import { MultiBotStoreGetters } from '@/store/modules/botStoreWrapper';
|
||||||
import { BotDescriptors, BotState, ProfitInterface } from '@/types';
|
import { BotDescriptors, BotState, ProfitInterface } from '@/types';
|
||||||
import { Component, Vue } from 'vue-property-decorator';
|
import { Component, Vue } from 'vue-property-decorator';
|
||||||
import { namespace } from 'vuex-class';
|
import { namespace } from 'vuex-class';
|
||||||
|
import ProfitPill from '@/components/general/ProfitPill.vue';
|
||||||
|
|
||||||
const ftbot = namespace('ftbot');
|
const ftbot = namespace('ftbot');
|
||||||
|
|
||||||
@Component({})
|
@Component({ components: { ProfitPill } })
|
||||||
export default class BotComparisonList extends Vue {
|
export default class BotComparisonList extends Vue {
|
||||||
@ftbot.Getter [MultiBotStoreGetters.allProfit]!: Record<string, ProfitInterface>;
|
@ftbot.Getter [MultiBotStoreGetters.allProfit]!: Record<string, ProfitInterface>;
|
||||||
|
|
||||||
|
@ -33,44 +49,48 @@ export default class BotComparisonList extends Vue {
|
||||||
|
|
||||||
get tableItems() {
|
get tableItems() {
|
||||||
const val: any[] = [];
|
const val: any[] = [];
|
||||||
let closedSum = 0;
|
const summary = {
|
||||||
let openProfitSum = 0;
|
botId: 'Summary',
|
||||||
let decimals = 3;
|
profitClosed: 0,
|
||||||
|
profitClosedRatio: undefined,
|
||||||
|
profitOpen: 0,
|
||||||
|
profitOpenRatio: undefined,
|
||||||
|
stakeCurrency: 'USDT',
|
||||||
|
wins: 0,
|
||||||
|
losses: 0,
|
||||||
|
winVsLoss: '',
|
||||||
|
};
|
||||||
|
|
||||||
Object.entries(this.allProfit).forEach(([k, v]) => {
|
Object.entries(this.allProfit).forEach(([k, v]) => {
|
||||||
// TODO: handle one inactive bot ...
|
// TODO: handle one inactive bot ...
|
||||||
val.push({
|
val.push({
|
||||||
botId: this.allAvailableBots[k].botName,
|
botId: this.allAvailableBots[k].botName,
|
||||||
trades: `${this.allOpenTradeCount[k]} / ${this.allBotState[k]?.max_open_trades}`,
|
trades: `${this.allOpenTradeCount[k]} / ${this.allBotState[k]?.max_open_trades}`,
|
||||||
profitClosed: `${
|
profitClosed: v.profit_closed_coin,
|
||||||
formatPrice(v.profit_closed_coin, this.allBotState[k]?.stake_currency_decimals) || 'N/A'
|
profitClosedRatio: v.profit_closed_ratio_sum || 0,
|
||||||
} `,
|
stakeCurrency: this.allBotState[k]?.stake_currency || '',
|
||||||
profitClosedPercent: `${v.profit_closed_percent_sum || 'N/A'}`,
|
profitOpenRatio: v.profit_all_ratio_sum - v.profit_closed_ratio_sum,
|
||||||
profitOpenPercent: v.profit_all_percent_sum,
|
profitOpen: v.profit_all_coin - v.profit_closed_coin,
|
||||||
profitOpen: v.profit_all_coin,
|
|
||||||
winVsLoss: `${v.winning_trades || 'N/A'} / ${v.losing_trades || 'N/A'}`,
|
winVsLoss: `${v.winning_trades || 'N/A'} / ${v.losing_trades || 'N/A'}`,
|
||||||
});
|
});
|
||||||
if (v.profit_closed_coin !== undefined) {
|
if (v.profit_closed_coin !== undefined) {
|
||||||
closedSum += v.profit_closed_coin;
|
summary.profitClosed += v.profit_closed_coin;
|
||||||
openProfitSum += v.profit_all_coin;
|
summary.profitOpen += v.profit_all_coin;
|
||||||
decimals = this.allBotState[k]?.stake_currency_decimals || decimals;
|
summary.wins += v.winning_trades;
|
||||||
|
summary.losses += v.losing_trades;
|
||||||
|
// summary.decimals = this.allBotState[k]?.stake_currency_decimals || summary.decimals;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
val.push({
|
summary.winVsLoss = `${summary.wins} / ${summary.losses}`;
|
||||||
botId: 'Summary',
|
val.push(summary);
|
||||||
profitClosed: formatPrice(closedSum, decimals),
|
|
||||||
profitClosedPercent: '',
|
|
||||||
profitOpenPercent: '',
|
|
||||||
profitOpen: '',
|
|
||||||
winVsLoss: '',
|
|
||||||
});
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
tableFields: Record<string, string | Function>[] = [
|
tableFields: Record<string, string | Function>[] = [
|
||||||
{ key: 'botId', label: 'Bot' },
|
{ key: 'botId', label: 'Bot' },
|
||||||
{ key: 'trades', label: 'Trades' },
|
{ key: 'trades', label: 'Trades' },
|
||||||
|
{ key: 'profitOpen', label: 'Open Profit' },
|
||||||
{ key: 'profitClosed', label: 'Closed Profit' },
|
{ key: 'profitClosed', label: 'Closed Profit' },
|
||||||
{ key: 'profitClosedPercent', label: 'Closed Profit %' },
|
|
||||||
{ key: 'winVsLoss', label: 'W/L' },
|
{ key: 'winVsLoss', label: 'W/L' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user