Repository navigation
fix(accounts): clamp breached balances at accepted drawdown floor - #246
hugodemenez wants to merge 3 commits into
Conversation
Clamp displayed balances at the drawdown floor across account metrics, daily stats, and equity charts so post-breach losses are not over-reported. - Extract shared drawdown helpers in lib/account-drawdown.ts - Apply floor clamp in computeAccountMetrics and dailyMetrics - Align trade-progress-chart, account-equity-chart, and account-table - Add unit tests and vitest path alias config Closes #86 Co-authored-by: Hugo Demenez <hugodemenez@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Stale comment
Not approving: Cursor Bugbot is not configured on this PR, and the completed
cursor-reviewautomation flagged unresolved medium findings (inconsistent post-breach balance propagation across charts vs metrics). Human verification is needed before merge. No reviewers assigned — the only repo collaborator is the PR author.Sent by Cursor Approval Agent: Pull Request Approver
Address PR review feedback: - Feed clamped balance into the next day/event in daily metrics and equity chart, matching trade-progress-chart behavior - Add propagation regression test for post-breach daily balances - Add bun run test script and GitHub Actions test workflow Co-authored-by: Hugo Demenez <hugodemenez@users.noreply.github.com>
When drawdown is breached and later trades exist, prompt the user to either set a reset date for a new evaluation or mark the account as bursted. - Add bursted and breachDate fields to Account schema - Detect post-breach trades with lib/account-breach.ts - Exclude post-breach trades from metrics when bursted - Add AccountBreachPrompt dialog in accounts overview - Show bursted state on account card and table Co-authored-by: Hugo Demenez <hugodemenez@users.noreply.github.com>
🤖 Automated Code ReviewPR Review SummaryThis PR adds prop-firm drawdown handling: balance clamping at the drawdown floor, persisted Critical1. Missing Prisma migration
2. Breach detection ignores payouts
3. Silent save failures in
Medium4. Impure
5. No validation on reset date The calendar allows any date. Users can pick a date before the breach or unrelated to the first post-breach trade. Constrain to 6.
7. Confirming reset clears Minor / Best Practices8. Error handling & UX
9. Performance
10. CI workflow
11. TypeScript / React
12. Security
What looks good
VerdictDo not merge until a Prisma migration is added and payout-aware breach detection is aligned with metrics (or explicitly documented as trade-only). Add save error handling before shipping the prompt UX. The core drawdown clamping and test infrastructure are well done. Generated by Cursor CLI workflow — |
There was a problem hiding this comment.
Not approving: Cursor Bugbot is not configured on this PR, and the latest cursor-review on head (82ad8e7) reports critical findings (missing Prisma migration, payout-aware breach detection, silent save failures). Human verification is needed before merge. No reviewers assigned — the only repo collaborator is the PR author.
Sent by Cursor Approval Agent: Pull Request Approver


Problem
Fixes #86 — after a prop-firm account breaches its drawdown, balances could keep displaying losses below the accepted loss floor, and continued trading after a bust was ambiguous.
Changes
Drawdown floor display
lib/account-drawdown.tsPost-breach lifecycle
burstedandbreachDatefields onAccountlib/account-breach.ts)AccountBreachPrompt:resetDate, clearsburstedbursted+breachDate, metrics ignore post-breach tradesQuality
bun run testscript + GitHub Actions test workflowTesting
bun run test(29 tests)bun run typecheckOPENAI_API_KEY=dummy bun run buildMigration
Run
bunx prisma db push(or deploy migration) to addburstedandbreachDatecolumns.