Files
sure/app/models/provider/exchange_rate_concept.rb
soky srm e40811b1ee Add improvements from security providers to FX providers also (#1445)
* FIX prefer provider rate always

- add debugging also

* Move logic from securities over

* FIXes

* Review fixes

* Update provided.rb

---------

Signed-off-by: soky srm <sokysrm@gmail.com>
2026-04-13 00:51:23 +02:00

22 lines
743 B
Ruby

module Provider::ExchangeRateConcept
extend ActiveSupport::Concern
Rate = Data.define(:date, :from, :to, :rate)
def fetch_exchange_rate(from:, to:, date:)
raise NotImplementedError, "Subclasses must implement #fetch_exchange_rate"
end
def fetch_exchange_rates(from:, to:, start_date:, end_date:)
raise NotImplementedError, "Subclasses must implement #fetch_exchange_rates"
end
# Maximum number of calendar days of historical FX data the provider can
# return. Returns nil when the provider has no known limit (unbounded).
# Callers should clamp start_date when non-nil to avoid requesting data
# beyond this window. Override in subclasses with provider-specific limits.
def max_history_days
nil
end
end