mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-25 04:25:15 +00:00
Merge pull request #2114 from xzmeng/sort-trades-by-profit
Add sorting trades by profit
This commit is contained in:
commit
3c55cc7f19
|
@ -11,7 +11,12 @@ const emit = defineEmits<{ 'trade-select': [trade: Trade] }>();
|
||||||
|
|
||||||
const botStore = useBotStore();
|
const botStore = useBotStore();
|
||||||
const selectedTrade = ref({} as Trade);
|
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) => {
|
const onTradeSelect = (trade: Trade) => {
|
||||||
selectedTrade.value = trade;
|
selectedTrade.value = trade;
|
||||||
|
@ -19,13 +24,10 @@ const onTradeSelect = (trade: Trade) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const sortedTrades = computed(() => {
|
const sortedTrades = computed(() => {
|
||||||
return props.trades
|
const field: keyof Trade = sortMethod.value === 'profit' ? 'profit_ratio' : 'open_timestamp';
|
||||||
.slice()
|
return sortDescendingOrder.value
|
||||||
.sort((a, b) =>
|
? props.trades.slice().sort((a, b) => b[field] - a[field])
|
||||||
sortNewestFirst.value
|
: props.trades.slice().sort((a, b) => a[field] - b[field]);
|
||||||
? b.open_timestamp - a.open_timestamp
|
|
||||||
: a.open_timestamp - b.open_timestamp,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const ordersVisible = ref(sortedTrades.value.map(() => false));
|
const ordersVisible = ref(sortedTrades.value.map(() => false));
|
||||||
|
@ -40,13 +42,17 @@ watch(
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<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>
|
<BListGroup>
|
||||||
<BListGroupItem
|
<BListGroupItem
|
||||||
button
|
button
|
||||||
class="d-flex flex-wrap justify-content-center align-items-center"
|
class="d-flex flex-wrap justify-content-center align-items-center"
|
||||||
:title="'Trade Navigation'"
|
:title="'Trade Navigation'"
|
||||||
@click="sortNewestFirst = !sortNewestFirst"
|
@click="sortDescendingOrder = !sortDescendingOrder"
|
||||||
>Trade Navigation {{ sortNewestFirst ? '↓' : '↑' }}
|
>Trade Navigation {{ sortDescendingOrder ? '↓' : '↑' }}
|
||||||
</BListGroupItem>
|
</BListGroupItem>
|
||||||
<BListGroupItem
|
<BListGroupItem
|
||||||
v-for="(trade, i) in sortedTrades"
|
v-for="(trade, i) in sortedTrades"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user