FIX holdings and exchange rate (#345)

* FIX holdings and exchange rate

- Fix holdings not showing total return instead showing day change %
- Fix exchange rate saving 0 for holidays, use LOCF - Last Observation Carried Forward

* Fix failing test
This commit is contained in:
soky srm
2025-11-17 15:18:20 +01:00
committed by GitHub
parent 2d188377a6
commit 0290ed636f
4 changed files with 10 additions and 5 deletions

View File

@@ -74,7 +74,7 @@ class Provider::TwelveData < Provider
data.map do |resp|
rate = resp.dig("close")
date = resp.dig("datetime")
if rate.nil?
if rate.nil? || rate.to_f <= 0
Rails.logger.warn("#{self.class.name} returned invalid rate data for pair from: #{from} to: #{to} on: #{date}. Rate data: #{rate.inspect}")
next
end
@@ -178,7 +178,7 @@ class Provider::TwelveData < Provider
values.map do |resp|
price = resp.dig("close")
date = resp.dig("datetime")
if price.nil?
if price.nil? || price.to_f <= 0
Rails.logger.warn("#{self.class.name} returned invalid price data for security #{symbol} on: #{date}. Price data: #{price.inspect}")
next
end