mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
Handle market holidays during holding sync (#1292)
* Handle market holidays during holding sync * Use informal holidays instead of custom override
This commit is contained in:
parent
77fc5caecf
commit
3399b74849
4 changed files with 15 additions and 6 deletions
|
@ -32,7 +32,11 @@ class Gapfiller
|
|||
attr_reader :date_range, :cache
|
||||
|
||||
def should_gapfill?(date, record)
|
||||
date.on_weekend? && record.nil?
|
||||
(date.on_weekend? || holiday?(date)) && record.nil?
|
||||
end
|
||||
|
||||
def holiday?(date)
|
||||
Holidays.on(date, :federalreserve, :us, :informal).any?
|
||||
end
|
||||
|
||||
def create_gapfilled_record(prev_record, date)
|
||||
|
|
|
@ -38,13 +38,15 @@ module Security::Price::Provided
|
|||
|
||||
if response.success?
|
||||
response.prices.map do |price|
|
||||
new_price = Security::Price.new \
|
||||
new_price = Security::Price.find_or_initialize_by(
|
||||
ticker: ticker,
|
||||
date: price[:date],
|
||||
price: price[:price],
|
||||
currency: price[:currency]
|
||||
date: price[:date]
|
||||
) do |p|
|
||||
p.price = price[:price]
|
||||
p.currency = price[:currency]
|
||||
end
|
||||
|
||||
new_price.save! if cache
|
||||
new_price.save! if cache && new_price.new_record?
|
||||
new_price
|
||||
end
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue