when coin is sold out, it will not be save in db with amount and usdPrice is 0.
fix code:
// ...
const filteredTotals = _(totals).filter(t => !_(t.wallet).startsWith("md5:")).filter(t => {
// already handled in loadPortfolios
if (t.usdValue === 0){
return true
}
if (t.usdValue > 1) {
return true
}
const totalWallet = md5(t.wallet)
const lastAsset = _(lastAssets).flatten().find(a => a.symbol === t.symbol && a.wallet === totalWallet)
// not found in last asset, which means coin has already been removed before last record
if (!lastAsset) {
return false
}
// coin has been sold out in last time
if (lastAsset.usdValue === 0) {
return false
}
return true
}).map(t=>({
...t,
// if usdValue < 1, means it has been sold out this time. update it to 0, because coin whose usdValue < 1 will be ignored before saving to database
usdValue: t.usdValue > 1 ? t.usdValue : 0,
})).value()
when coin is sold out, it will not be save in db with amount and usdPrice is 0.
fix code: