Show absolute profit in trades list

This commit is contained in:
Matthias 2021-07-17 16:00:15 +02:00
parent a7a20a8919
commit 5143334005
3 changed files with 19 additions and 3 deletions

View File

@ -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));
}

View File

@ -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) {

View File

@ -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) */