Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Showing wrong currency value at Holdings #168

Open
sertxudev opened this issue Nov 17, 2024 · 3 comments
Open

[BUG] Showing wrong currency value at Holdings #168

sertxudev opened this issue Nov 17, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@sertxudev
Copy link

Hi, awesome work!

I've noticed account holdings are shown with the account currency (EUR):

image

These should be:

Total value Today's price
€9,15 €9,64 €4,58 €4,82

The values shown are retrieved from Yahoo finance, which are stored in USD.

image

The account holdings should be converted to EUR (or whatever the account currency is).

The other values in the account are working as expected.

image

So the bug it's only at the account holdings table.

@MarcinFrankowski
Copy link

MarcinFrankowski commented Nov 22, 2024

The problem seems to be caused by the calculation logic in the HoldingsService. It's using the holding currency instead of the asset currency to get the exchange rate.

Additionally, there's book_value_converted field that doesn't make much sense to me, since it's not calculated using the exchange rate from day of the activity but the current exchange rate

It gets even more interesting when you have 3 currencies in the setup.

  1. Set up currency A as a base currency
  2. Add 2 accounts with B and C currencies
  3. Add the same BUY activity of any asset to both accounts and compare the numbers on the account and holdings pages

I think the discrepancies come from the confusion around book_value
For examample if we have an account in currency B but the asset currency is C, then the value of market_value is in currency C but book_value is in currency B. What's even more confusing both of values are converted using the same exchange rate to the base account currency A
this code does that

@MarcinFrankowski
Copy link

I was able to fix the values on Account Holdings page with some debatable calculation changes, but discovered that the same logic is used for the Holdings Page and the fix can't be applied to display correct value on both pages.
My take is that the root cause is the data model structure. The Holding class has values in different currencies. The currency conversion needs to be improved, and it should take into account the context of where the values are presented. For example it should use the account currency on the Account Holdings page and base currency on the Holdings page.

The Holding page gets more complicated when you have the same asset on two account with different currencies. Right now it will add simply add the book values even if the currency does not match (ie. 100$ + 100€ = 200$)

@rafaelgreca
Copy link

Same problem here with VWCE and XEON stocks.

@afadil afadil added the bug Something isn't working label Jan 14, 2025
@afadil afadil self-assigned this Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants