afadil / wealthfolio

A Beautiful Private and Secure Desktop Investment Tracking Application
https://wealthfolio.app
GNU Affero General Public License v3.0
4.39k stars 228 forks source link

Some exchange rates don't get applied #81

Closed mocdaniel closed 2 months ago

mocdaniel commented 2 months ago

After importing all of my portfolio's orders, I noticed some exchange rates not being applied for the position's ticker as well as its corresponding holding.

What I mean with this is i.e. the following:

  1. I bought Rio Tinto (RIO) and got dividends once, both happened in EUR. The bulk import via CSV seems to have worked:
Screenshot 2024-09-09 at 14 03 42
  1. However, when looking at current statistics, the stats are all messed up:
Screenshot 2024-09-09 at 14 05 40

Now if I look up the stats on YAHOO, it displays the Rio Tinto statistics in Great British Pence (GBp), and matches the wrong ticker value displayed in the app 1:1.

I noticed the same behavior for other currency pairs as well, e.g. EURHKD. After a quick glance into the source code it looks like it returns the fallback conversion rate of 1.0 here, for some reason:

https://github.com/afadil/wealthfolio/blob/b7c9bc0ceb7f84112407402cb1ebaa9f42dc6dc6/src-tauri/src/portfolio/portfolio_service.rs#L74

However, without further debugging (and a better knowledge of Rust), I coulnd't find out why exactly this is/was happening.

My best guess is that many of the more 'exotic' currency pairs need to be converted by going over it this way:

$ASSETCURRENCY -> USD -> $BASECURRENCY

I've seen apps like Ghostfolio do it that way, probably because there always exists an exchange rate to/from USD, but probably not for (all) other currency pairs.

afadil commented 2 months ago

@mocdaniel You're probaly right, the app lookup exchange rate using Yahoo app. We need probably $ASSETCURRENCY -> USD -> $BASECURRENCY if we can get $ASSETCURRENCY -> $BASECURRENCY.

maelp commented 2 months ago

I have the same issue I think (added an issue)

Basically it seems the USD value is used instead of the EUR value, but is displayed with a EUR sign (when I setup my account in eur) hence causing confusion...

Perhaps you should have ALL VALUES internally be represented as {currency, amount} and a helper which is "displayInUserRequestedCurrency" which takes the {currency, amount} and converts it (using current exchange rates) to the user currency?

afadil commented 2 months ago

Should be fixed in v1.0.14. There is now a setting page to update exchange rate manually if can’t be fetched from yahoo finance api.

mocdaniel commented 2 months ago

How would I add such an exchange rate manually? I don't see a button triggering a dialog or anything similar. Maybe I'm missing something, don't want to open another issue just yet.

Screenshot 2024-09-23 at 10 32 20
afadil commented 2 months ago

You will see exchange rate when you add accounts and activities with currencies other than base currency. You will be able to edit the ones not found in Yahoo finance