mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-10 18:23:50 +00:00
parent
5d94fe5f9c
commit
20d3b80d41
|
@ -52,53 +52,54 @@ export default defineComponent({
|
|||
const botList = ref<string[]>([]);
|
||||
const cumulativeData = ref<{ date: number; profit: any }[]>([]);
|
||||
|
||||
watch(
|
||||
() => props.trades,
|
||||
() => {
|
||||
botList.value = [];
|
||||
const res: CumProfitData[] = [];
|
||||
const resD: CumProfitDataPerDate = {};
|
||||
const closedTrades = props.trades
|
||||
.slice()
|
||||
.sort((a, b) => (a.close_timestamp > b.close_timestamp ? 1 : -1));
|
||||
let profit = 0.0;
|
||||
const calcCumulativeData = () => {
|
||||
console.log('trades');
|
||||
botList.value = [];
|
||||
const res: CumProfitData[] = [];
|
||||
const resD: CumProfitDataPerDate = {};
|
||||
const closedTrades = props.trades
|
||||
.slice()
|
||||
.sort((a, b) => (a.close_timestamp > b.close_timestamp ? 1 : -1));
|
||||
let profit = 0.0;
|
||||
|
||||
for (let i = 0, len = closedTrades.length; i < len; i += 1) {
|
||||
const trade = closedTrades[i];
|
||||
for (let i = 0, len = closedTrades.length; i < len; i += 1) {
|
||||
const trade = closedTrades[i];
|
||||
|
||||
if (trade.close_timestamp && trade[props.profitColumn]) {
|
||||
profit += trade[props.profitColumn];
|
||||
if (!resD[trade.close_timestamp]) {
|
||||
// New timestamp
|
||||
resD[trade.close_timestamp] = { profit, [trade.botId]: profit };
|
||||
if (trade.close_timestamp && trade[props.profitColumn]) {
|
||||
profit += trade[props.profitColumn];
|
||||
if (!resD[trade.close_timestamp]) {
|
||||
// New timestamp
|
||||
resD[trade.close_timestamp] = { profit, [trade.botId]: profit };
|
||||
} else {
|
||||
// Add to existing profit
|
||||
resD[trade.close_timestamp].profit += trade[props.profitColumn];
|
||||
if (resD[trade.close_timestamp][trade.botId]) {
|
||||
resD[trade.close_timestamp][trade.botId] += trade[props.profitColumn];
|
||||
} else {
|
||||
// Add to existing profit
|
||||
resD[trade.close_timestamp].profit += trade[props.profitColumn];
|
||||
if (resD[trade.close_timestamp][trade.botId]) {
|
||||
resD[trade.close_timestamp][trade.botId] += trade[props.profitColumn];
|
||||
} else {
|
||||
resD[trade.close_timestamp][trade.botId] = profit;
|
||||
}
|
||||
}
|
||||
// console.log(trade.close_date, profit);
|
||||
res.push({ date: trade.close_timestamp, profit, [trade.botId]: profit });
|
||||
if (!botList.value.includes(trade.botId)) {
|
||||
botList.value.push(trade.botId);
|
||||
resD[trade.close_timestamp][trade.botId] = profit;
|
||||
}
|
||||
}
|
||||
// console.log(trade.close_date, profit);
|
||||
res.push({ date: trade.close_timestamp, profit, [trade.botId]: profit });
|
||||
if (!botList.value.includes(trade.botId)) {
|
||||
botList.value.push(trade.botId);
|
||||
}
|
||||
}
|
||||
// console.log(resD);
|
||||
}
|
||||
// console.log(resD);
|
||||
|
||||
cumulativeData.value = Object.entries(resD).map(([k, v]) => {
|
||||
const obj = { date: parseInt(k, 10), profit: v.profit };
|
||||
// TODO: The below could allow "lines" per bot"
|
||||
// this.botList.forEach((botId) => {
|
||||
// obj[botId] = v[botId];
|
||||
// });
|
||||
return obj;
|
||||
});
|
||||
},
|
||||
);
|
||||
cumulativeData.value = Object.entries(resD).map(([k, v]) => {
|
||||
const obj = { date: parseInt(k, 10), profit: v.profit };
|
||||
// TODO: The below could allow "lines" per bot"
|
||||
// this.botList.forEach((botId) => {
|
||||
// obj[botId] = v[botId];
|
||||
// });
|
||||
return obj;
|
||||
});
|
||||
};
|
||||
watch([props.trades], calcCumulativeData);
|
||||
// Initial call
|
||||
calcCumulativeData();
|
||||
|
||||
const chartOptions = computed((): EChartsOption => {
|
||||
const chartOptionsLoc: EChartsOption = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user