Merged
Conversation
… values are derived from the same trade
Features/account pnls calendar
…turing function parameters
…nts controller tests
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| created_at: 'DESC', | ||
| }, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Save error silently swallowed without logging
Low Severity
The new catch block in pullAndSaveCoinCurrencyRates swallows the error from coinPriceRepository.save without logging it. If saves fail persistently (e.g., disk full, constraint violations), this would go completely unnoticed in production. The fallback to findOne is a fine recovery strategy, but the original error information is lost, making diagnosis of recurring save failures very difficult.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Note
Medium Risk
Touches portfolio/PnL calculation logic and introduces new non-trivial SQL aggregates, so incorrect semantics or edge cases could affect reported financial metrics. Changes are covered by expanded unit tests but still warrant careful validation against real data.
Overview
Adds a new portfolio stats API:
GET /accounts/:address/portfolio/statsaccepts optionalstartDate/endDateand returns aggregated trading metrics (top win, unrealized profit, win rate, avg hold duration, trade counts), resolving name addresses viaPortfolioService.resolveAccountAddress.Refactors PnL semantics and batching:
BclPnlServicenow distinguishes cumulative PnL (all-time invested/spent vs proceeds + current value, including closed positions) from range-based PnL (realized gains only), adds a timestamp-windowedcalculateDailyPnlBatchSQL path for per-day calendars, and updatesPortfolioServiceto compute range PnL via these per-day windows (keyed by timestamp) instead of a second block-height batch.Also improves developer/ops robustness:
scripts/db-restore.shresets the local DB user password after restore, andAePricingService.pullAndSaveCoinCurrencyRatesfalls back to the latest persisted rates if saving new rates fails.Written by Cursor Bugbot for commit 11e9cc5. This will update automatically on new commits. Configure here.