From 51433340050ab57ee31dca07f96cdfa97a83afc2 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 17 Jul 2021 16:00:15 +0200 Subject: [PATCH] Show absolute profit in trades list --- src/components/ftbot/TradeList.vue | 17 ++++++++++++++--- src/store/modules/ftbot/index.ts | 4 ++++ src/types/types.ts | 1 + 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/components/ftbot/TradeList.vue b/src/components/ftbot/TradeList.vue index 48d75f23..30165793 100644 --- a/src/components/ftbot/TradeList.vue +++ b/src/components/ftbot/TradeList.vue @@ -67,6 +67,7 @@ import { Trade } from '@/types'; import DeleteIcon from 'vue-material-design-icons/Delete.vue'; import ForceSellIcon from 'vue-material-design-icons/CloseBoxMultiple.vue'; import DateTimeTZ from '@/components/general/DateTimeTZ.vue'; +import { BotStoreGetters } from '@/store/modules/ftbot'; import ProfitSymbol from './ProfitSymbol.vue'; const ftbot = namespace('ftbot'); @@ -95,6 +96,8 @@ export default class TradeList extends Vue { @ftbot.State detailTradeId?: number; + @ftbot.Getter [BotStoreGetters.stakeCurrencyDecimals]!: number; + @ftbot.Action setDetailTrade; // eslint-disable-next-line @typescript-eslint/no-unused-vars @@ -145,18 +148,26 @@ export default class TradeList extends Vue { { key: this.activeTrades ? 'current_profit' : this.profitColumn, label: this.activeTrades ? 'Current profit %' : 'Profit %', - formatter: (value) => formatPercent(value, 3), + formatter: (value, key, item: Trade) => { + return `${formatPercent(item.profit_ratio, 3)} (${this.formatPriceWithDecimals( + item.profit_abs, + )})`; + }, }, { key: 'open_timestamp', label: 'Open date' }, ...(this.activeTrades ? this.openFields : this.closedFields), ]; - forcesellHandler(item) { + formatPriceWithDecimals(price) { + return formatPrice(price, this.stakeCurrencyDecimals); + } + + forcesellHandler(item: Trade) { this.$bvModal .msgBoxConfirm(`Really forcesell trade ${item.trade_id} (Pair ${item.pair})?`) .then((value: boolean) => { if (value) { - this.forcesell(item.trade_id) + this.forcesell(String(item.trade_id)) .then((xxx) => console.log(xxx)) .catch((error) => console.log(error.response)); } diff --git a/src/store/modules/ftbot/index.ts b/src/store/modules/ftbot/index.ts index c4744c9a..6bbda016 100644 --- a/src/store/modules/ftbot/index.ts +++ b/src/store/modules/ftbot/index.ts @@ -52,6 +52,7 @@ export enum BotStoreGetters { refreshRequired = 'refreshRequired', selectedBacktestResult = 'selectedBacktestResult', canRunBacktest = 'canRunBacktest', + stakeCurrencyDecimals = 'stakeCurrencyDecimals', } export default { @@ -121,6 +122,9 @@ export default { /** Determines if bot runs in webserver mode */ return state.botState?.runmode === RunModes.WEBSERVER; }, + [BotStoreGetters.stakeCurrencyDecimals](state: FtbotStateType): number { + return state.botState?.stake_currency_decimals || 3; + }, }, mutations: { updateRefreshRequired(state: FtbotStateType, refreshRequired: boolean) { diff --git a/src/types/types.ts b/src/types/types.ts index 463c7ce8..1255cbf3 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -54,6 +54,7 @@ export interface BotState { stake_amount: number; stake_currency: string; stake_currency_decimals?: number; + available_balance?: number; stoploss: number; strategy: string; /** Timeframe in readable form (e.g. 5m) */