mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +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
1
Gemfile
1
Gemfile
|
@ -48,6 +48,7 @@ gem "csv"
|
||||||
gem "redcarpet"
|
gem "redcarpet"
|
||||||
gem "stripe"
|
gem "stripe"
|
||||||
gem "intercom-rails"
|
gem "intercom-rails"
|
||||||
|
gem "holidays"
|
||||||
|
|
||||||
group :development, :test do
|
group :development, :test do
|
||||||
gem "debug", platforms: %i[mri windows]
|
gem "debug", platforms: %i[mri windows]
|
||||||
|
|
|
@ -183,6 +183,7 @@ GEM
|
||||||
thor (>= 1.0.0)
|
thor (>= 1.0.0)
|
||||||
hashdiff (1.1.1)
|
hashdiff (1.1.1)
|
||||||
highline (3.0.1)
|
highline (3.0.1)
|
||||||
|
holidays (8.8.0)
|
||||||
hotwire-livereload (1.4.1)
|
hotwire-livereload (1.4.1)
|
||||||
actioncable (>= 6.0.0)
|
actioncable (>= 6.0.0)
|
||||||
listen (>= 3.0.0)
|
listen (>= 3.0.0)
|
||||||
|
@ -486,6 +487,7 @@ DEPENDENCIES
|
||||||
faraday-multipart
|
faraday-multipart
|
||||||
faraday-retry
|
faraday-retry
|
||||||
good_job
|
good_job
|
||||||
|
holidays
|
||||||
hotwire-livereload
|
hotwire-livereload
|
||||||
i18n-tasks
|
i18n-tasks
|
||||||
image_processing (>= 1.2)
|
image_processing (>= 1.2)
|
||||||
|
|
|
@ -32,7 +32,11 @@ class Gapfiller
|
||||||
attr_reader :date_range, :cache
|
attr_reader :date_range, :cache
|
||||||
|
|
||||||
def should_gapfill?(date, record)
|
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
|
end
|
||||||
|
|
||||||
def create_gapfilled_record(prev_record, date)
|
def create_gapfilled_record(prev_record, date)
|
||||||
|
|
|
@ -38,13 +38,15 @@ module Security::Price::Provided
|
||||||
|
|
||||||
if response.success?
|
if response.success?
|
||||||
response.prices.map do |price|
|
response.prices.map do |price|
|
||||||
new_price = Security::Price.new \
|
new_price = Security::Price.find_or_initialize_by(
|
||||||
ticker: ticker,
|
ticker: ticker,
|
||||||
date: price[:date],
|
date: price[:date]
|
||||||
price: price[:price],
|
) do |p|
|
||||||
currency: price[:currency]
|
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
|
new_price
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue