Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gem "csv"
gem "redcarpet"
gem "stripe"
gem "intercom-rails"
gem "holidays"

group :development, :test do
gem "debug", platforms: %i[mri windows]
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ GEM
thor (>= 1.0.0)
hashdiff (1.1.1)
highline (3.0.1)
holidays (8.8.0)
hotwire-livereload (1.4.1)
actioncable (>= 6.0.0)
listen (>= 3.0.0)
Expand Down Expand Up @@ -486,6 +487,7 @@ DEPENDENCIES
faraday-multipart
faraday-retry
good_job
holidays
hotwire-livereload
i18n-tasks
image_processing (>= 1.2)
Expand Down
6 changes: 5 additions & 1 deletion app/models/gapfiller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ def run
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)
Expand Down
12 changes: 7 additions & 5 deletions app/models/security/price/provided.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ def fetch_prices_from_provider(ticker:, start_date:, end_date:, cache: false)

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
Expand Down