mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-01-11 11:50:27 +01:00
Feature: Recursive exchange rates #92
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @icovada on GitHub (Dec 28, 2025).
To track the value of a "Dollar Cost Average Tracker" I have set up three currencies:
I use Euro to buy shares in a fund, but to do so I have to first exchange EUR to dollars, so the exchange goes through two transactions.
If I set up the DCA to track "F x €" it shows all negatives because despite having that day's exchange rate for "FxUSD" and "USDxEUR" it doesn't have direct "FxEUR" exchanges.
We should be able to come up with that data anyway.
@eitchtee commented on GitHub (Dec 28, 2025):
We have support for this using the
TransitiveAutomatic Exchange Rate provider519a85d256/app/apps/currencies/exchange_rates/providers.py (L91)It does require explicit declaration of what currencies you want to calculate based on your existing exchange rates, but after it's configured:
It first fetches all existing exchange rates and builds a bidirectional graph where:
When you need a rate from currency A to currency B, it uses BFS to find the shortest path through the graph. For example: If you need EUR -> JPY but only have EUR -> USD and USD -> JPY, it will find the path EUR -> USD -> JPY.
Maybe we could modify
get_exchange_rate()(here) to automatically fallback to the same behavior if it can't find a direct exchange rate, but I'm not sure this would perform well, considering we currently calculate everything at runtime (when it needs to be displayed to the user). The database cache we have should help a lot, just need to make sure the algorithm is good, as DCAs with a lot of entries already take some time to load due to this dynamic calculation, wouldn't want to slow it down even more.