1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-03 04:25:21 +02:00

First pass at security price reference (#1388)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* First pass at security price reference

* Data cleanup

* Synth security fetching does better with a mic_code

* Update test suite

😭

* Update schema.rb

* Update generator.rb
This commit is contained in:
Josh Pigford 2024-10-29 15:37:59 -04:00 committed by GitHub
parent bf695972e4
commit 490f44589e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 155 additions and 88 deletions

View file

@ -38,23 +38,31 @@ class Account::Holding::Syncer
def security_prices
@security_prices ||= begin
prices = {}
ticker_start_dates = {}
prices = {}
ticker_securities = {}
sync_entries.each do |entry|
unless ticker_start_dates[entry.account_trade.security.ticker]
ticker_start_dates[entry.account_trade.security.ticker] = entry.date
end
end
sync_entries.each do |entry|
security = entry.account_trade.security
unless ticker_securities[security.ticker]
ticker_securities[security.ticker] = {
security: security,
start_date: entry.date
}
end
end
ticker_start_dates.each do |ticker, date|
fetched_prices = Security::Price.find_prices(ticker: ticker, start_date: date, end_date: Date.current)
gapfilled_prices = Gapfiller.new(fetched_prices, start_date: date, end_date: Date.current, cache: false).run
prices[ticker] = gapfilled_prices
end
ticker_securities.each do |ticker, data|
fetched_prices = Security::Price.find_prices(
security: data[:security],
start_date: data[:start_date],
end_date: Date.current
)
gapfilled_prices = Gapfiller.new(fetched_prices, start_date: data[:start_date], end_date: Date.current, cache: false).run
prices[ticker] = gapfilled_prices
end
prices
end
prices
end
end
def build_holdings_for_date(date)