Conversation
✅ Deploy Preview for fancy-gelato-7cdad5 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| to, | ||
| }, | ||
| }; | ||
| }, [rechartsData, convertTo]); |
There was a problem hiding this comment.
Bug: PnL calculation incorrectly includes deposits and withdrawals
The new PnL calculation computes profit/loss as the difference between portfolio values at the start and end of the time window. This incorrectly treats deposits and withdrawals as gains or losses. For example, if a user deposits 100 AE mid-period, it appears as a 100 AE profit. True PnL requires tracking the cost basis of investments, which the removed backend calculation provided. The same issue affects the hover PnL calculation at lines 1086-1132.
|
I tried to reproduce it -> for the increse of pnl with AE seems to be ok I tried to simulate for the loss again, could not simulate it for some reason since always show 0 AE However I navigated to https://deploy-preview-373--fancy-gelato-7cdad5.netlify.app/trends/leaderboard and took the last account with a -25$ pnl in the last 30 days and take a look at his profile: account: ak_25LoeDiZB9bATDCYCJT5mtgnfEvBmURAqecQDgmZ85eErfroFH |


fixes #362
Note
Compute PnL from chart values (incl. hover) instead of fetching, and optimize crosshair/hover performance with memoization and stable handlers.
src/components/Account/AccountPortfolio.tsx):useQueryPnL fetch with local derivation fromrechartsDatafor current and hovered points.handleChartHoverviauseCallbackand pass toRechartsChart.minValue/maxValue; include them in effect deps.Written by Cursor Bugbot for commit 8e427eb. This will update automatically on new commits. Configure here.