wealthfolio icon indicating copy to clipboard operation
wealthfolio copied to clipboard

[bug] v3.0.0-beta.4 | Missing FX Conversion Activity Support

Open Jonjon-prog opened this issue 9 months ago • 3 comments

Problem Description

Wealthfolio doesn't support explicit foreign exchange (FX) conversion activities within the same account. When a user buys securities in a foreign currency (e.g., buying USD-denominated stocks from a EUR account), the bank performs an automatic EUR→USD conversion, but this conversion is not tracked in Wealthfolio.

This causes negative cash balances in the foreign currency and incorrect cash calculations.

Current Behavior

Activity Types Available:

  • BUY, SELL, DIVIDEND, INTEREST, DEPOSIT, WITHDRAWAL, TRANSFER_IN, TRANSFER_OUT, FEE, TAX, SPLIT, CREDIT, ADJUSTMENT, UNKNOWN

What happens:

  1. User imports/adds activities showing USD purchases (e.g., buying GOLD in USD)
  2. The bank automatically converts EUR→USD to fund the purchase
  3. Wealthfolio records the USD spending but has no record of the EUR→USD conversion
  4. Result: Negative USD cash balance (-649.962 USD) and incorrect cash percentages (EUR showing 197.61%, USD showing negative values)

Steps to Reproduce

  1. Create an account with EUR as base currency
  2. Add a BUY activity for a USD-denominated security (e.g., GOLD $100 USD)
  3. Navigate to Allocations > Cash category
  4. Observe negative USD cash balance and abnormal percentage calculations

Example from real data:

  • EUR Cash: 1108.215 EUR (shows as 197.61%)
  • USD Cash: -649.962 USD (shows as negative)
  • Net Total: 560.82 EUR

The percentages are mathematically correct but indicate missing conversion data.

Expected Behavior

The system should support one of these approaches:

Option 1: Explicit FX Activity Types

Add new activity types:

  • FX_OUT - Currency sold (e.g., EUR spent)
  • FX_IN - Currency received (e.g., USD received)

Option 2: Automatic FX Detection

When a BUY/SELL occurs in a currency different from the account's primary currency, automatically infer and create the conversion activities.

Option 3: Enhanced Transfer Types

Allow TRANSFER_OUT/TRANSFER_IN within the same account but different currencies to represent FX conversions.

Current Workaround

Users must manually add activities:

  • WITHDRAWAL of EUR (amount spent for conversion)
  • DEPOSIT of USD (amount received)

Or:

  • TRANSFER_OUT of EUR
  • TRANSFER_IN of USD (both in same account)

This is tedious and error-prone for accounts with frequent multi-currency transactions.

Technical Context

  • FX rates are already supported via the fx_rate field on activities
  • The FX service can fetch exchange rates for conversion
  • The health system has FX_INTEGRITY checks for missing/stale rates
  • Missing: Activity types and UI flows for recording conversions

Impact

  • Cash calculations are incorrect for multi-currency accounts
  • Portfolio valuation may be affected
  • User experience is confusing when seeing negative balances

Jonjon-prog avatar Feb 16 '26 12:02 Jonjon-prog

I can provide more examples if needed.

I would prefer the second automatic option if it's possible to ask for this 🙃, otherwise I think the explicit FX_OUT/FX_IN alternative would be the way instead of using the TRANSFER_OUT/TRANSFER_IN option

Johan3F avatar Sep 08 '26 19:09 Johan3F

I've opened PR #1924 to add the explicit same-account currency-exchange workflow discussed here.

The proposed implementation records the source debit and destination credit (for example, 100 USD → 92 EUR) as one activity, with desktop/mobile create, edit, duplicate and delete flows. Both native cash balances update together; the exchange is not counted as an external flow or contribution. The execution ratio stays separate from the FX rates used for portfolio valuation, and Spending includes both cash legs without classifying the exchange as income or spending.

This PR covers manual exchanges only. It does not infer conversions from BUY/SELL, add new CSV/broker import support (including #1402), or rewrite historical transfer pairs. Existing cross-account transfers and legacy paired-FX handling remain in place.

tiann avatar Oct 08 '26 01:10 tiann

I believe #1228 is related.

sylvank avatar Oct 14 '26 15:10 sylvank