fully Support Cumprofitchart while no trade has been closed.

This commit is contained in:
Matthias 2023-07-14 07:03:04 +02:00
parent c60898c685
commit b722e1ff0a

View File

@ -107,16 +107,23 @@ const cumulativeData = computed<CumProfitChartData[]>(() => {
}, },
); );
if (props.openTrades.length > 0 && valueArray.length > 0) { if (props.openTrades.length > 0) {
const lastPoint = valueArray[valueArray.length - 1]; let lastProfit = 0;
if (lastPoint) { let lastDate = 0;
const resultWitHOpen = (lastPoint.profit ?? 0) + openProfit.value; if (valueArray.length > 0) {
valueArray.push({ date: lastPoint.date, currentProfit: lastPoint.profit }); const lastPoint = valueArray[valueArray.length - 1];
// Add one day to date to ensure it's showing properly lastProfit = lastPoint.profit ?? 0;
const tomorrow = Date.now() + 24 * 60 * 60 * 1000; lastDate = lastPoint.date ?? 0;
valueArray.push({ date: tomorrow, currentProfit: resultWitHOpen }); } else {
lastDate = props.openTrades[0].open_timestamp;
} }
const resultWitHOpen = (lastProfit ?? 0) + openProfit.value;
valueArray.push({ date: lastDate, currentProfit: lastProfit });
// Add one day to date to ensure it's showing properly
const tomorrow = Date.now() + 24 * 60 * 60 * 1000;
valueArray.push({ date: tomorrow, currentProfit: resultWitHOpen });
} }
console.log(valueArray);
return valueArray; return valueArray;
}); });