Use "computed" for profit variables

This commit is contained in:
Matthias 2023-02-28 20:50:04 +01:00
parent 2c9a01bae2
commit 7ba0ef0512

View File

@ -1,7 +1,7 @@
<template>
<profit-pill
:profit-ratio="trade.profit_ratio"
:profit-abs="trade.profit_abs"
:profit-ratio="profitRatio"
:profit-abs="profitAbs"
:profit-desc="profitDesc"
:stake-currency="trade.quote_currency || 'USDT'"
/>
@ -16,6 +16,7 @@ import { computed } from 'vue';
const props = defineProps({
trade: { required: true, type: Object as () => Trade },
mode: { required: false, default: 'default', type: String },
});
const profitDesc = computed((): string => {
let profit = `Current profit: ${formatPercent(props.trade.profit_ratio)} (${
@ -24,6 +25,13 @@ const profitDesc = computed((): string => {
profit += `\nOpen since: ${timestampms(props.trade.open_timestamp)}`;
return profit;
});
const profitRatio = computed<number | undefined>(() => {
return props.trade.profit_ratio;
});
const profitAbs = computed<number | undefined>(() => {
return props.trade.profit_abs;
});
</script>
<style scoped></style>