mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-14 20:23:52 +00:00
Add sort trades by profit
This commit is contained in:
parent
6bc0562ec0
commit
c724abd655
|
@ -11,7 +11,12 @@ const emit = defineEmits<{ 'trade-select': [trade: Trade] }>();
|
|||
|
||||
const botStore = useBotStore();
|
||||
const selectedTrade = ref({} as Trade);
|
||||
const sortNewestFirst = ref(true);
|
||||
const sortDescendingOrder = ref(true)
|
||||
const sortMethod = ref('openDate')
|
||||
const sortMethodOptions = [
|
||||
{text: 'Open date', value: 'openDate'},
|
||||
{text: 'Profit', value: 'profit'},
|
||||
]
|
||||
|
||||
const onTradeSelect = (trade: Trade) => {
|
||||
selectedTrade.value = trade;
|
||||
|
@ -19,13 +24,23 @@ const onTradeSelect = (trade: Trade) => {
|
|||
};
|
||||
|
||||
const sortedTrades = computed(() => {
|
||||
if (sortMethod.value === 'profit') {
|
||||
return props.trades
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
sortNewestFirst.value
|
||||
sortDescendingOrder.value
|
||||
? b.profit_ratio - a.profit_ratio
|
||||
: a.profit_ratio - b.profit_ratio,
|
||||
)
|
||||
} else {
|
||||
return props.trades
|
||||
.slice()
|
||||
.sort((a, b) =>
|
||||
sortDescendingOrder.value
|
||||
? b.open_timestamp - a.open_timestamp
|
||||
: a.open_timestamp - b.open_timestamp,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const ordersVisible = ref(sortedTrades.value.map(() => false));
|
||||
|
@ -40,13 +55,21 @@ watch(
|
|||
|
||||
<template>
|
||||
<div>
|
||||
<div class="d-flex justify-content-center">
|
||||
<span class="me-2">Sort by:</span>
|
||||
<BFormRadioGroup
|
||||
v-model="sortMethod"
|
||||
:options="sortMethodOptions"
|
||||
name="radio-options"
|
||||
/>
|
||||
</div>
|
||||
<BListGroup>
|
||||
<BListGroupItem
|
||||
button
|
||||
class="d-flex flex-wrap justify-content-center align-items-center"
|
||||
:title="'Trade Navigation'"
|
||||
@click="sortNewestFirst = !sortNewestFirst"
|
||||
>Trade Navigation {{ sortNewestFirst ? '↓' : '↑' }}
|
||||
@click="sortDescendingOrder = !sortDescendingOrder"
|
||||
>Trade Navigation {{ sortDescendingOrder ? '↓' : '↑' }}
|
||||
</BListGroupItem>
|
||||
<BListGroupItem
|
||||
v-for="(trade, i) in sortedTrades"
|
||||
|
|
Loading…
Reference in New Issue
Block a user