Skip to content

Commit

Permalink
Improve HoldingCalculator Security Preloading
Browse files Browse the repository at this point in the history
- Include securities from both trades and current holdings
- Ensure unique securities are preloaded
- Enhance logging for preloaded securities
  • Loading branch information
Shpigford committed Feb 4, 2025
1 parent 9c846e7 commit bdec61f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/account/holding_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ def portfolio_start_date
end

def preload_securities
# Get securities from trades and current holdings
securities = trades.map(&:entryable).map(&:security).uniq
securities += account.holdings.where(date: Date.current).map(&:security)
securities.uniq!

Rails.logger.info "[HoldingCalculator] Preloading #{securities.size} securities for account #{account.id}"

securities.each do |security|
Expand Down

0 comments on commit bdec61f

Please sign in to comment.