There was an interesting conversation on the subreddit yesterday about
currency conversion, but I don't really know if there is a good
answer.
I spend money in two currencies and sometimes have to convert between
them, I think there are two basic ways to record this.
This is the way I usually do it:
2025/09/04 * Convert Currency
Assets:Bank $135 @@ £100
Assets:Bank
You just converted £100 to $135, easy. IIUC, hledger users
prefer something like this because there are built-in tools to handle
it:
2025/09/04 * Convert Currency
Assets:Bank $135
Assets:Bank -£100
Equity:Conversion
There are problems with both solutions. The problem with the @@ syntax
is that there is no way to mark a commodity as fungible, so each
conversion will create new lots.
Example:
$ cat test.ldg
2025/09/04 * Convert Currency
Assets:Bank $135.00 @@ £100
Assets:Bank
2025/09/04 * Baker
Expenses:Food $5 ; Sandwich
Assets:Bank
$ ledger --file test.ldg bal --lots ^Assets:Bank
$-5.00
$135.00 {£0.74074074} [04-Sep-2025] Assets:Bank
Nobody records which lot they used to buy a sandwich, so you get stuck
with these useless lots that mess up various reports.
I know one workaround, you can strip lot annotations and make them
fungible like this:
$ cat test.ldg
2025/09/04 * Convert Currency
Assets:Bank $135.00 @@ £100
Assets:Bank -$135.00 {{£100}} [2025-09-04] @ $1
Assets:Bank
2025/09/04 * Baker
Expenses:Food $5 ; Sandwich
Assets:Bank
$ ledger --file test.ldg bal --lots ^Assets:Bank
$130.00 Assets:Bank
It's kinda ugly though, I wish there was a commodity option! Maybe
something like this?
commodity $
format $1,000.00
alias USD
default
fungible
I guess someone might actually trade currencies *and* spend them... so
you want some lots to be non-fungible for tax purposes. I guess you
could use seperate commodities, like USD and FOREX.USD?
I'm not a fan of the Equity:Conversion solution, the conversion isn't
recorded, it's just stuffed in there out of the way... it doesn't
feel correct to me and I think probably breaks basis/historical/gain
reports?
I don't know, what do other people do?
Tavis.
--
_o) $ lynx lock.cmpxchg8b.com
/\\ _o) _o) $ finger [email protected]
_\_V _( ) _( ) @taviso
--
---
You received this message because you are subscribed to the Google Groups
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/ledger-cli/109f1gk%24qou%241%40ciao.gmane.io.